diff --git a/examples/one_function_multi_call/one_function_multi_call.c b/examples/one_function_multi_call/one_function_multi_call.c new file mode 100644 index 000000000..4aab3dd14 --- /dev/null +++ b/examples/one_function_multi_call/one_function_multi_call.c @@ -0,0 +1,23 @@ +#include + +// Function declarations +int addNumbers(int a, int b); + +int callAddFromAnotherFunction(int x, int y) { + return addNumbers(x, y); +} + +int callFromFun2(int x, int y) { + return addNumbers(x, y); +} + +int addNumbers(int a, int b) { + return a + b; +} + +int main() { + int resultFromMain = addNumbers(10, 5); + int resultFromOtherFunc = callAddFromAnotherFunction(20, 15); + int resultFromFun2 = callFromFun2(30, 25); + return 0; +} diff --git a/examples/stackambiguity/stackambiguity.adt b/examples/stackambiguity/stackambiguity.adt new file mode 100644 index 000000000..c06f24fdd --- /dev/null +++ b/examples/stackambiguity/stackambiguity.adt @@ -0,0 +1,673 @@ +Project(Attrs([Attr("filename","\"a.out\""), +Attr("image-specification","(declare abi (name str))\n(declare arch (name str))\n(declare base-address (addr int))\n(declare bias (off int))\n(declare bits (size int))\n(declare code-region (addr int) (size int) (off int))\n(declare code-start (addr int))\n(declare entry-point (addr int))\n(declare external-reference (addr int) (name str))\n(declare format (name str))\n(declare is-executable (flag bool))\n(declare is-little-endian (flag bool))\n(declare llvm:base-address (addr int))\n(declare llvm:code-entry (name str) (off int) (size int))\n(declare llvm:coff-import-library (name str))\n(declare llvm:coff-virtual-section-header (name str) (addr int) (size int))\n(declare llvm:elf-program-header (name str) (off int) (size int))\n(declare llvm:elf-program-header-flags (name str) (ld bool) (r bool) \n (w bool) (x bool))\n(declare llvm:elf-virtual-program-header (name str) (addr int) (size int))\n(declare llvm:entry-point (addr int))\n(declare llvm:macho-symbol (name str) (value int))\n(declare llvm:name-reference (at int) (name str))\n(declare llvm:relocation (at int) (addr int))\n(declare llvm:section-entry (name str) (addr int) (size int) (off int))\n(declare llvm:section-flags (name str) (r bool) (w bool) (x bool))\n(declare llvm:segment-command (name str) (off int) (size int))\n(declare llvm:segment-command-flags (name str) (r bool) (w bool) (x bool))\n(declare llvm:symbol-entry (name str) (addr int) (size int) (off int)\n (value int))\n(declare llvm:virtual-segment-command (name str) (addr int) (size int))\n(declare mapped (addr int) (size int) (off int))\n(declare named-region (addr int) (size int) (name str))\n(declare named-symbol (addr int) (name str))\n(declare require (name str))\n(declare section (addr int) (size int))\n(declare segment (addr int) (size int) (r bool) (w bool) (x bool))\n(declare subarch (name str))\n(declare symbol-chunk (addr int) (size int) (root int))\n(declare symbol-value (addr int) (value int))\n(declare system (name str))\n(declare vendor (name str))\n\n(abi unknown)\n(arch aarch64)\n(base-address 0)\n(bias 0)\n(bits 64)\n(code-region 1952 20 1952)\n(code-region 1536 416 1536)\n(code-region 1440 96 1440)\n(code-region 1408 24 1408)\n(code-start 1588)\n(code-start 1536)\n(code-start 1860)\n(code-start 1812)\n(entry-point 1536)\n(external-reference 69568 _ITM_deregisterTMCloneTable)\n(external-reference 69576 __cxa_finalize)\n(external-reference 69584 __gmon_start__)\n(external-reference 69600 _ITM_registerTMCloneTable)\n(external-reference 69632 __libc_start_main)\n(external-reference 69640 __cxa_finalize)\n(external-reference 69648 __gmon_start__)\n(external-reference 69656 abort)\n(format elf)\n(is-executable true)\n(is-little-endian true)\n(llvm:base-address 0)\n(llvm:code-entry abort 0 0)\n(llvm:code-entry __cxa_finalize 0 0)\n(llvm:code-entry __libc_start_main 0 0)\n(llvm:code-entry test 1812 48)\n(llvm:code-entry _init 1408 0)\n(llvm:code-entry main 1860 92)\n(llvm:code-entry _start 1536 52)\n(llvm:code-entry abort@GLIBC_2.17 0 0)\n(llvm:code-entry _fini 1952 0)\n(llvm:code-entry __cxa_finalize@GLIBC_2.17 0 0)\n(llvm:code-entry __libc_start_main@GLIBC_2.34 0 0)\n(llvm:code-entry frame_dummy 1808 0)\n(llvm:code-entry __do_global_dtors_aux 1728 0)\n(llvm:code-entry register_tm_clones 1664 0)\n(llvm:code-entry deregister_tm_clones 1616 0)\n(llvm:code-entry call_weak_fn 1588 20)\n(llvm:code-entry .fini 1952 20)\n(llvm:code-entry .text 1536 416)\n(llvm:code-entry .plt 1440 96)\n(llvm:code-entry .init 1408 24)\n(llvm:elf-program-header 08 3528 568)\n(llvm:elf-program-header 07 0 0)\n(llvm:elf-program-header 06 1976 68)\n(llvm:elf-program-header 05 596 68)\n(llvm:elf-program-header 04 3544 480)\n(llvm:elf-program-header 03 3528 616)\n(llvm:elf-program-header 02 0 2256)\n(llvm:elf-program-header 01 568 27)\n(llvm:elf-program-header 00 64 504)\n(llvm:elf-program-header-flags 08 false true false false)\n(llvm:elf-program-header-flags 07 false true true false)\n(llvm:elf-program-header-flags 06 false true false false)\n(llvm:elf-program-header-flags 05 false true false false)\n(llvm:elf-program-header-flags 04 false true true false)\n(llvm:elf-program-header-flags 03 true true true false)\n(llvm:elf-program-header-flags 02 true true false true)\n(llvm:elf-program-header-flags 01 false true false false)\n(llvm:elf-program-header-flags 00 false true false false)\n(llvm:elf-virtual-program-header 08 69064 568)\n(llvm:elf-virtual-program-header 07 0 0)\n(llvm:elf-virtual-program-header 06 1976 68)\n(llvm:elf-virtual-program-header 05 596 68)\n(llvm:elf-virtual-program-header 04 69080 480)\n(llvm:elf-virtual-program-header 03 69064 624)\n(llvm:elf-virtual-program-header 02 0 2256)\n(llvm:elf-virtual-program-header 01 568 27)\n(llvm:elf-virtual-program-header 00 64 504)\n(llvm:entry-point 1536)\n(llvm:name-reference 69656 abort)\n(llvm:name-reference 69648 __gmon_start__)\n(llvm:name-reference 69640 __cxa_finalize)\n(llvm:name-reference 69632 __libc_start_main)\n(llvm:name-reference 69600 _ITM_registerTMCloneTable)\n(llvm:name-reference 69584 __gmon_start__)\n(llvm:name-reference 69576 __cxa_finalize)\n(llvm:name-reference 69568 _ITM_deregisterTMCloneTable)\n(llvm:section-entry .shstrtab 0 259 6922)\n(llvm:section-entry .strtab 0 570 6352)\n(llvm:section-entry .symtab 0 2136 4216)\n(llvm:section-entry .comment 0 71 4144)\n(llvm:section-entry .bss 69680 8 4144)\n(llvm:section-entry .data 69664 16 4128)\n(llvm:section-entry .got.plt 69608 56 4072)\n(llvm:section-entry .got 69560 48 4024)\n(llvm:section-entry .dynamic 69080 480 3544)\n(llvm:section-entry .fini_array 69072 8 3536)\n(llvm:section-entry .init_array 69064 8 3528)\n(llvm:section-entry .eh_frame 2048 208 2048)\n(llvm:section-entry .eh_frame_hdr 1976 68 1976)\n(llvm:section-entry .rodata 1972 4 1972)\n(llvm:section-entry .fini 1952 20 1952)\n(llvm:section-entry .text 1536 416 1536)\n(llvm:section-entry .plt 1440 96 1440)\n(llvm:section-entry .init 1408 24 1408)\n(llvm:section-entry .rela.plt 1312 96 1312)\n(llvm:section-entry .rela.dyn 1120 192 1120)\n(llvm:section-entry .gnu.version_r 1072 48 1072)\n(llvm:section-entry .gnu.version 1054 18 1054)\n(llvm:section-entry .dynstr 912 141 912)\n(llvm:section-entry .dynsym 696 216 696)\n(llvm:section-entry .gnu.hash 664 28 664)\n(llvm:section-entry .note.ABI-tag 632 32 632)\n(llvm:section-entry .note.gnu.build-id 596 36 596)\n(llvm:section-entry .interp 568 27 568)\n(llvm:section-flags .shstrtab true false false)\n(llvm:section-flags .strtab true false false)\n(llvm:section-flags .symtab true false false)\n(llvm:section-flags .comment true false false)\n(llvm:section-flags .bss true true false)\n(llvm:section-flags .data true true false)\n(llvm:section-flags .got.plt true true false)\n(llvm:section-flags .got true true false)\n(llvm:section-flags .dynamic true true false)\n(llvm:section-flags .fini_array true true false)\n(llvm:section-flags .init_array true true false)\n(llvm:section-flags .eh_frame true false false)\n(llvm:section-flags .eh_frame_hdr true false false)\n(llvm:section-flags .rodata true false false)\n(llvm:section-flags .fini true false true)\n(llvm:section-flags .text true false true)\n(llvm:section-flags .plt true false true)\n(llvm:section-flags .init true false true)\n(llvm:section-flags .rela.plt true false false)\n(llvm:section-flags .rela.dyn true false false)\n(llvm:section-flags .gnu.version_r true false false)\n(llvm:section-flags .gnu.version true false false)\n(llvm:section-flags .dynstr true false false)\n(llvm:section-flags .dynsym true false false)\n(llvm:section-flags .gnu.hash true false false)\n(llvm:section-flags .note.ABI-tag true false false)\n(llvm:section-flags .note.gnu.build-id true false false)\n(llvm:section-flags .interp true false false)\n(llvm:symbol-entry abort 0 0 0 0)\n(llvm:symbol-entry __cxa_finalize 0 0 0 0)\n(llvm:symbol-entry __libc_start_main 0 0 0 0)\n(llvm:symbol-entry test 1812 48 1812 1812)\n(llvm:symbol-entry _init 1408 0 1408 1408)\n(llvm:symbol-entry main 1860 92 1860 1860)\n(llvm:symbol-entry _start 1536 52 1536 1536)\n(llvm:symbol-entry abort@GLIBC_2.17 0 0 0 0)\n(llvm:symbol-entry _fini 1952 0 1952 1952)\n(llvm:symbol-entry __cxa_finalize@GLIBC_2.17 0 0 0 0)\n(llvm:symbol-entry __libc_start_main@GLIBC_2.34 0 0 0 0)\n(llvm:symbol-entry frame_dummy 1808 0 1808 1808)\n(llvm:symbol-entry __do_global_dtors_aux 1728 0 1728 1728)\n(llvm:symbol-entry register_tm_clones 1664 0 1664 1664)\n(llvm:symbol-entry deregister_tm_clones 1616 0 1616 1616)\n(llvm:symbol-entry call_weak_fn 1588 20 1588 1588)\n(mapped 0 2256 0)\n(mapped 69064 616 3528)\n(named-region 0 2256 02)\n(named-region 69064 624 03)\n(named-region 568 27 .interp)\n(named-region 596 36 .note.gnu.build-id)\n(named-region 632 32 .note.ABI-tag)\n(named-region 664 28 .gnu.hash)\n(named-region 696 216 .dynsym)\n(named-region 912 141 .dynstr)\n(named-region 1054 18 .gnu.version)\n(named-region 1072 48 .gnu.version_r)\n(named-region 1120 192 .rela.dyn)\n(named-region 1312 96 .rela.plt)\n(named-region 1408 24 .init)\n(named-region 1440 96 .plt)\n(named-region 1536 416 .text)\n(named-region 1952 20 .fini)\n(named-region 1972 4 .rodata)\n(named-region 1976 68 .eh_frame_hdr)\n(named-region 2048 208 .eh_frame)\n(named-region 69064 8 .init_array)\n(named-region 69072 8 .fini_array)\n(named-region 69080 480 .dynamic)\n(named-region 69560 48 .got)\n(named-region 69608 56 .got.plt)\n(named-region 69664 16 .data)\n(named-region 69680 8 .bss)\n(named-region 0 71 .comment)\n(named-region 0 2136 .symtab)\n(named-region 0 570 .strtab)\n(named-region 0 259 .shstrtab)\n(named-symbol 1588 call_weak_fn)\n(named-symbol 1616 deregister_tm_clones)\n(named-symbol 1664 register_tm_clones)\n(named-symbol 1728 __do_global_dtors_aux)\n(named-symbol 1808 frame_dummy)\n(named-symbol 0 __libc_start_main@GLIBC_2.34)\n(named-symbol 0 __cxa_finalize@GLIBC_2.17)\n(named-symbol 1952 _fini)\n(named-symbol 0 abort@GLIBC_2.17)\n(named-symbol 1536 _start)\n(named-symbol 1860 main)\n(named-symbol 1408 _init)\n(named-symbol 1812 test)\n(named-symbol 0 __libc_start_main)\n(named-symbol 0 __cxa_finalize)\n(named-symbol 0 abort)\n(require libc.so.6)\n(section 568 27)\n(section 596 36)\n(section 632 32)\n(section 664 28)\n(section 696 216)\n(section 912 141)\n(section 1054 18)\n(section 1072 48)\n(section 1120 192)\n(section 1312 96)\n(section 1408 24)\n(section 1440 96)\n(section 1536 416)\n(section 1952 20)\n(section 1972 4)\n(section 1976 68)\n(section 2048 208)\n(section 69064 8)\n(section 69072 8)\n(section 69080 480)\n(section 69560 48)\n(section 69608 56)\n(section 69664 16)\n(section 69680 8)\n(section 0 71)\n(section 0 2136)\n(section 0 570)\n(section 0 259)\n(segment 0 2256 true false true)\n(segment 69064 624 true true false)\n(subarch v8)\n(symbol-chunk 1588 20 1588)\n(symbol-chunk 1536 52 1536)\n(symbol-chunk 1860 92 1860)\n(symbol-chunk 1812 48 1812)\n(symbol-value 1588 1588)\n(symbol-value 1616 1616)\n(symbol-value 1664 1664)\n(symbol-value 1728 1728)\n(symbol-value 1808 1808)\n(symbol-value 1952 1952)\n(symbol-value 1536 1536)\n(symbol-value 1860 1860)\n(symbol-value 1408 1408)\n(symbol-value 1812 1812)\n(symbol-value 0 0)\n(system \"\")\n(vendor \"\")\n"), +Attr("abi-name","\"aarch64-linux-gnu-elf\"")]), +Sections([Section(".shstrtab", 0x0, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x10\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x38\x00\x09\x00\x40\x00\x1d\x00\x1c\x00\x06\x00\x00\x00\x04\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd0\x08\x00\x00\x00\x00\x00\x00\xd0\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x00\x00\x06\x00\x00\x00\xc8\x0d\x00\x00\x00\x00\x00\x00\xc8\x0d\x01\x00\x00\x00\x00\x00\xc8\x0d\x01"), +Section(".strtab", 0x0, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x10\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x38\x00\x09\x00\x40\x00\x1d\x00\x1c\x00\x06\x00\x00\x00\x04\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd0\x08\x00\x00\x00\x00\x00\x00\xd0\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x00\x00\x06\x00\x00\x00\xc8\x0d\x00\x00\x00\x00\x00\x00\xc8\x0d\x01\x00\x00\x00\x00\x00\xc8\x0d\x01\x00\x00\x00\x00\x00\x68\x02\x00\x00\x00\x00\x00\x00\x70\x02\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x02\x00\x00\x00\x06\x00\x00\x00\xd8\x0d\x00\x00\x00\x00\x00\x00\xd8\x0d\x01\x00\x00\x00\x00\x00\xd8\x0d\x01\x00\x00\x00\x00\x00\xe0\x01\x00\x00\x00\x00\x00\x00\xe0\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x50\xe5\x74\x64\x04\x00\x00\x00\xb8\x07\x00\x00\x00\x00\x00\x00\xb8\x07\x00\x00\x00\x00\x00\x00\xb8\x07\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x51\xe5\x74\x64\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x52\xe5\x74\x64\x04\x00\x00\x00\xc8\x0d\x00\x00\x00\x00\x00\x00\xc8\x0d\x01\x00\x00\x00\x00\x00\xc8\x0d\x01\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x2f\x6c"), +Section(".symtab", 0x0, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x10\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x38\x00\x09\x00\x40\x00\x1d\x00\x1c\x00\x06\x00\x00\x00\x04\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd0\x08\x00\x00\x00\x00\x00\x00\xd0\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x00\x00\x06\x00\x00\x00\xc8\x0d\x00\x00\x00\x00\x00\x00\xc8\x0d\x01\x00\x00\x00\x00\x00\xc8\x0d\x01\x00\x00\x00\x00\x00\x68\x02\x00\x00\x00\x00\x00\x00\x70\x02\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x02\x00\x00\x00\x06\x00\x00\x00\xd8\x0d\x00\x00\x00\x00\x00\x00\xd8\x0d\x01\x00\x00\x00\x00\x00\xd8\x0d\x01\x00\x00\x00\x00\x00\xe0\x01\x00\x00\x00\x00\x00\x00\xe0\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x50\xe5\x74\x64\x04\x00\x00\x00\xb8\x07\x00\x00\x00\x00\x00\x00\xb8\x07\x00\x00\x00\x00\x00\x00\xb8\x07\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x51\xe5\x74\x64\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x52\xe5\x74\x64\x04\x00\x00\x00\xc8\x0d\x00\x00\x00\x00\x00\x00\xc8\x0d\x01\x00\x00\x00\x00\x00\xc8\x0d\x01\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x2f\x6c\x69\x62\x2f\x6c\x64\x2d\x6c\x69\x6e\x75\x78\x2d\x61\x61\x72\x63\x68\x36\x34\x2e\x73\x6f\x2e\x31\x00\x00\x04\x00\x00\x00\x14\x00\x00\x00\x03\x00\x00\x00\x47\x4e\x55\x00\x75\xee\xa3\x81\x5a\xcb\x3c\xbb\xd6\xda\x03\x86\xf7\x5e\x45\x89\x13\xf4\x8c\xfe\x04\x00\x00\x00\x10\x00\x00\x00\x01\x00\x00\x00\x47\x4e\x55\x00\x00\x00\x00\x00\x03\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x0b\x00\x80\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x17\x00\x20\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x48\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x64\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x22\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x73\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5f\x5f\x63\x78\x61\x5f\x66\x69\x6e\x61\x6c\x69\x7a\x65\x00\x5f\x5f\x6c\x69\x62\x63\x5f\x73\x74\x61\x72\x74\x5f\x6d\x61\x69\x6e\x00\x61\x62\x6f\x72\x74\x00\x6c\x69\x62\x63\x2e\x73\x6f\x2e\x36\x00\x47\x4c\x49\x42\x43\x5f\x32\x2e\x31\x37\x00\x47\x4c\x49\x42\x43\x5f\x32\x2e\x33\x34\x00\x5f\x49\x54\x4d\x5f\x64\x65\x72\x65\x67\x69\x73\x74\x65\x72\x54\x4d\x43\x6c\x6f\x6e\x65\x54\x61\x62\x6c\x65\x00\x5f\x5f\x67\x6d\x6f\x6e\x5f\x73\x74\x61\x72\x74\x5f\x5f\x00\x5f\x49\x54\x4d\x5f\x72\x65\x67\x69\x73\x74\x65\x72\x54\x4d\x43\x6c\x6f\x6e\x65\x54\x61\x62\x6c\x65\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x01\x00\x03\x00\x01\x00\x03\x00\x01\x00\x01\x00\x02\x00\x28\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x97\x91\x96\x06\x00\x00\x03\x00\x32\x00\x00\x00\x10\x00\x00\x00\xb4\x91\x96\x06\x00\x00\x02\x00\x3d\x00\x00\x00\x00\x00\x00\x00\xc8\x0d\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x10\x07\x00\x00\x00\x00\x00\x00\xd0\x0d\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\xc0\x06\x00\x00\x00\x00\x00\x00\xd8\x0f\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x44\x07\x00\x00\x00\x00\x00\x00\x28\x10\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x28\x10\x01\x00\x00\x00\x00\x00\xc0\x0f\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc8\x0f\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd0\x0f\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x0f\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x10\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x10\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x10\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x20\x03\xd5\xfd\x7b\xbf\xa9\xfd\x03\x00\x91\x2a\x00\x00\x94\xfd\x7b\xc1\xa8\xc0\x03\x5f\xd6\x00\x00\x00\x00\x00\x00\x00\x00\xf0\x7b\xbf\xa9\x90\x00\x00\x90\x11\xfe\x47\xf9\x10\xe2\x3f\x91\x20\x02\x1f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x90\x00\x00\xb0\x11\x02\x40\xf9\x10\x02\x00\x91\x20\x02\x1f\xd6\x90\x00\x00\xb0\x11\x06\x40\xf9\x10\x22\x00\x91\x20\x02\x1f\xd6\x90\x00\x00\xb0\x11\x0a\x40\xf9\x10\x42\x00\x91\x20\x02\x1f\xd6\x90\x00\x00\xb0\x11\x0e\x40\xf9\x10\x62\x00\x91\x20\x02\x1f\xd6\x1f\x20\x03\xd5\x1d\x00\x80\xd2\x1e\x00\x80\xd2\xe5\x03\x00\xaa\xe1\x03\x40\xf9\xe2\x23\x00\x91\xe6\x03\x00\x91\x80\x00\x00\x90\x00\xec\x47\xf9\x03\x00\x80\xd2\x04\x00\x80\xd2\xe5\xff\xff\x97\xf0\xff\xff\x97\x80\x00\x00\x90\x00\xe8\x47\xf9\x40\x00\x00\xb4\xe8\xff\xff\x17\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x80\x00\x00\xb0\x00\xc0\x00\x91\x81\x00\x00\xb0\x21\xc0\x00\x91\x3f\x00\x00\xeb\xc0\x00\x00\x54\x81\x00\x00\x90\x21\xe0\x47\xf9\x61\x00\x00\xb4\xf0\x03\x01\xaa\x00\x02\x1f\xd6\xc0\x03\x5f\xd6\x80\x00\x00\xb0\x00\xc0\x00\x91\x81\x00\x00\xb0\x21\xc0\x00\x91\x21\x00\x00\xcb\x22\xfc\x7f\xd3\x41\x0c\x81\x8b\x21\xfc\x41\x93\xc1\x00\x00\xb4\x82\x00\x00\x90\x42\xf0\x47\xf9\x62\x00\x00\xb4\xf0\x03\x02\xaa\x00\x02\x1f\xd6\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\xfd\x7b\xbe\xa9\xfd\x03\x00\x91\xf3\x0b\x00\xf9\x93\x00\x00\xb0\x60\xc2\x40\x39\x40\x01\x00\x35\x80\x00\x00\x90\x00\xe4\x47\xf9\x80\x00\x00\xb4\x80\x00\x00\xb0\x00\x14\x40\xf9\xb9\xff\xff\x97\xd8\xff\xff\x97\x20\x00\x80\x52\x60\xc2\x00\x39\xf3\x0b\x40\xf9\xfd\x7b\xc2\xa8\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\xdc\xff\xff\x17\xff\x43\x00\xd1\xe8\x03\x00\x91\x7f\x0c\x00\x71\x09\xc9\x23\x8b\x08\x21\x00\x91\x28\xb1\x88\x9a\xe0\x07\x00\x29\xe2\x7f\x01\x29\x08\x01\x40\xb9\x00\x05\x00\x11\xff\x43\x00\x91\xc0\x03\x5f\xd6\xff\x43\x00\xd1\x09\x10\x00\x11\x0b\x08\x00\x0b\xc8\x00\x80\x52\xea\x03\x00\x91\x0d\x7c\x7e\x93\x08\x01\x00\x4b\x4c\x21\x00\x91\x1f\x0c\x00\x71\x4a\x01\x0d\x8b\xe9\x2f\x00\x29\x49\xb1\x8c\x9a\x4d\x0b\x80\x52\x4a\xb1\x8c\x9a\xe8\x7f\x01\x29\x29\x01\x40\xb9\xeb\x23\x00\x29\xed\x07\x00\xf9\x48\x01\x40\xb9\x28\x01\x08\x0b\x00\x09\x00\x11\xff\x43\x00\x91\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\xfd\x7b\xbf\xa9\xfd\x03\x00\x91\xfd\x7b\xc1\xa8\xc0\x03\x5f\xd6\x01\x00\x02\x00\x01\x1b\x03\x3b\x44\x00\x00\x00\x07\x00\x00\x00\x48\xfe\xff\xff\x5c\x00\x00\x00\x98\xfe\xff\xff\x70\x00\x00\x00\xc8\xfe\xff\xff\x84\x00\x00\x00\x08\xff\xff\xff\x98\x00\x00\x00\x58\xff\xff\xff\xbc\x00\x00\x00\x5c\xff\xff\xff\xe4\x00\x00\x00\x8c\xff\xff\xff\xfc\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x01\x7a\x52\x00\x04\x78\x1e\x01\x1b\x0c\x1f\x00\x10\x00\x00\x00\x18\x00\x00\x00\xe4\xfd\xff\xff\x34\x00\x00\x00\x00\x41\x07\x1e\x10\x00\x00\x00\x2c\x00\x00\x00\x20\xfe\xff\xff\x30\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x40\x00\x00\x00\x3c\xfe\xff\xff\x3c\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x54\x00\x00\x00"), +Section(".comment", 0x0, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x10\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x38\x00\x09\x00\x40\x00\x1d\x00\x1c\x00\x06\x00\x00\x00\x04\x00\x00"), +Section(".interp", 0x238, "\x2f\x6c\x69\x62\x2f\x6c\x64\x2d\x6c\x69\x6e\x75\x78\x2d\x61\x61\x72\x63\x68\x36\x34\x2e\x73\x6f\x2e\x31\x00"), +Section(".note.gnu.build-id", 0x254, "\x04\x00\x00\x00\x14\x00\x00\x00\x03\x00\x00\x00\x47\x4e\x55\x00\x75\xee\xa3\x81\x5a\xcb\x3c\xbb\xd6\xda\x03\x86\xf7\x5e\x45\x89\x13\xf4\x8c\xfe"), +Section(".note.ABI-tag", 0x278, "\x04\x00\x00\x00\x10\x00\x00\x00\x01\x00\x00\x00\x47\x4e\x55\x00\x00\x00\x00\x00\x03\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00"), +Section(".gnu.hash", 0x298, "\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".dynsym", 0x2B8, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x0b\x00\x80\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x17\x00\x20\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x48\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x64\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x22\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x73\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".dynstr", 0x390, "\x00\x5f\x5f\x63\x78\x61\x5f\x66\x69\x6e\x61\x6c\x69\x7a\x65\x00\x5f\x5f\x6c\x69\x62\x63\x5f\x73\x74\x61\x72\x74\x5f\x6d\x61\x69\x6e\x00\x61\x62\x6f\x72\x74\x00\x6c\x69\x62\x63\x2e\x73\x6f\x2e\x36\x00\x47\x4c\x49\x42\x43\x5f\x32\x2e\x31\x37\x00\x47\x4c\x49\x42\x43\x5f\x32\x2e\x33\x34\x00\x5f\x49\x54\x4d\x5f\x64\x65\x72\x65\x67\x69\x73\x74\x65\x72\x54\x4d\x43\x6c\x6f\x6e\x65\x54\x61\x62\x6c\x65\x00\x5f\x5f\x67\x6d\x6f\x6e\x5f\x73\x74\x61\x72\x74\x5f\x5f\x00\x5f\x49\x54\x4d\x5f\x72\x65\x67\x69\x73\x74\x65\x72\x54\x4d\x43\x6c\x6f\x6e\x65\x54\x61\x62\x6c\x65\x00"), +Section(".gnu.version", 0x41E, "\x00\x00\x00\x00\x00\x00\x02\x00\x01\x00\x03\x00\x01\x00\x03\x00\x01\x00"), +Section(".gnu.version_r", 0x430, "\x01\x00\x02\x00\x28\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x97\x91\x96\x06\x00\x00\x03\x00\x32\x00\x00\x00\x10\x00\x00\x00\xb4\x91\x96\x06\x00\x00\x02\x00\x3d\x00\x00\x00\x00\x00\x00\x00"), +Section(".rela.dyn", 0x460, "\xc8\x0d\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x10\x07\x00\x00\x00\x00\x00\x00\xd0\x0d\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\xc0\x06\x00\x00\x00\x00\x00\x00\xd8\x0f\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x44\x07\x00\x00\x00\x00\x00\x00\x28\x10\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x28\x10\x01\x00\x00\x00\x00\x00\xc0\x0f\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc8\x0f\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd0\x0f\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x0f\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".rela.plt", 0x520, "\x00\x10\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x10\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x10\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x10\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".init", 0x580, "\x1f\x20\x03\xd5\xfd\x7b\xbf\xa9\xfd\x03\x00\x91\x2a\x00\x00\x94\xfd\x7b\xc1\xa8\xc0\x03\x5f\xd6"), +Section(".plt", 0x5A0, "\xf0\x7b\xbf\xa9\x90\x00\x00\x90\x11\xfe\x47\xf9\x10\xe2\x3f\x91\x20\x02\x1f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x90\x00\x00\xb0\x11\x02\x40\xf9\x10\x02\x00\x91\x20\x02\x1f\xd6\x90\x00\x00\xb0\x11\x06\x40\xf9\x10\x22\x00\x91\x20\x02\x1f\xd6\x90\x00\x00\xb0\x11\x0a\x40\xf9\x10\x42\x00\x91\x20\x02\x1f\xd6\x90\x00\x00\xb0\x11\x0e\x40\xf9\x10\x62\x00\x91\x20\x02\x1f\xd6"), +Section(".text", 0x600, "\x1f\x20\x03\xd5\x1d\x00\x80\xd2\x1e\x00\x80\xd2\xe5\x03\x00\xaa\xe1\x03\x40\xf9\xe2\x23\x00\x91\xe6\x03\x00\x91\x80\x00\x00\x90\x00\xec\x47\xf9\x03\x00\x80\xd2\x04\x00\x80\xd2\xe5\xff\xff\x97\xf0\xff\xff\x97\x80\x00\x00\x90\x00\xe8\x47\xf9\x40\x00\x00\xb4\xe8\xff\xff\x17\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x80\x00\x00\xb0\x00\xc0\x00\x91\x81\x00\x00\xb0\x21\xc0\x00\x91\x3f\x00\x00\xeb\xc0\x00\x00\x54\x81\x00\x00\x90\x21\xe0\x47\xf9\x61\x00\x00\xb4\xf0\x03\x01\xaa\x00\x02\x1f\xd6\xc0\x03\x5f\xd6\x80\x00\x00\xb0\x00\xc0\x00\x91\x81\x00\x00\xb0\x21\xc0\x00\x91\x21\x00\x00\xcb\x22\xfc\x7f\xd3\x41\x0c\x81\x8b\x21\xfc\x41\x93\xc1\x00\x00\xb4\x82\x00\x00\x90\x42\xf0\x47\xf9\x62\x00\x00\xb4\xf0\x03\x02\xaa\x00\x02\x1f\xd6\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\xfd\x7b\xbe\xa9\xfd\x03\x00\x91\xf3\x0b\x00\xf9\x93\x00\x00\xb0\x60\xc2\x40\x39\x40\x01\x00\x35\x80\x00\x00\x90\x00\xe4\x47\xf9\x80\x00\x00\xb4\x80\x00\x00\xb0\x00\x14\x40\xf9\xb9\xff\xff\x97\xd8\xff\xff\x97\x20\x00\x80\x52\x60\xc2\x00\x39\xf3\x0b\x40\xf9\xfd\x7b\xc2\xa8\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\xdc\xff\xff\x17\xff\x43\x00\xd1\xe8\x03\x00\x91\x7f\x0c\x00\x71\x09\xc9\x23\x8b\x08\x21\x00\x91\x28\xb1\x88\x9a\xe0\x07\x00\x29\xe2\x7f\x01\x29\x08\x01\x40\xb9\x00\x05\x00\x11\xff\x43\x00\x91\xc0\x03\x5f\xd6\xff\x43\x00\xd1\x09\x10\x00\x11\x0b\x08\x00\x0b\xc8\x00\x80\x52\xea\x03\x00\x91\x0d\x7c\x7e\x93\x08\x01\x00\x4b\x4c\x21\x00\x91\x1f\x0c\x00\x71\x4a\x01\x0d\x8b\xe9\x2f\x00\x29\x49\xb1\x8c\x9a\x4d\x0b\x80\x52\x4a\xb1\x8c\x9a\xe8\x7f\x01\x29\x29\x01\x40\xb9\xeb\x23\x00\x29\xed\x07\x00\xf9\x48\x01\x40\xb9\x28\x01\x08\x0b\x00\x09\x00\x11\xff\x43\x00\x91\xc0\x03\x5f\xd6"), +Section(".fini", 0x7A0, "\x1f\x20\x03\xd5\xfd\x7b\xbf\xa9\xfd\x03\x00\x91\xfd\x7b\xc1\xa8\xc0\x03\x5f\xd6"), +Section(".rodata", 0x7B4, "\x01\x00\x02\x00"), +Section(".eh_frame_hdr", 0x7B8, "\x01\x1b\x03\x3b\x44\x00\x00\x00\x07\x00\x00\x00\x48\xfe\xff\xff\x5c\x00\x00\x00\x98\xfe\xff\xff\x70\x00\x00\x00\xc8\xfe\xff\xff\x84\x00\x00\x00\x08\xff\xff\xff\x98\x00\x00\x00\x58\xff\xff\xff\xbc\x00\x00\x00\x5c\xff\xff\xff\xe4\x00\x00\x00\x8c\xff\xff\xff\xfc\x00\x00\x00"), +Section(".eh_frame", 0x800, "\x10\x00\x00\x00\x00\x00\x00\x00\x01\x7a\x52\x00\x04\x78\x1e\x01\x1b\x0c\x1f\x00\x10\x00\x00\x00\x18\x00\x00\x00\xe4\xfd\xff\xff\x34\x00\x00\x00\x00\x41\x07\x1e\x10\x00\x00\x00\x2c\x00\x00\x00\x20\xfe\xff\xff\x30\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x40\x00\x00\x00\x3c\xfe\xff\xff\x3c\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x54\x00\x00\x00\x68\xfe\xff\xff\x48\x00\x00\x00\x00\x41\x0e\x20\x9d\x04\x9e\x03\x42\x93\x02\x4e\xde\xdd\xd3\x0e\x00\x00\x00\x00\x10\x00\x00\x00\x78\x00\x00\x00\x94\xfe\xff\xff\x04\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x01\x7a\x52\x00\x01\x7c\x1e\x01\x1b\x0c\x1f\x00\x14\x00\x00\x00\x18\x00\x00\x00\x70\xfe\xff\xff\x30\x00\x00\x00\x00\x44\x0e\x10\x68\x0e\x00\x00\x14\x00\x00\x00\x30\x00\x00\x00\x88\xfe\xff\xff\x5c\x00\x00\x00\x00\x44\x0e\x10\x02\x54\x0e\x00\x00\x00\x00\x00"), +Section(".fini_array", 0x10DD0, "\xc0\x06\x00\x00\x00\x00\x00\x00"), +Section(".dynamic", 0x10DD8, "\x01\x00\x00\x00\x00\x00\x00\x00\x28\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x80\x05\x00\x00\x00\x00\x00\x00\x0d\x00\x00\x00\x00\x00\x00\x00\xa0\x07\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\xc8\x0d\x01\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00\x00\x00\x00\x00\xd0\x0d\x01\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\xf5\xfe\xff\x6f\x00\x00\x00\x00\x98\x02\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x90\x03\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\xb8\x02\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x8d\x00\x00\x00\x00\x00\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x15\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\xe8\x0f\x01\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x60\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x17\x00\x00\x00\x00\x00\x00\x00\x20\x05\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x60\x04\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\xc0\x00\x00\x00\x00\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\xfb\xff\xff\x6f\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\xfe\xff\xff\x6f\x00\x00\x00\x00\x30\x04\x00\x00\x00\x00\x00\x00\xff\xff\xff\x6f\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\xf0\xff\xff\x6f\x00\x00\x00\x00\x1e\x04\x00\x00\x00\x00\x00\x00\xf9\xff\xff\x6f\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".got", 0x10FB8, "\xd8\x0d\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x44\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".got.plt", 0x10FE8, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa0\x05\x00\x00\x00\x00\x00\x00\xa0\x05\x00\x00\x00\x00\x00\x00\xa0\x05\x00\x00\x00\x00\x00\x00\xa0\x05\x00\x00\x00\x00\x00\x00"), +Section(".data", 0x11020, "\x00\x00\x00\x00\x00\x00\x00\x00\x28\x10\x01\x00\x00\x00\x00\x00"), +Section(".init_array", 0x10DC8, "\x10\x07\x00\x00\x00\x00\x00\x00")]), +Memmap([Annotation(Region(0x0,0x8CF), Attr("segment","02 0 2256")), +Annotation(Region(0x600,0x633), Attr("symbol","\"_start\"")), +Annotation(Region(0x0,0x102), Attr("section","\".shstrtab\"")), +Annotation(Region(0x0,0x239), Attr("section","\".strtab\"")), +Annotation(Region(0x0,0x857), Attr("section","\".symtab\"")), +Annotation(Region(0x0,0x46), Attr("section","\".comment\"")), +Annotation(Region(0x238,0x252), Attr("section","\".interp\"")), +Annotation(Region(0x254,0x277), Attr("section","\".note.gnu.build-id\"")), +Annotation(Region(0x278,0x297), Attr("section","\".note.ABI-tag\"")), +Annotation(Region(0x298,0x2B3), Attr("section","\".gnu.hash\"")), +Annotation(Region(0x2B8,0x38F), Attr("section","\".dynsym\"")), +Annotation(Region(0x390,0x41C), Attr("section","\".dynstr\"")), +Annotation(Region(0x41E,0x42F), Attr("section","\".gnu.version\"")), +Annotation(Region(0x430,0x45F), Attr("section","\".gnu.version_r\"")), +Annotation(Region(0x460,0x51F), Attr("section","\".rela.dyn\"")), +Annotation(Region(0x520,0x57F), Attr("section","\".rela.plt\"")), +Annotation(Region(0x580,0x597), Attr("section","\".init\"")), +Annotation(Region(0x5A0,0x5FF), Attr("section","\".plt\"")), +Annotation(Region(0x580,0x597), Attr("code-region","()")), +Annotation(Region(0x5A0,0x5FF), Attr("code-region","()")), +Annotation(Region(0x600,0x633), Attr("symbol-info","_start 0x600 52")), +Annotation(Region(0x634,0x647), Attr("symbol","\"call_weak_fn\"")), +Annotation(Region(0x634,0x647), Attr("symbol-info","call_weak_fn 0x634 20")), +Annotation(Region(0x714,0x743), Attr("symbol","\"test\"")), +Annotation(Region(0x600,0x79F), Attr("section","\".text\"")), +Annotation(Region(0x600,0x79F), Attr("code-region","()")), +Annotation(Region(0x714,0x743), Attr("symbol-info","test 0x714 48")), +Annotation(Region(0x744,0x79F), Attr("symbol","\"main\"")), +Annotation(Region(0x744,0x79F), Attr("symbol-info","main 0x744 92")), +Annotation(Region(0x7A0,0x7B3), Attr("section","\".fini\"")), +Annotation(Region(0x7A0,0x7B3), Attr("code-region","()")), +Annotation(Region(0x7B4,0x7B7), Attr("section","\".rodata\"")), +Annotation(Region(0x7B8,0x7FB), Attr("section","\".eh_frame_hdr\"")), +Annotation(Region(0x800,0x8CF), Attr("section","\".eh_frame\"")), +Annotation(Region(0x10DC8,0x1102F), Attr("segment","03 0x10DC8 624")), +Annotation(Region(0x10DD0,0x10DD7), Attr("section","\".fini_array\"")), +Annotation(Region(0x10DD8,0x10FB7), Attr("section","\".dynamic\"")), +Annotation(Region(0x10FB8,0x10FE7), Attr("section","\".got\"")), +Annotation(Region(0x10FE8,0x1101F), Attr("section","\".got.plt\"")), +Annotation(Region(0x11020,0x1102F), Attr("section","\".data\"")), +Annotation(Region(0x10DC8,0x10DCF), Attr("section","\".init_array\""))]), +Program(Tid(1_876, "%00000754"), Attrs([]), + Subs([Sub(Tid(1_853, "@__cxa_finalize"), + Attrs([Attr("c.proto","signed (*)(void)"), Attr("address","0x5D0"), +Attr("stub","()")]), "__cxa_finalize", Args([Arg(Tid(1_877, "%00000755"), + Attrs([Attr("c.layout","[signed : 32]"), Attr("c.data","Top:u32"), +Attr("c.type","signed")]), Var("__cxa_finalize_result",Imm(32)), +LOW(32,Var("R0",Imm(64))), Out())]), Blks([Blk(Tid(1_211, "@__cxa_finalize"), + Attrs([Attr("address","0x5D0")]), Phis([]), +Defs([Def(Tid(1_459, "%000005b3"), Attrs([Attr("address","0x5D0"), +Attr("insn","adrp x16, #69632")]), Var("R16",Imm(64)), Int(69632,64)), +Def(Tid(1_466, "%000005ba"), Attrs([Attr("address","0x5D4"), +Attr("insn","ldr x17, [x16, #0x8]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R16",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(1_472, "%000005c0"), Attrs([Attr("address","0x5D8"), +Attr("insn","add x16, x16, #0x8")]), Var("R16",Imm(64)), +PLUS(Var("R16",Imm(64)),Int(8,64)))]), Jmps([Call(Tid(1_477, "%000005c5"), + Attrs([Attr("address","0x5DC"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), +Sub(Tid(1_854, "@__do_global_dtors_aux"), + Attrs([Attr("c.proto","signed (*)(void)"), Attr("address","0x6C0")]), + "__do_global_dtors_aux", Args([Arg(Tid(1_878, "%00000756"), + Attrs([Attr("c.layout","[signed : 32]"), Attr("c.data","Top:u32"), +Attr("c.type","signed")]), Var("__do_global_dtors_aux_result",Imm(32)), +LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(730, "@__do_global_dtors_aux"), + Attrs([Attr("address","0x6C0")]), Phis([]), Defs([Def(Tid(734, "%000002de"), + Attrs([Attr("address","0x6C0"), +Attr("insn","stp x29, x30, [sp, #-0x20]!")]), Var("#3",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(18446744073709551584,64))), +Def(Tid(740, "%000002e4"), Attrs([Attr("address","0x6C0"), +Attr("insn","stp x29, x30, [sp, #-0x20]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("#3",Imm(64)),Var("R29",Imm(64)),LittleEndian(),64)), +Def(Tid(746, "%000002ea"), Attrs([Attr("address","0x6C0"), +Attr("insn","stp x29, x30, [sp, #-0x20]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("#3",Imm(64)),Int(8,64)),Var("R30",Imm(64)),LittleEndian(),64)), +Def(Tid(750, "%000002ee"), Attrs([Attr("address","0x6C0"), +Attr("insn","stp x29, x30, [sp, #-0x20]!")]), Var("R31",Imm(64)), +Var("#3",Imm(64))), Def(Tid(756, "%000002f4"), + Attrs([Attr("address","0x6C4"), Attr("insn","mov x29, sp")]), + Var("R29",Imm(64)), Var("R31",Imm(64))), Def(Tid(764, "%000002fc"), + Attrs([Attr("address","0x6C8"), Attr("insn","str x19, [sp, #0x10]")]), + Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(16,64)),Var("R19",Imm(64)),LittleEndian(),64)), +Def(Tid(769, "%00000301"), Attrs([Attr("address","0x6CC"), +Attr("insn","adrp x19, #69632")]), Var("R19",Imm(64)), Int(69632,64)), +Def(Tid(776, "%00000308"), Attrs([Attr("address","0x6D0"), +Attr("insn","ldrb w0, [x19, #0x30]")]), Var("R0",Imm(64)), +UNSIGNED(64,Load(Var("mem",Mem(64,8)),PLUS(Var("R19",Imm(64)),Int(48,64)),LittleEndian(),8)))]), +Jmps([Goto(Tid(783, "%0000030f"), Attrs([Attr("address","0x6D4"), +Attr("insn","cbnz w0, #0x28")]), + NEQ(Extract(31,0,Var("R0",Imm(64))),Int(0,32)), +Direct(Tid(781, "%0000030d"))), Goto(Tid(1_855, "%0000073f"), Attrs([]), + Int(1,1), Direct(Tid(1_156, "%00000484")))])), Blk(Tid(1_156, "%00000484"), + Attrs([Attr("address","0x6D8")]), Phis([]), +Defs([Def(Tid(1_159, "%00000487"), Attrs([Attr("address","0x6D8"), +Attr("insn","adrp x0, #65536")]), Var("R0",Imm(64)), Int(65536,64)), +Def(Tid(1_166, "%0000048e"), Attrs([Attr("address","0x6DC"), +Attr("insn","ldr x0, [x0, #0xfc8]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R0",Imm(64)),Int(4040,64)),LittleEndian(),64))]), +Jmps([Goto(Tid(1_172, "%00000494"), Attrs([Attr("address","0x6E0"), +Attr("insn","cbz x0, #0x10")]), EQ(Var("R0",Imm(64)),Int(0,64)), +Direct(Tid(1_170, "%00000492"))), Goto(Tid(1_856, "%00000740"), Attrs([]), + Int(1,1), Direct(Tid(1_195, "%000004ab")))])), Blk(Tid(1_195, "%000004ab"), + Attrs([Attr("address","0x6E4")]), Phis([]), +Defs([Def(Tid(1_198, "%000004ae"), Attrs([Attr("address","0x6E4"), +Attr("insn","adrp x0, #69632")]), Var("R0",Imm(64)), Int(69632,64)), +Def(Tid(1_205, "%000004b5"), Attrs([Attr("address","0x6E8"), +Attr("insn","ldr x0, [x0, #0x28]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R0",Imm(64)),Int(40,64)),LittleEndian(),64)), +Def(Tid(1_210, "%000004ba"), Attrs([Attr("address","0x6EC"), +Attr("insn","bl #-0x11c")]), Var("R30",Imm(64)), Int(1776,64))]), +Jmps([Call(Tid(1_213, "%000004bd"), Attrs([Attr("address","0x6EC"), +Attr("insn","bl #-0x11c")]), Int(1,1), +(Direct(Tid(1_853, "@__cxa_finalize")),Direct(Tid(1_170, "%00000492"))))])), +Blk(Tid(1_170, "%00000492"), Attrs([Attr("address","0x6F0")]), Phis([]), +Defs([Def(Tid(1_178, "%0000049a"), Attrs([Attr("address","0x6F0"), +Attr("insn","bl #-0xa0")]), Var("R30",Imm(64)), Int(1780,64))]), +Jmps([Call(Tid(1_180, "%0000049c"), Attrs([Attr("address","0x6F0"), +Attr("insn","bl #-0xa0")]), Int(1,1), +(Direct(Tid(1_867, "@deregister_tm_clones")),Direct(Tid(1_182, "%0000049e"))))])), +Blk(Tid(1_182, "%0000049e"), Attrs([Attr("address","0x6F4")]), Phis([]), +Defs([Def(Tid(1_185, "%000004a1"), Attrs([Attr("address","0x6F4"), +Attr("insn","mov w0, #0x1")]), Var("R0",Imm(64)), Int(1,64)), +Def(Tid(1_193, "%000004a9"), Attrs([Attr("address","0x6F8"), +Attr("insn","strb w0, [x19, #0x30]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R19",Imm(64)),Int(48,64)),Extract(7,0,Var("R0",Imm(64))),LittleEndian(),8))]), +Jmps([Goto(Tid(1_857, "%00000741"), Attrs([]), Int(1,1), +Direct(Tid(781, "%0000030d")))])), Blk(Tid(781, "%0000030d"), + Attrs([Attr("address","0x6FC")]), Phis([]), Defs([Def(Tid(791, "%00000317"), + Attrs([Attr("address","0x6FC"), Attr("insn","ldr x19, [sp, #0x10]")]), + Var("R19",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(16,64)),LittleEndian(),64)), +Def(Tid(798, "%0000031e"), Attrs([Attr("address","0x700"), +Attr("insn","ldp x29, x30, [sp], #0x20")]), Var("R29",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(803, "%00000323"), Attrs([Attr("address","0x700"), +Attr("insn","ldp x29, x30, [sp], #0x20")]), Var("R30",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(807, "%00000327"), Attrs([Attr("address","0x700"), +Attr("insn","ldp x29, x30, [sp], #0x20")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(32,64)))]), Jmps([Call(Tid(812, "%0000032c"), + Attrs([Attr("address","0x704"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))])), Sub(Tid(1_858, "@__libc_start_main"), + Attrs([Attr("c.proto","signed (*)(signed (*)(signed , char** , char** );* main, signed , char** , \nvoid* auxv)"), +Attr("address","0x5C0"), Attr("stub","()")]), "__libc_start_main", + Args([Arg(Tid(1_879, "%00000757"), + Attrs([Attr("c.layout","**[ : 64]"), +Attr("c.data","Top:u64 ptr ptr"), +Attr("c.type","signed (*)(signed , char** , char** );*")]), + Var("__libc_start_main_main",Imm(64)), Var("R0",Imm(64)), In()), +Arg(Tid(1_880, "%00000758"), Attrs([Attr("c.layout","[signed : 32]"), +Attr("c.data","Top:u32"), Attr("c.type","signed")]), + Var("__libc_start_main_arg2",Imm(32)), LOW(32,Var("R1",Imm(64))), In()), +Arg(Tid(1_881, "%00000759"), Attrs([Attr("c.layout","**[char : 8]"), +Attr("c.data","Top:u8 ptr ptr"), Attr("c.type","char**")]), + Var("__libc_start_main_arg3",Imm(64)), Var("R2",Imm(64)), Both()), +Arg(Tid(1_882, "%0000075a"), Attrs([Attr("c.layout","*[ : 8]"), +Attr("c.data","{} ptr"), Attr("c.type","void*")]), + Var("__libc_start_main_auxv",Imm(64)), Var("R3",Imm(64)), Both()), +Arg(Tid(1_883, "%0000075b"), Attrs([Attr("c.layout","[signed : 32]"), +Attr("c.data","Top:u32"), Attr("c.type","signed")]), + Var("__libc_start_main_result",Imm(32)), LOW(32,Var("R0",Imm(64))), +Out())]), Blks([Blk(Tid(563, "@__libc_start_main"), + Attrs([Attr("address","0x5C0")]), Phis([]), +Defs([Def(Tid(1_437, "%0000059d"), Attrs([Attr("address","0x5C0"), +Attr("insn","adrp x16, #69632")]), Var("R16",Imm(64)), Int(69632,64)), +Def(Tid(1_444, "%000005a4"), Attrs([Attr("address","0x5C4"), +Attr("insn","ldr x17, [x16]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R16",Imm(64)),LittleEndian(),64)), +Def(Tid(1_450, "%000005aa"), Attrs([Attr("address","0x5C8"), +Attr("insn","add x16, x16, #0x0")]), Var("R16",Imm(64)), +Var("R16",Imm(64)))]), Jmps([Call(Tid(1_455, "%000005af"), + Attrs([Attr("address","0x5CC"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), Sub(Tid(1_859, "@_fini"), + Attrs([Attr("c.proto","signed (*)(void)"), Attr("address","0x7A0")]), + "_fini", Args([Arg(Tid(1_884, "%0000075c"), + Attrs([Attr("c.layout","[signed : 32]"), Attr("c.data","Top:u32"), +Attr("c.type","signed")]), Var("_fini_result",Imm(32)), +LOW(32,Var("R0",Imm(64))), Out())]), Blks([Blk(Tid(31, "@_fini"), + Attrs([Attr("address","0x7A0")]), Phis([]), Defs([Def(Tid(37, "%00000025"), + Attrs([Attr("address","0x7A4"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("#0",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(18446744073709551600,64))), +Def(Tid(43, "%0000002b"), Attrs([Attr("address","0x7A4"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("#0",Imm(64)),Var("R29",Imm(64)),LittleEndian(),64)), +Def(Tid(49, "%00000031"), Attrs([Attr("address","0x7A4"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("#0",Imm(64)),Int(8,64)),Var("R30",Imm(64)),LittleEndian(),64)), +Def(Tid(53, "%00000035"), Attrs([Attr("address","0x7A4"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("R31",Imm(64)), +Var("#0",Imm(64))), Def(Tid(59, "%0000003b"), Attrs([Attr("address","0x7A8"), +Attr("insn","mov x29, sp")]), Var("R29",Imm(64)), Var("R31",Imm(64))), +Def(Tid(66, "%00000042"), Attrs([Attr("address","0x7AC"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R29",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(71, "%00000047"), Attrs([Attr("address","0x7AC"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R30",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(75, "%0000004b"), Attrs([Attr("address","0x7AC"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(16,64)))]), Jmps([Call(Tid(80, "%00000050"), + Attrs([Attr("address","0x7B0"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))])), Sub(Tid(1_860, "@_init"), + Attrs([Attr("c.proto","signed (*)(void)"), Attr("address","0x580")]), + "_init", Args([Arg(Tid(1_885, "%0000075d"), + Attrs([Attr("c.layout","[signed : 32]"), Attr("c.data","Top:u32"), +Attr("c.type","signed")]), Var("_init_result",Imm(32)), +LOW(32,Var("R0",Imm(64))), Out())]), Blks([Blk(Tid(1_660, "@_init"), + Attrs([Attr("address","0x580")]), Phis([]), +Defs([Def(Tid(1_666, "%00000682"), Attrs([Attr("address","0x584"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("#9",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(18446744073709551600,64))), +Def(Tid(1_672, "%00000688"), Attrs([Attr("address","0x584"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("#9",Imm(64)),Var("R29",Imm(64)),LittleEndian(),64)), +Def(Tid(1_678, "%0000068e"), Attrs([Attr("address","0x584"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("#9",Imm(64)),Int(8,64)),Var("R30",Imm(64)),LittleEndian(),64)), +Def(Tid(1_682, "%00000692"), Attrs([Attr("address","0x584"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("R31",Imm(64)), +Var("#9",Imm(64))), Def(Tid(1_688, "%00000698"), + Attrs([Attr("address","0x588"), Attr("insn","mov x29, sp")]), + Var("R29",Imm(64)), Var("R31",Imm(64))), Def(Tid(1_693, "%0000069d"), + Attrs([Attr("address","0x58C"), Attr("insn","bl #0xa8")]), + Var("R30",Imm(64)), Int(1424,64))]), Jmps([Call(Tid(1_695, "%0000069f"), + Attrs([Attr("address","0x58C"), Attr("insn","bl #0xa8")]), Int(1,1), +(Direct(Tid(1_865, "@call_weak_fn")),Direct(Tid(1_697, "%000006a1"))))])), +Blk(Tid(1_697, "%000006a1"), Attrs([Attr("address","0x590")]), Phis([]), +Defs([Def(Tid(1_702, "%000006a6"), Attrs([Attr("address","0x590"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R29",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(1_707, "%000006ab"), Attrs([Attr("address","0x590"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R30",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(1_711, "%000006af"), Attrs([Attr("address","0x590"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(16,64)))]), Jmps([Call(Tid(1_716, "%000006b4"), + Attrs([Attr("address","0x594"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))])), Sub(Tid(1_861, "@_start"), + Attrs([Attr("c.proto","signed (*)(void)"), Attr("address","0x600"), +Attr("stub","()"), Attr("entry-point","()")]), "_start", + Args([Arg(Tid(1_886, "%0000075e"), Attrs([Attr("c.layout","[signed : 32]"), +Attr("c.data","Top:u32"), Attr("c.type","signed")]), + Var("_start_result",Imm(32)), LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(500, "@_start"), Attrs([Attr("address","0x600")]), Phis([]), +Defs([Def(Tid(505, "%000001f9"), Attrs([Attr("address","0x604"), +Attr("insn","mov x29, #0x0")]), Var("R29",Imm(64)), Int(0,64)), +Def(Tid(510, "%000001fe"), Attrs([Attr("address","0x608"), +Attr("insn","mov x30, #0x0")]), Var("R30",Imm(64)), Int(0,64)), +Def(Tid(516, "%00000204"), Attrs([Attr("address","0x60C"), +Attr("insn","mov x5, x0")]), Var("R5",Imm(64)), Var("R0",Imm(64))), +Def(Tid(523, "%0000020b"), Attrs([Attr("address","0x610"), +Attr("insn","ldr x1, [sp]")]), Var("R1",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(529, "%00000211"), Attrs([Attr("address","0x614"), +Attr("insn","add x2, sp, #0x8")]), Var("R2",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(8,64))), Def(Tid(535, "%00000217"), + Attrs([Attr("address","0x618"), Attr("insn","mov x6, sp")]), + Var("R6",Imm(64)), Var("R31",Imm(64))), Def(Tid(540, "%0000021c"), + Attrs([Attr("address","0x61C"), Attr("insn","adrp x0, #65536")]), + Var("R0",Imm(64)), Int(65536,64)), Def(Tid(547, "%00000223"), + Attrs([Attr("address","0x620"), Attr("insn","ldr x0, [x0, #0xfd8]")]), + Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R0",Imm(64)),Int(4056,64)),LittleEndian(),64)), +Def(Tid(552, "%00000228"), Attrs([Attr("address","0x624"), +Attr("insn","mov x3, #0x0")]), Var("R3",Imm(64)), Int(0,64)), +Def(Tid(557, "%0000022d"), Attrs([Attr("address","0x628"), +Attr("insn","mov x4, #0x0")]), Var("R4",Imm(64)), Int(0,64)), +Def(Tid(562, "%00000232"), Attrs([Attr("address","0x62C"), +Attr("insn","bl #-0x6c")]), Var("R30",Imm(64)), Int(1584,64))]), +Jmps([Call(Tid(565, "%00000235"), Attrs([Attr("address","0x62C"), +Attr("insn","bl #-0x6c")]), Int(1,1), +(Direct(Tid(1_858, "@__libc_start_main")),Direct(Tid(567, "%00000237"))))])), +Blk(Tid(567, "%00000237"), Attrs([Attr("address","0x630")]), Phis([]), +Defs([Def(Tid(570, "%0000023a"), Attrs([Attr("address","0x630"), +Attr("insn","bl #-0x40")]), Var("R30",Imm(64)), Int(1588,64))]), +Jmps([Call(Tid(573, "%0000023d"), Attrs([Attr("address","0x630"), +Attr("insn","bl #-0x40")]), Int(1,1), +(Direct(Tid(1_864, "@abort")),Direct(Tid(1_862, "%00000746"))))])), +Blk(Tid(1_862, "%00000746"), Attrs([]), Phis([]), Defs([]), +Jmps([Call(Tid(1_863, "%00000747"), Attrs([]), Int(1,1), +(Direct(Tid(1_865, "@call_weak_fn")),))]))])), Sub(Tid(1_864, "@abort"), + Attrs([Attr("noreturn","()"), Attr("c.proto","void (*)(void)"), +Attr("address","0x5F0"), Attr("stub","()")]), "abort", Args([]), +Blks([Blk(Tid(571, "@abort"), Attrs([Attr("address","0x5F0")]), Phis([]), +Defs([Def(Tid(1_503, "%000005df"), Attrs([Attr("address","0x5F0"), +Attr("insn","adrp x16, #69632")]), Var("R16",Imm(64)), Int(69632,64)), +Def(Tid(1_510, "%000005e6"), Attrs([Attr("address","0x5F4"), +Attr("insn","ldr x17, [x16, #0x18]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R16",Imm(64)),Int(24,64)),LittleEndian(),64)), +Def(Tid(1_516, "%000005ec"), Attrs([Attr("address","0x5F8"), +Attr("insn","add x16, x16, #0x18")]), Var("R16",Imm(64)), +PLUS(Var("R16",Imm(64)),Int(24,64)))]), Jmps([Call(Tid(1_521, "%000005f1"), + Attrs([Attr("address","0x5FC"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), Sub(Tid(1_865, "@call_weak_fn"), + Attrs([Attr("c.proto","signed (*)(void)"), Attr("address","0x634")]), + "call_weak_fn", Args([Arg(Tid(1_887, "%0000075f"), + Attrs([Attr("c.layout","[signed : 32]"), Attr("c.data","Top:u32"), +Attr("c.type","signed")]), Var("call_weak_fn_result",Imm(32)), +LOW(32,Var("R0",Imm(64))), Out())]), Blks([Blk(Tid(575, "@call_weak_fn"), + Attrs([Attr("address","0x634")]), Phis([]), Defs([Def(Tid(578, "%00000242"), + Attrs([Attr("address","0x634"), Attr("insn","adrp x0, #65536")]), + Var("R0",Imm(64)), Int(65536,64)), Def(Tid(585, "%00000249"), + Attrs([Attr("address","0x638"), Attr("insn","ldr x0, [x0, #0xfd0]")]), + Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R0",Imm(64)),Int(4048,64)),LittleEndian(),64))]), +Jmps([Goto(Tid(591, "%0000024f"), Attrs([Attr("address","0x63C"), +Attr("insn","cbz x0, #0x8")]), EQ(Var("R0",Imm(64)),Int(0,64)), +Direct(Tid(589, "%0000024d"))), Goto(Tid(1_866, "%0000074a"), Attrs([]), + Int(1,1), Direct(Tid(1_275, "%000004fb")))])), Blk(Tid(589, "%0000024d"), + Attrs([Attr("address","0x644")]), Phis([]), Defs([]), +Jmps([Call(Tid(597, "%00000255"), Attrs([Attr("address","0x644"), +Attr("insn","ret")]), Int(1,1), (Indirect(Var("R30",Imm(64))),))])), +Blk(Tid(1_275, "%000004fb"), Attrs([Attr("address","0x640")]), Phis([]), +Defs([]), Jmps([Goto(Tid(1_278, "%000004fe"), Attrs([Attr("address","0x640"), +Attr("insn","b #-0x60")]), Int(1,1), +Direct(Tid(1_276, "@__gmon_start__")))])), Blk(Tid(1_276, "@__gmon_start__"), + Attrs([Attr("address","0x5E0")]), Phis([]), +Defs([Def(Tid(1_481, "%000005c9"), Attrs([Attr("address","0x5E0"), +Attr("insn","adrp x16, #69632")]), Var("R16",Imm(64)), Int(69632,64)), +Def(Tid(1_488, "%000005d0"), Attrs([Attr("address","0x5E4"), +Attr("insn","ldr x17, [x16, #0x10]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R16",Imm(64)),Int(16,64)),LittleEndian(),64)), +Def(Tid(1_494, "%000005d6"), Attrs([Attr("address","0x5E8"), +Attr("insn","add x16, x16, #0x10")]), Var("R16",Imm(64)), +PLUS(Var("R16",Imm(64)),Int(16,64)))]), Jmps([Call(Tid(1_499, "%000005db"), + Attrs([Attr("address","0x5EC"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), +Sub(Tid(1_867, "@deregister_tm_clones"), + Attrs([Attr("c.proto","signed (*)(void)"), Attr("address","0x650")]), + "deregister_tm_clones", Args([Arg(Tid(1_888, "%00000760"), + Attrs([Attr("c.layout","[signed : 32]"), Attr("c.data","Top:u32"), +Attr("c.type","signed")]), Var("deregister_tm_clones_result",Imm(32)), +LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(603, "@deregister_tm_clones"), + Attrs([Attr("address","0x650")]), Phis([]), Defs([Def(Tid(606, "%0000025e"), + Attrs([Attr("address","0x650"), Attr("insn","adrp x0, #69632")]), + Var("R0",Imm(64)), Int(69632,64)), Def(Tid(612, "%00000264"), + Attrs([Attr("address","0x654"), Attr("insn","add x0, x0, #0x30")]), + Var("R0",Imm(64)), PLUS(Var("R0",Imm(64)),Int(48,64))), +Def(Tid(617, "%00000269"), Attrs([Attr("address","0x658"), +Attr("insn","adrp x1, #69632")]), Var("R1",Imm(64)), Int(69632,64)), +Def(Tid(623, "%0000026f"), Attrs([Attr("address","0x65C"), +Attr("insn","add x1, x1, #0x30")]), Var("R1",Imm(64)), +PLUS(Var("R1",Imm(64)),Int(48,64))), Def(Tid(629, "%00000275"), + Attrs([Attr("address","0x660"), Attr("insn","cmp x1, x0")]), + Var("#1",Imm(64)), NOT(Var("R0",Imm(64)))), Def(Tid(634, "%0000027a"), + Attrs([Attr("address","0x660"), Attr("insn","cmp x1, x0")]), + Var("#2",Imm(64)), PLUS(Var("R1",Imm(64)),NOT(Var("R0",Imm(64))))), +Def(Tid(640, "%00000280"), Attrs([Attr("address","0x660"), +Attr("insn","cmp x1, x0")]), Var("VF",Imm(1)), +NEQ(SIGNED(65,PLUS(Var("#2",Imm(64)),Int(1,64))),PLUS(PLUS(SIGNED(65,Var("R1",Imm(64))),SIGNED(65,Var("#1",Imm(64)))),Int(1,65)))), +Def(Tid(646, "%00000286"), Attrs([Attr("address","0x660"), +Attr("insn","cmp x1, x0")]), Var("CF",Imm(1)), +NEQ(UNSIGNED(65,PLUS(Var("#2",Imm(64)),Int(1,64))),PLUS(PLUS(UNSIGNED(65,Var("R1",Imm(64))),UNSIGNED(65,Var("#1",Imm(64)))),Int(1,65)))), +Def(Tid(650, "%0000028a"), Attrs([Attr("address","0x660"), +Attr("insn","cmp x1, x0")]), Var("ZF",Imm(1)), +EQ(PLUS(Var("#2",Imm(64)),Int(1,64)),Int(0,64))), Def(Tid(654, "%0000028e"), + Attrs([Attr("address","0x660"), Attr("insn","cmp x1, x0")]), + Var("NF",Imm(1)), Extract(63,63,PLUS(Var("#2",Imm(64)),Int(1,64))))]), +Jmps([Goto(Tid(660, "%00000294"), Attrs([Attr("address","0x664"), +Attr("insn","b.eq #0x18")]), EQ(Var("ZF",Imm(1)),Int(1,1)), +Direct(Tid(658, "%00000292"))), Goto(Tid(1_868, "%0000074c"), Attrs([]), + Int(1,1), Direct(Tid(1_245, "%000004dd")))])), Blk(Tid(1_245, "%000004dd"), + Attrs([Attr("address","0x668")]), Phis([]), +Defs([Def(Tid(1_248, "%000004e0"), Attrs([Attr("address","0x668"), +Attr("insn","adrp x1, #65536")]), Var("R1",Imm(64)), Int(65536,64)), +Def(Tid(1_255, "%000004e7"), Attrs([Attr("address","0x66C"), +Attr("insn","ldr x1, [x1, #0xfc0]")]), Var("R1",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R1",Imm(64)),Int(4032,64)),LittleEndian(),64))]), +Jmps([Goto(Tid(1_260, "%000004ec"), Attrs([Attr("address","0x670"), +Attr("insn","cbz x1, #0xc")]), EQ(Var("R1",Imm(64)),Int(0,64)), +Direct(Tid(658, "%00000292"))), Goto(Tid(1_869, "%0000074d"), Attrs([]), + Int(1,1), Direct(Tid(1_264, "%000004f0")))])), Blk(Tid(658, "%00000292"), + Attrs([Attr("address","0x67C")]), Phis([]), Defs([]), +Jmps([Call(Tid(666, "%0000029a"), Attrs([Attr("address","0x67C"), +Attr("insn","ret")]), Int(1,1), (Indirect(Var("R30",Imm(64))),))])), +Blk(Tid(1_264, "%000004f0"), Attrs([Attr("address","0x674")]), Phis([]), +Defs([Def(Tid(1_268, "%000004f4"), Attrs([Attr("address","0x674"), +Attr("insn","mov x16, x1")]), Var("R16",Imm(64)), Var("R1",Imm(64)))]), +Jmps([Call(Tid(1_273, "%000004f9"), Attrs([Attr("address","0x678"), +Attr("insn","br x16")]), Int(1,1), (Indirect(Var("R16",Imm(64))),))]))])), +Sub(Tid(1_870, "@frame_dummy"), Attrs([Attr("c.proto","signed (*)(void)"), +Attr("address","0x710")]), "frame_dummy", Args([Arg(Tid(1_889, "%00000761"), + Attrs([Attr("c.layout","[signed : 32]"), Attr("c.data","Top:u32"), +Attr("c.type","signed")]), Var("frame_dummy_result",Imm(32)), +LOW(32,Var("R0",Imm(64))), Out())]), Blks([Blk(Tid(818, "@frame_dummy"), + Attrs([Attr("address","0x710")]), Phis([]), Defs([]), +Jmps([Call(Tid(820, "%00000334"), Attrs([Attr("address","0x710"), +Attr("insn","b #-0x90")]), Int(1,1), +(Direct(Tid(1_872, "@register_tm_clones")),))]))])), Sub(Tid(1_871, "@main"), + Attrs([Attr("c.proto","signed (*)(signed argc, const char** argv)"), +Attr("address","0x744")]), "main", Args([Arg(Tid(1_890, "%00000762"), + Attrs([Attr("c.layout","[signed : 32]"), Attr("c.data","Top:u32"), +Attr("c.type","signed")]), Var("main_argc",Imm(32)), +LOW(32,Var("R0",Imm(64))), In()), Arg(Tid(1_891, "%00000763"), + Attrs([Attr("c.layout","**[char : 8]"), Attr("c.data","Top:u8 ptr ptr"), +Attr("c.type"," const char**")]), Var("main_argv",Imm(64)), +Var("R1",Imm(64)), Both()), Arg(Tid(1_892, "%00000764"), + Attrs([Attr("c.layout","[signed : 32]"), Attr("c.data","Top:u32"), +Attr("c.type","signed")]), Var("main_result",Imm(32)), +LOW(32,Var("R0",Imm(64))), Out())]), Blks([Blk(Tid(944, "@main"), + Attrs([Attr("address","0x744")]), Phis([]), Defs([Def(Tid(948, "%000003b4"), + Attrs([Attr("address","0x744"), Attr("insn","sub sp, sp, #0x10")]), + Var("R31",Imm(64)), PLUS(Var("R31",Imm(64)),Int(18446744073709551600,64))), +Def(Tid(954, "%000003ba"), Attrs([Attr("address","0x748"), +Attr("insn","add w9, w0, #0x4")]), Var("R9",Imm(64)), +UNSIGNED(64,PLUS(Extract(31,0,Var("R0",Imm(64))),Int(4,32)))), +Def(Tid(961, "%000003c1"), Attrs([Attr("address","0x74C"), +Attr("insn","add w11, w0, w0, lsl #2")]), Var("R11",Imm(64)), +UNSIGNED(64,PLUS(Extract(31,0,Var("R0",Imm(64))),Concat(Extract(29,0,Var("R0",Imm(64))),Int(0,2))))), +Def(Tid(966, "%000003c6"), Attrs([Attr("address","0x750"), +Attr("insn","mov w8, #0x6")]), Var("R8",Imm(64)), Int(6,64)), +Def(Tid(972, "%000003cc"), Attrs([Attr("address","0x754"), +Attr("insn","mov x10, sp")]), Var("R10",Imm(64)), Var("R31",Imm(64))), +Def(Tid(978, "%000003d2"), Attrs([Attr("address","0x758"), +Attr("insn","sbfiz x13, x0, #2, #32")]), Var("R13",Imm(64)), +SIGNED(64,Concat(Extract(31,0,Var("R0",Imm(64))),Int(0,2)))), +Def(Tid(985, "%000003d9"), Attrs([Attr("address","0x75C"), +Attr("insn","sub w8, w8, w0")]), Var("R8",Imm(64)), +UNSIGNED(64,PLUS(PLUS(Extract(31,0,Var("R8",Imm(64))),NOT(Extract(31,0,Var("R0",Imm(64))))),Int(1,32)))), +Def(Tid(991, "%000003df"), Attrs([Attr("address","0x760"), +Attr("insn","add x12, x10, #0x8")]), Var("R12",Imm(64)), +PLUS(Var("R10",Imm(64)),Int(8,64))), Def(Tid(997, "%000003e5"), + Attrs([Attr("address","0x764"), Attr("insn","cmp w0, #0x3")]), + Var("#6",Imm(32)), +PLUS(Extract(31,0,Var("R0",Imm(64))),Int(4294967292,32))), +Def(Tid(1_002, "%000003ea"), Attrs([Attr("address","0x764"), +Attr("insn","cmp w0, #0x3")]), Var("VF",Imm(1)), +NEQ(SIGNED(33,PLUS(Var("#6",Imm(32)),Int(1,32))),PLUS(SIGNED(33,Extract(31,0,Var("R0",Imm(64)))),Int(8589934589,33)))), +Def(Tid(1_007, "%000003ef"), Attrs([Attr("address","0x764"), +Attr("insn","cmp w0, #0x3")]), Var("CF",Imm(1)), +NEQ(UNSIGNED(33,PLUS(Var("#6",Imm(32)),Int(1,32))),PLUS(UNSIGNED(33,Extract(31,0,Var("R0",Imm(64)))),Int(4294967293,33)))), +Def(Tid(1_011, "%000003f3"), Attrs([Attr("address","0x764"), +Attr("insn","cmp w0, #0x3")]), Var("ZF",Imm(1)), +EQ(PLUS(Var("#6",Imm(32)),Int(1,32)),Int(0,32))), +Def(Tid(1_015, "%000003f7"), Attrs([Attr("address","0x764"), +Attr("insn","cmp w0, #0x3")]), Var("NF",Imm(1)), +Extract(31,31,PLUS(Var("#6",Imm(32)),Int(1,32)))), +Def(Tid(1_022, "%000003fe"), Attrs([Attr("address","0x768"), +Attr("insn","add x10, x10, x13")]), Var("R10",Imm(64)), +PLUS(Var("R10",Imm(64)),Var("R13",Imm(64)))), Def(Tid(1_030, "%00000406"), + Attrs([Attr("address","0x76C"), Attr("insn","stp w9, w11, [sp]")]), + Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("R31",Imm(64)),Extract(31,0,Var("R9",Imm(64))),LittleEndian(),32)), +Def(Tid(1_036, "%0000040c"), Attrs([Attr("address","0x76C"), +Attr("insn","stp w9, w11, [sp]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(4,64)),Extract(31,0,Var("R11",Imm(64))),LittleEndian(),32))]), +Jmps([Goto(Tid(1_051, "%0000041b"), Attrs([Attr("address","0x770"), +Attr("insn","csel x9, x10, x12, lt")]), + NEQ(Var("NF",Imm(1)),Var("VF",Imm(1))), Direct(Tid(1_043, "%00000413"))), +Goto(Tid(1_052, "%0000041c"), Attrs([Attr("address","0x770"), +Attr("insn","csel x9, x10, x12, lt")]), Int(1,1), +Direct(Tid(1_047, "%00000417")))])), Blk(Tid(1_047, "%00000417"), Attrs([]), + Phis([]), Defs([Def(Tid(1_048, "%00000418"), Attrs([Attr("address","0x770"), +Attr("insn","csel x9, x10, x12, lt")]), Var("R9",Imm(64)), +Var("R12",Imm(64)))]), Jmps([Goto(Tid(1_054, "%0000041e"), + Attrs([Attr("address","0x770"), Attr("insn","csel x9, x10, x12, lt")]), + Int(1,1), Direct(Tid(1_050, "%0000041a")))])), Blk(Tid(1_043, "%00000413"), + Attrs([]), Phis([]), Defs([Def(Tid(1_044, "%00000414"), + Attrs([Attr("address","0x770"), Attr("insn","csel x9, x10, x12, lt")]), + Var("R9",Imm(64)), Var("R10",Imm(64)))]), +Jmps([Goto(Tid(1_053, "%0000041d"), Attrs([Attr("address","0x770"), +Attr("insn","csel x9, x10, x12, lt")]), Int(1,1), +Direct(Tid(1_050, "%0000041a")))])), Blk(Tid(1_050, "%0000041a"), Attrs([]), + Phis([]), Defs([Def(Tid(1_059, "%00000423"), Attrs([Attr("address","0x774"), +Attr("insn","mov w13, #0x5a")]), Var("R13",Imm(64)), Int(90,64))]), +Jmps([Goto(Tid(1_074, "%00000432"), Attrs([Attr("address","0x778"), +Attr("insn","csel x10, x10, x12, lt")]), + NEQ(Var("NF",Imm(1)),Var("VF",Imm(1))), Direct(Tid(1_066, "%0000042a"))), +Goto(Tid(1_075, "%00000433"), Attrs([Attr("address","0x778"), +Attr("insn","csel x10, x10, x12, lt")]), Int(1,1), +Direct(Tid(1_070, "%0000042e")))])), Blk(Tid(1_070, "%0000042e"), Attrs([]), + Phis([]), Defs([Def(Tid(1_071, "%0000042f"), Attrs([Attr("address","0x778"), +Attr("insn","csel x10, x10, x12, lt")]), Var("R10",Imm(64)), +Var("R12",Imm(64)))]), Jmps([Goto(Tid(1_077, "%00000435"), + Attrs([Attr("address","0x778"), Attr("insn","csel x10, x10, x12, lt")]), + Int(1,1), Direct(Tid(1_073, "%00000431")))])), Blk(Tid(1_066, "%0000042a"), + Attrs([]), Phis([]), Defs([Def(Tid(1_067, "%0000042b"), + Attrs([Attr("address","0x778"), Attr("insn","csel x10, x10, x12, lt")]), + Var("R10",Imm(64)), Var("R10",Imm(64)))]), +Jmps([Goto(Tid(1_076, "%00000434"), Attrs([Attr("address","0x778"), +Attr("insn","csel x10, x10, x12, lt")]), Int(1,1), +Direct(Tid(1_073, "%00000431")))])), Blk(Tid(1_073, "%00000431"), Attrs([]), + Phis([]), Defs([Def(Tid(1_083, "%0000043b"), Attrs([Attr("address","0x77C"), +Attr("insn","stp w8, wzr, [sp, #0x8]")]), Var("#7",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(8,64))), Def(Tid(1_089, "%00000441"), + Attrs([Attr("address","0x77C"), Attr("insn","stp w8, wzr, [sp, #0x8]")]), + Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("#7",Imm(64)),Extract(31,0,Var("R8",Imm(64))),LittleEndian(),32)), +Def(Tid(1_094, "%00000446"), Attrs([Attr("address","0x77C"), +Attr("insn","stp w8, wzr, [sp, #0x8]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("#7",Imm(64)),Int(4,64)),Int(0,32),LittleEndian(),32)), +Def(Tid(1_101, "%0000044d"), Attrs([Attr("address","0x780"), +Attr("insn","ldr w9, [x9]")]), Var("R9",Imm(64)), +UNSIGNED(64,Load(Var("mem",Mem(64,8)),Var("R9",Imm(64)),LittleEndian(),32))), +Def(Tid(1_109, "%00000455"), Attrs([Attr("address","0x784"), +Attr("insn","stp w11, w8, [sp]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("R31",Imm(64)),Extract(31,0,Var("R11",Imm(64))),LittleEndian(),32)), +Def(Tid(1_115, "%0000045b"), Attrs([Attr("address","0x784"), +Attr("insn","stp w11, w8, [sp]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(4,64)),Extract(31,0,Var("R8",Imm(64))),LittleEndian(),32)), +Def(Tid(1_123, "%00000463"), Attrs([Attr("address","0x788"), +Attr("insn","str x13, [sp, #0x8]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),Var("R13",Imm(64)),LittleEndian(),64)), +Def(Tid(1_130, "%0000046a"), Attrs([Attr("address","0x78C"), +Attr("insn","ldr w8, [x10]")]), Var("R8",Imm(64)), +UNSIGNED(64,Load(Var("mem",Mem(64,8)),Var("R10",Imm(64)),LittleEndian(),32))), +Def(Tid(1_137, "%00000471"), Attrs([Attr("address","0x790"), +Attr("insn","add w8, w9, w8")]), Var("R8",Imm(64)), +UNSIGNED(64,PLUS(Extract(31,0,Var("R9",Imm(64))),Extract(31,0,Var("R8",Imm(64)))))), +Def(Tid(1_143, "%00000477"), Attrs([Attr("address","0x794"), +Attr("insn","add w0, w8, #0x2")]), Var("R0",Imm(64)), +UNSIGNED(64,PLUS(Extract(31,0,Var("R8",Imm(64))),Int(2,32)))), +Def(Tid(1_149, "%0000047d"), Attrs([Attr("address","0x798"), +Attr("insn","add sp, sp, #0x10")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(16,64)))]), Jmps([Call(Tid(1_154, "%00000482"), + Attrs([Attr("address","0x79C"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))])), +Sub(Tid(1_872, "@register_tm_clones"), + Attrs([Attr("c.proto","signed (*)(void)"), Attr("address","0x680")]), + "register_tm_clones", Args([Arg(Tid(1_893, "%00000765"), + Attrs([Attr("c.layout","[signed : 32]"), Attr("c.data","Top:u32"), +Attr("c.type","signed")]), Var("register_tm_clones_result",Imm(32)), +LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(668, "@register_tm_clones"), Attrs([Attr("address","0x680")]), + Phis([]), Defs([Def(Tid(671, "%0000029f"), Attrs([Attr("address","0x680"), +Attr("insn","adrp x0, #69632")]), Var("R0",Imm(64)), Int(69632,64)), +Def(Tid(677, "%000002a5"), Attrs([Attr("address","0x684"), +Attr("insn","add x0, x0, #0x30")]), Var("R0",Imm(64)), +PLUS(Var("R0",Imm(64)),Int(48,64))), Def(Tid(682, "%000002aa"), + Attrs([Attr("address","0x688"), Attr("insn","adrp x1, #69632")]), + Var("R1",Imm(64)), Int(69632,64)), Def(Tid(688, "%000002b0"), + Attrs([Attr("address","0x68C"), Attr("insn","add x1, x1, #0x30")]), + Var("R1",Imm(64)), PLUS(Var("R1",Imm(64)),Int(48,64))), +Def(Tid(695, "%000002b7"), Attrs([Attr("address","0x690"), +Attr("insn","sub x1, x1, x0")]), Var("R1",Imm(64)), +PLUS(PLUS(Var("R1",Imm(64)),NOT(Var("R0",Imm(64)))),Int(1,64))), +Def(Tid(701, "%000002bd"), Attrs([Attr("address","0x694"), +Attr("insn","lsr x2, x1, #63")]), Var("R2",Imm(64)), +Concat(Int(0,63),Extract(63,63,Var("R1",Imm(64))))), +Def(Tid(708, "%000002c4"), Attrs([Attr("address","0x698"), +Attr("insn","add x1, x2, x1, asr #3")]), Var("R1",Imm(64)), +PLUS(Var("R2",Imm(64)),ARSHIFT(Var("R1",Imm(64)),Int(3,3)))), +Def(Tid(714, "%000002ca"), Attrs([Attr("address","0x69C"), +Attr("insn","asr x1, x1, #1")]), Var("R1",Imm(64)), +SIGNED(64,Extract(63,1,Var("R1",Imm(64)))))]), +Jmps([Goto(Tid(720, "%000002d0"), Attrs([Attr("address","0x6A0"), +Attr("insn","cbz x1, #0x18")]), EQ(Var("R1",Imm(64)),Int(0,64)), +Direct(Tid(718, "%000002ce"))), Goto(Tid(1_873, "%00000751"), Attrs([]), + Int(1,1), Direct(Tid(1_215, "%000004bf")))])), Blk(Tid(1_215, "%000004bf"), + Attrs([Attr("address","0x6A4")]), Phis([]), +Defs([Def(Tid(1_218, "%000004c2"), Attrs([Attr("address","0x6A4"), +Attr("insn","adrp x2, #65536")]), Var("R2",Imm(64)), Int(65536,64)), +Def(Tid(1_225, "%000004c9"), Attrs([Attr("address","0x6A8"), +Attr("insn","ldr x2, [x2, #0xfe0]")]), Var("R2",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R2",Imm(64)),Int(4064,64)),LittleEndian(),64))]), +Jmps([Goto(Tid(1_230, "%000004ce"), Attrs([Attr("address","0x6AC"), +Attr("insn","cbz x2, #0xc")]), EQ(Var("R2",Imm(64)),Int(0,64)), +Direct(Tid(718, "%000002ce"))), Goto(Tid(1_874, "%00000752"), Attrs([]), + Int(1,1), Direct(Tid(1_234, "%000004d2")))])), Blk(Tid(718, "%000002ce"), + Attrs([Attr("address","0x6B8")]), Phis([]), Defs([]), +Jmps([Call(Tid(726, "%000002d6"), Attrs([Attr("address","0x6B8"), +Attr("insn","ret")]), Int(1,1), (Indirect(Var("R30",Imm(64))),))])), +Blk(Tid(1_234, "%000004d2"), Attrs([Attr("address","0x6B0")]), Phis([]), +Defs([Def(Tid(1_238, "%000004d6"), Attrs([Attr("address","0x6B0"), +Attr("insn","mov x16, x2")]), Var("R16",Imm(64)), Var("R2",Imm(64)))]), +Jmps([Call(Tid(1_243, "%000004db"), Attrs([Attr("address","0x6B4"), +Attr("insn","br x16")]), Int(1,1), (Indirect(Var("R16",Imm(64))),))]))])), +Sub(Tid(1_875, "@test"), Attrs([Attr("c.proto","signed (*)(void)"), +Attr("address","0x714")]), "test", Args([Arg(Tid(1_894, "%00000766"), + Attrs([Attr("c.layout","[signed : 32]"), Attr("c.data","Top:u32"), +Attr("c.type","signed")]), Var("test_result",Imm(32)), +LOW(32,Var("R0",Imm(64))), Out())]), Blks([Blk(Tid(822, "@test"), + Attrs([Attr("address","0x714")]), Phis([]), Defs([Def(Tid(826, "%0000033a"), + Attrs([Attr("address","0x714"), Attr("insn","sub sp, sp, #0x10")]), + Var("R31",Imm(64)), PLUS(Var("R31",Imm(64)),Int(18446744073709551600,64))), +Def(Tid(832, "%00000340"), Attrs([Attr("address","0x718"), +Attr("insn","mov x8, sp")]), Var("R8",Imm(64)), Var("R31",Imm(64))), +Def(Tid(838, "%00000346"), Attrs([Attr("address","0x71C"), +Attr("insn","cmp w3, #0x3")]), Var("#4",Imm(32)), +PLUS(Extract(31,0,Var("R3",Imm(64))),Int(4294967292,32))), +Def(Tid(843, "%0000034b"), Attrs([Attr("address","0x71C"), +Attr("insn","cmp w3, #0x3")]), Var("VF",Imm(1)), +NEQ(SIGNED(33,PLUS(Var("#4",Imm(32)),Int(1,32))),PLUS(SIGNED(33,Extract(31,0,Var("R3",Imm(64)))),Int(8589934589,33)))), +Def(Tid(848, "%00000350"), Attrs([Attr("address","0x71C"), +Attr("insn","cmp w3, #0x3")]), Var("CF",Imm(1)), +NEQ(UNSIGNED(33,PLUS(Var("#4",Imm(32)),Int(1,32))),PLUS(UNSIGNED(33,Extract(31,0,Var("R3",Imm(64)))),Int(4294967293,33)))), +Def(Tid(852, "%00000354"), Attrs([Attr("address","0x71C"), +Attr("insn","cmp w3, #0x3")]), Var("ZF",Imm(1)), +EQ(PLUS(Var("#4",Imm(32)),Int(1,32)),Int(0,32))), Def(Tid(856, "%00000358"), + Attrs([Attr("address","0x71C"), Attr("insn","cmp w3, #0x3")]), + Var("NF",Imm(1)), Extract(31,31,PLUS(Var("#4",Imm(32)),Int(1,32)))), +Def(Tid(863, "%0000035f"), Attrs([Attr("address","0x720"), +Attr("insn","add x9, x8, w3, sxtw #2")]), Var("R9",Imm(64)), +PLUS(Var("R8",Imm(64)),SIGNED(64,Concat(Extract(31,0,Var("R3",Imm(64))),Int(0,2))))), +Def(Tid(869, "%00000365"), Attrs([Attr("address","0x724"), +Attr("insn","add x8, x8, #0x8")]), Var("R8",Imm(64)), +PLUS(Var("R8",Imm(64)),Int(8,64)))]), Jmps([Goto(Tid(884, "%00000374"), + Attrs([Attr("address","0x728"), Attr("insn","csel x8, x9, x8, lt")]), + NEQ(Var("NF",Imm(1)),Var("VF",Imm(1))), Direct(Tid(876, "%0000036c"))), +Goto(Tid(885, "%00000375"), Attrs([Attr("address","0x728"), +Attr("insn","csel x8, x9, x8, lt")]), Int(1,1), +Direct(Tid(880, "%00000370")))])), Blk(Tid(880, "%00000370"), Attrs([]), + Phis([]), Defs([Def(Tid(881, "%00000371"), Attrs([Attr("address","0x728"), +Attr("insn","csel x8, x9, x8, lt")]), Var("R8",Imm(64)), +Var("R8",Imm(64)))]), Jmps([Goto(Tid(887, "%00000377"), + Attrs([Attr("address","0x728"), Attr("insn","csel x8, x9, x8, lt")]), + Int(1,1), Direct(Tid(883, "%00000373")))])), Blk(Tid(876, "%0000036c"), + Attrs([]), Phis([]), Defs([Def(Tid(877, "%0000036d"), + Attrs([Attr("address","0x728"), Attr("insn","csel x8, x9, x8, lt")]), + Var("R8",Imm(64)), Var("R9",Imm(64)))]), Jmps([Goto(Tid(886, "%00000376"), + Attrs([Attr("address","0x728"), Attr("insn","csel x8, x9, x8, lt")]), + Int(1,1), Direct(Tid(883, "%00000373")))])), Blk(Tid(883, "%00000373"), + Attrs([]), Phis([]), Defs([Def(Tid(895, "%0000037f"), + Attrs([Attr("address","0x72C"), Attr("insn","stp w0, w1, [sp]")]), + Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("R31",Imm(64)),Extract(31,0,Var("R0",Imm(64))),LittleEndian(),32)), +Def(Tid(901, "%00000385"), Attrs([Attr("address","0x72C"), +Attr("insn","stp w0, w1, [sp]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(4,64)),Extract(31,0,Var("R1",Imm(64))),LittleEndian(),32)), +Def(Tid(907, "%0000038b"), Attrs([Attr("address","0x730"), +Attr("insn","stp w2, wzr, [sp, #0x8]")]), Var("#5",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(8,64))), Def(Tid(913, "%00000391"), + Attrs([Attr("address","0x730"), Attr("insn","stp w2, wzr, [sp, #0x8]")]), + Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("#5",Imm(64)),Extract(31,0,Var("R2",Imm(64))),LittleEndian(),32)), +Def(Tid(918, "%00000396"), Attrs([Attr("address","0x730"), +Attr("insn","stp w2, wzr, [sp, #0x8]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("#5",Imm(64)),Int(4,64)),Int(0,32),LittleEndian(),32)), +Def(Tid(925, "%0000039d"), Attrs([Attr("address","0x734"), +Attr("insn","ldr w8, [x8]")]), Var("R8",Imm(64)), +UNSIGNED(64,Load(Var("mem",Mem(64,8)),Var("R8",Imm(64)),LittleEndian(),32))), +Def(Tid(931, "%000003a3"), Attrs([Attr("address","0x738"), +Attr("insn","add w0, w8, #0x1")]), Var("R0",Imm(64)), +UNSIGNED(64,PLUS(Extract(31,0,Var("R8",Imm(64))),Int(1,32)))), +Def(Tid(937, "%000003a9"), Attrs([Attr("address","0x73C"), +Attr("insn","add sp, sp, #0x10")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(16,64)))]), Jmps([Call(Tid(942, "%000003ae"), + Attrs([Attr("address","0x740"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))]))]))) \ No newline at end of file diff --git a/examples/stackambiguity/stackambiguity.bir b/examples/stackambiguity/stackambiguity.bir new file mode 100644 index 000000000..98ceb4590 --- /dev/null +++ b/examples/stackambiguity/stackambiguity.bir @@ -0,0 +1,310 @@ +00000754: program +0000073d: sub __cxa_finalize(__cxa_finalize_result) +00000755: __cxa_finalize_result :: out u32 = low:32[R0] + +000004bb: +000005b3: R16 := 0x11000 +000005ba: R17 := mem[R16 + 8, el]:u64 +000005c0: R16 := R16 + 8 +000005c5: call R17 with noreturn + +0000073e: sub __do_global_dtors_aux(__do_global_dtors_aux_result) +00000756: __do_global_dtors_aux_result :: out u32 = low:32[R0] + +000002da: +000002de: #3 := R31 - 0x20 +000002e4: mem := mem with [#3, el]:u64 <- R29 +000002ea: mem := mem with [#3 + 8, el]:u64 <- R30 +000002ee: R31 := #3 +000002f4: R29 := R31 +000002fc: mem := mem with [R31 + 0x10, el]:u64 <- R19 +00000301: R19 := 0x11000 +00000308: R0 := pad:64[mem[R19 + 0x30]] +0000030f: when 31:0[R0] <> 0 goto %0000030d +0000073f: goto %00000484 + +00000484: +00000487: R0 := 0x10000 +0000048e: R0 := mem[R0 + 0xFC8, el]:u64 +00000494: when R0 = 0 goto %00000492 +00000740: goto %000004ab + +000004ab: +000004ae: R0 := 0x11000 +000004b5: R0 := mem[R0 + 0x28, el]:u64 +000004ba: R30 := 0x6F0 +000004bd: call @__cxa_finalize with return %00000492 + +00000492: +0000049a: R30 := 0x6F4 +0000049c: call @deregister_tm_clones with return %0000049e + +0000049e: +000004a1: R0 := 1 +000004a9: mem := mem with [R19 + 0x30] <- 7:0[R0] +00000741: goto %0000030d + +0000030d: +00000317: R19 := mem[R31 + 0x10, el]:u64 +0000031e: R29 := mem[R31, el]:u64 +00000323: R30 := mem[R31 + 8, el]:u64 +00000327: R31 := R31 + 0x20 +0000032c: call R30 with noreturn + +00000742: sub __libc_start_main(__libc_start_main_main, __libc_start_main_arg2, __libc_start_main_arg3, __libc_start_main_auxv, __libc_start_main_result) +00000757: __libc_start_main_main :: in u64 = R0 +00000758: __libc_start_main_arg2 :: in u32 = low:32[R1] +00000759: __libc_start_main_arg3 :: in out u64 = R2 +0000075a: __libc_start_main_auxv :: in out u64 = R3 +0000075b: __libc_start_main_result :: out u32 = low:32[R0] + +00000233: +0000059d: R16 := 0x11000 +000005a4: R17 := mem[R16, el]:u64 +000005aa: R16 := R16 +000005af: call R17 with noreturn + +00000743: sub _fini(_fini_result) +0000075c: _fini_result :: out u32 = low:32[R0] + +0000001f: +00000025: #0 := R31 - 0x10 +0000002b: mem := mem with [#0, el]:u64 <- R29 +00000031: mem := mem with [#0 + 8, el]:u64 <- R30 +00000035: R31 := #0 +0000003b: R29 := R31 +00000042: R29 := mem[R31, el]:u64 +00000047: R30 := mem[R31 + 8, el]:u64 +0000004b: R31 := R31 + 0x10 +00000050: call R30 with noreturn + +00000744: sub _init(_init_result) +0000075d: _init_result :: out u32 = low:32[R0] + +0000067c: +00000682: #9 := R31 - 0x10 +00000688: mem := mem with [#9, el]:u64 <- R29 +0000068e: mem := mem with [#9 + 8, el]:u64 <- R30 +00000692: R31 := #9 +00000698: R29 := R31 +0000069d: R30 := 0x590 +0000069f: call @call_weak_fn with return %000006a1 + +000006a1: +000006a6: R29 := mem[R31, el]:u64 +000006ab: R30 := mem[R31 + 8, el]:u64 +000006af: R31 := R31 + 0x10 +000006b4: call R30 with noreturn + +00000745: sub _start(_start_result) +0000075e: _start_result :: out u32 = low:32[R0] + +000001f4: +000001f9: R29 := 0 +000001fe: R30 := 0 +00000204: R5 := R0 +0000020b: R1 := mem[R31, el]:u64 +00000211: R2 := R31 + 8 +00000217: R6 := R31 +0000021c: R0 := 0x10000 +00000223: R0 := mem[R0 + 0xFD8, el]:u64 +00000228: R3 := 0 +0000022d: R4 := 0 +00000232: R30 := 0x630 +00000235: call @__libc_start_main with return %00000237 + +00000237: +0000023a: R30 := 0x634 +0000023d: call @abort with return %00000746 + +00000746: +00000747: call @call_weak_fn with noreturn + +00000748: sub abort() + + +0000023b: +000005df: R16 := 0x11000 +000005e6: R17 := mem[R16 + 0x18, el]:u64 +000005ec: R16 := R16 + 0x18 +000005f1: call R17 with noreturn + +00000749: sub call_weak_fn(call_weak_fn_result) +0000075f: call_weak_fn_result :: out u32 = low:32[R0] + +0000023f: +00000242: R0 := 0x10000 +00000249: R0 := mem[R0 + 0xFD0, el]:u64 +0000024f: when R0 = 0 goto %0000024d +0000074a: goto %000004fb + +0000024d: +00000255: call R30 with noreturn + +000004fb: +000004fe: goto @__gmon_start__ + +000004fc: +000005c9: R16 := 0x11000 +000005d0: R17 := mem[R16 + 0x10, el]:u64 +000005d6: R16 := R16 + 0x10 +000005db: call R17 with noreturn + +0000074b: sub deregister_tm_clones(deregister_tm_clones_result) +00000760: deregister_tm_clones_result :: out u32 = low:32[R0] + +0000025b: +0000025e: R0 := 0x11000 +00000264: R0 := R0 + 0x30 +00000269: R1 := 0x11000 +0000026f: R1 := R1 + 0x30 +00000275: #1 := ~R0 +0000027a: #2 := R1 + ~R0 +00000280: VF := extend:65[#2 + 1] <> extend:65[R1] + extend:65[#1] + 1 +00000286: CF := pad:65[#2 + 1] <> pad:65[R1] + pad:65[#1] + 1 +0000028a: ZF := #2 + 1 = 0 +0000028e: NF := 63:63[#2 + 1] +00000294: when ZF goto %00000292 +0000074c: goto %000004dd + +000004dd: +000004e0: R1 := 0x10000 +000004e7: R1 := mem[R1 + 0xFC0, el]:u64 +000004ec: when R1 = 0 goto %00000292 +0000074d: goto %000004f0 + +00000292: +0000029a: call R30 with noreturn + +000004f0: +000004f4: R16 := R1 +000004f9: call R16 with noreturn + +0000074e: sub frame_dummy(frame_dummy_result) +00000761: frame_dummy_result :: out u32 = low:32[R0] + +00000332: +00000334: call @register_tm_clones with noreturn + +0000074f: sub main(main_argc, main_argv, main_result) +00000762: main_argc :: in u32 = low:32[R0] +00000763: main_argv :: in out u64 = R1 +00000764: main_result :: out u32 = low:32[R0] + +000003b0: +000003b4: R31 := R31 - 0x10 +000003ba: R9 := pad:64[31:0[R0] + 4] +000003c1: R11 := pad:64[31:0[R0] + (29:0[R0].0)] +000003c6: R8 := 6 +000003cc: R10 := R31 +000003d2: R13 := extend:64[31:0[R0].0] +000003d9: R8 := pad:64[31:0[R8] + ~31:0[R0] + 1] +000003df: R12 := R10 + 8 +000003e5: #6 := 31:0[R0] - 4 +000003ea: VF := extend:33[#6 + 1] <> extend:33[31:0[R0]] - 3 +000003ef: CF := pad:33[#6 + 1] <> pad:33[31:0[R0]] + 0xFFFFFFFD +000003f3: ZF := #6 + 1 = 0 +000003f7: NF := 31:31[#6 + 1] +000003fe: R10 := R10 + R13 +00000406: mem := mem with [R31, el]:u32 <- 31:0[R9] +0000040c: mem := mem with [R31 + 4, el]:u32 <- 31:0[R11] +0000041b: when NF <> VF goto %00000413 +0000041c: goto %00000417 + +00000417: +00000418: R9 := R12 +0000041e: goto %0000041a + +00000413: +00000414: R9 := R10 +0000041d: goto %0000041a + +0000041a: +00000423: R13 := 0x5A +00000432: when NF <> VF goto %0000042a +00000433: goto %0000042e + +0000042e: +0000042f: R10 := R12 +00000435: goto %00000431 + +0000042a: +0000042b: R10 := R10 +00000434: goto %00000431 + +00000431: +0000043b: #7 := R31 + 8 +00000441: mem := mem with [#7, el]:u32 <- 31:0[R8] +00000446: mem := mem with [#7 + 4, el]:u32 <- 0 +0000044d: R9 := pad:64[mem[R9, el]:u32] +00000455: mem := mem with [R31, el]:u32 <- 31:0[R11] +0000045b: mem := mem with [R31 + 4, el]:u32 <- 31:0[R8] +00000463: mem := mem with [R31 + 8, el]:u64 <- R13 +0000046a: R8 := pad:64[mem[R10, el]:u32] +00000471: R8 := pad:64[31:0[R9] + 31:0[R8]] +00000477: R0 := pad:64[31:0[R8] + 2] +0000047d: R31 := R31 + 0x10 +00000482: call R30 with noreturn + +00000750: sub register_tm_clones(register_tm_clones_result) +00000765: register_tm_clones_result :: out u32 = low:32[R0] + +0000029c: +0000029f: R0 := 0x11000 +000002a5: R0 := R0 + 0x30 +000002aa: R1 := 0x11000 +000002b0: R1 := R1 + 0x30 +000002b7: R1 := R1 + ~R0 + 1 +000002bd: R2 := 0.63:63[R1] +000002c4: R1 := R2 + (R1 ~>> 3) +000002ca: R1 := extend:64[63:1[R1]] +000002d0: when R1 = 0 goto %000002ce +00000751: goto %000004bf + +000004bf: +000004c2: R2 := 0x10000 +000004c9: R2 := mem[R2 + 0xFE0, el]:u64 +000004ce: when R2 = 0 goto %000002ce +00000752: goto %000004d2 + +000002ce: +000002d6: call R30 with noreturn + +000004d2: +000004d6: R16 := R2 +000004db: call R16 with noreturn + +00000753: sub test(test_result) +00000766: test_result :: out u32 = low:32[R0] + +00000336: +0000033a: R31 := R31 - 0x10 +00000340: R8 := R31 +00000346: #4 := 31:0[R3] - 4 +0000034b: VF := extend:33[#4 + 1] <> extend:33[31:0[R3]] - 3 +00000350: CF := pad:33[#4 + 1] <> pad:33[31:0[R3]] + 0xFFFFFFFD +00000354: ZF := #4 + 1 = 0 +00000358: NF := 31:31[#4 + 1] +0000035f: R9 := R8 + extend:64[31:0[R3].0] +00000365: R8 := R8 + 8 +00000374: when NF <> VF goto %0000036c +00000375: goto %00000370 + +00000370: +00000371: R8 := R8 +00000377: goto %00000373 + +0000036c: +0000036d: R8 := R9 +00000376: goto %00000373 + +00000373: +0000037f: mem := mem with [R31, el]:u32 <- 31:0[R0] +00000385: mem := mem with [R31 + 4, el]:u32 <- 31:0[R1] +0000038b: #5 := R31 + 8 +00000391: mem := mem with [#5, el]:u32 <- 31:0[R2] +00000396: mem := mem with [#5 + 4, el]:u32 <- 0 +0000039d: R8 := pad:64[mem[R8, el]:u32] +000003a3: R0 := pad:64[31:0[R8] + 1] +000003a9: R31 := R31 + 0x10 +000003ae: call R30 with noreturn diff --git a/examples/stackambiguity/stackambiguity.c b/examples/stackambiguity/stackambiguity.c new file mode 100644 index 000000000..ed765bc30 --- /dev/null +++ b/examples/stackambiguity/stackambiguity.c @@ -0,0 +1,19 @@ +int test(int a, int b, int c, int d) { + int q = 0; + int x[4] = {a, b, c}; + int* y = &x[2]; + if (d < 3) { + y = &x[d]; + } + q = *y + 1; + return q; +} + +int main(int argc, char** argv) { + int a = 4 + argc; + int b = 5 * argc; + int c = 6 - argc; + int d = test(a, b, c, argc); + int e = test(b, c, 90, argc); + return d + e; +} \ No newline at end of file diff --git a/examples/stackambiguity/stackambiguity.relf b/examples/stackambiguity/stackambiguity.relf new file mode 100644 index 000000000..db606f74a --- /dev/null +++ b/examples/stackambiguity/stackambiguity.relf @@ -0,0 +1,122 @@ + +Relocation section '.rela.dyn' at offset 0x460 contains 8 entries: + Offset Info Type Symbol's Value Symbol's Name + Addend +0000000000010dc8 0000000000000403 R_AARCH64_RELATIVE 710 +0000000000010dd0 0000000000000403 R_AARCH64_RELATIVE 6c0 +0000000000010fd8 0000000000000403 R_AARCH64_RELATIVE 744 +0000000000011028 0000000000000403 R_AARCH64_RELATIVE 11028 +0000000000010fc0 0000000400000401 R_AARCH64_GLOB_DAT 0000000000000000 _ITM_deregisterTMCloneTable + 0 +0000000000010fc8 0000000500000401 R_AARCH64_GLOB_DAT 0000000000000000 __cxa_finalize@GLIBC_2.17 + 0 +0000000000010fd0 0000000600000401 R_AARCH64_GLOB_DAT 0000000000000000 __gmon_start__ + 0 +0000000000010fe0 0000000800000401 R_AARCH64_GLOB_DAT 0000000000000000 _ITM_registerTMCloneTable + 0 + +Relocation section '.rela.plt' at offset 0x520 contains 4 entries: + Offset Info Type Symbol's Value Symbol's Name + Addend +0000000000011000 0000000300000402 R_AARCH64_JUMP_SLOT 0000000000000000 __libc_start_main@GLIBC_2.34 + 0 +0000000000011008 0000000500000402 R_AARCH64_JUMP_SLOT 0000000000000000 __cxa_finalize@GLIBC_2.17 + 0 +0000000000011010 0000000600000402 R_AARCH64_JUMP_SLOT 0000000000000000 __gmon_start__ + 0 +0000000000011018 0000000700000402 R_AARCH64_JUMP_SLOT 0000000000000000 abort@GLIBC_2.17 + 0 + +Symbol table '.dynsym' contains 9 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000000580 0 SECTION LOCAL DEFAULT 11 .init + 2: 0000000000011020 0 SECTION LOCAL DEFAULT 23 .data + 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.34 (2) + 4: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTable + 5: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@GLIBC_2.17 (3) + 6: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__ + 7: 0000000000000000 0 FUNC GLOBAL DEFAULT UND abort@GLIBC_2.17 (3) + 8: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable + +Symbol table '.symtab' contains 89 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000000238 0 SECTION LOCAL DEFAULT 1 .interp + 2: 0000000000000254 0 SECTION LOCAL DEFAULT 2 .note.gnu.build-id + 3: 0000000000000278 0 SECTION LOCAL DEFAULT 3 .note.ABI-tag + 4: 0000000000000298 0 SECTION LOCAL DEFAULT 4 .gnu.hash + 5: 00000000000002b8 0 SECTION LOCAL DEFAULT 5 .dynsym + 6: 0000000000000390 0 SECTION LOCAL DEFAULT 6 .dynstr + 7: 000000000000041e 0 SECTION LOCAL DEFAULT 7 .gnu.version + 8: 0000000000000430 0 SECTION LOCAL DEFAULT 8 .gnu.version_r + 9: 0000000000000460 0 SECTION LOCAL DEFAULT 9 .rela.dyn + 10: 0000000000000520 0 SECTION LOCAL DEFAULT 10 .rela.plt + 11: 0000000000000580 0 SECTION LOCAL DEFAULT 11 .init + 12: 00000000000005a0 0 SECTION LOCAL DEFAULT 12 .plt + 13: 0000000000000600 0 SECTION LOCAL DEFAULT 13 .text + 14: 00000000000007a0 0 SECTION LOCAL DEFAULT 14 .fini + 15: 00000000000007b4 0 SECTION LOCAL DEFAULT 15 .rodata + 16: 00000000000007b8 0 SECTION LOCAL DEFAULT 16 .eh_frame_hdr + 17: 0000000000000800 0 SECTION LOCAL DEFAULT 17 .eh_frame + 18: 0000000000010dc8 0 SECTION LOCAL DEFAULT 18 .init_array + 19: 0000000000010dd0 0 SECTION LOCAL DEFAULT 19 .fini_array + 20: 0000000000010dd8 0 SECTION LOCAL DEFAULT 20 .dynamic + 21: 0000000000010fb8 0 SECTION LOCAL DEFAULT 21 .got + 22: 0000000000010fe8 0 SECTION LOCAL DEFAULT 22 .got.plt + 23: 0000000000011020 0 SECTION LOCAL DEFAULT 23 .data + 24: 0000000000011030 0 SECTION LOCAL DEFAULT 24 .bss + 25: 0000000000000000 0 SECTION LOCAL DEFAULT 25 .comment + 26: 0000000000000000 0 FILE LOCAL DEFAULT ABS Scrt1.o + 27: 0000000000000278 0 NOTYPE LOCAL DEFAULT 3 $d + 28: 0000000000000278 32 OBJECT LOCAL DEFAULT 3 __abi_tag + 29: 0000000000000600 0 NOTYPE LOCAL DEFAULT 13 $x + 30: 0000000000000814 0 NOTYPE LOCAL DEFAULT 17 $d + 31: 00000000000007b4 0 NOTYPE LOCAL DEFAULT 15 $d + 32: 0000000000000000 0 FILE LOCAL DEFAULT ABS crti.o + 33: 0000000000000634 0 NOTYPE LOCAL DEFAULT 13 $x + 34: 0000000000000634 20 FUNC LOCAL DEFAULT 13 call_weak_fn + 35: 0000000000000580 0 NOTYPE LOCAL DEFAULT 11 $x + 36: 00000000000007a0 0 NOTYPE LOCAL DEFAULT 14 $x + 37: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtn.o + 38: 0000000000000590 0 NOTYPE LOCAL DEFAULT 11 $x + 39: 00000000000007ac 0 NOTYPE LOCAL DEFAULT 14 $x + 40: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c + 41: 0000000000000650 0 NOTYPE LOCAL DEFAULT 13 $x + 42: 0000000000000650 0 FUNC LOCAL DEFAULT 13 deregister_tm_clones + 43: 0000000000000680 0 FUNC LOCAL DEFAULT 13 register_tm_clones + 44: 0000000000011028 0 NOTYPE LOCAL DEFAULT 23 $d + 45: 00000000000006c0 0 FUNC LOCAL DEFAULT 13 __do_global_dtors_aux + 46: 0000000000011030 1 OBJECT LOCAL DEFAULT 24 completed.0 + 47: 0000000000010dd0 0 NOTYPE LOCAL DEFAULT 19 $d + 48: 0000000000010dd0 0 OBJECT LOCAL DEFAULT 19 __do_global_dtors_aux_fini_array_entry + 49: 0000000000000710 0 FUNC LOCAL DEFAULT 13 frame_dummy + 50: 0000000000010dc8 0 NOTYPE LOCAL DEFAULT 18 $d + 51: 0000000000010dc8 0 OBJECT LOCAL DEFAULT 18 __frame_dummy_init_array_entry + 52: 0000000000000828 0 NOTYPE LOCAL DEFAULT 17 $d + 53: 0000000000011030 0 NOTYPE LOCAL DEFAULT 24 $d + 54: 0000000000000000 0 FILE LOCAL DEFAULT ABS stackambiguity.c + 55: 0000000000000714 0 NOTYPE LOCAL DEFAULT 13 $x.0 + 56: 000000000000002a 0 NOTYPE LOCAL DEFAULT 25 $d.1 + 57: 0000000000000888 0 NOTYPE LOCAL DEFAULT 17 $d.2 + 58: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c + 59: 00000000000008cc 0 NOTYPE LOCAL DEFAULT 17 $d + 60: 00000000000008cc 0 OBJECT LOCAL DEFAULT 17 __FRAME_END__ + 61: 0000000000000000 0 FILE LOCAL DEFAULT ABS + 62: 0000000000010dd8 0 OBJECT LOCAL DEFAULT ABS _DYNAMIC + 63: 00000000000007b8 0 NOTYPE LOCAL DEFAULT 16 __GNU_EH_FRAME_HDR + 64: 0000000000010fb8 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ + 65: 00000000000005a0 0 NOTYPE LOCAL DEFAULT 12 $x + 66: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.34 + 67: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTable + 68: 0000000000011020 0 NOTYPE WEAK DEFAULT 23 data_start + 69: 0000000000011030 0 NOTYPE GLOBAL DEFAULT 24 __bss_start__ + 70: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@GLIBC_2.17 + 71: 0000000000011038 0 NOTYPE GLOBAL DEFAULT 24 _bss_end__ + 72: 0000000000011030 0 NOTYPE GLOBAL DEFAULT 23 _edata + 73: 00000000000007a0 0 FUNC GLOBAL HIDDEN 14 _fini + 74: 0000000000011038 0 NOTYPE GLOBAL DEFAULT 24 __bss_end__ + 75: 0000000000011020 0 NOTYPE GLOBAL DEFAULT 23 __data_start + 76: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__ + 77: 0000000000011028 0 OBJECT GLOBAL HIDDEN 23 __dso_handle + 78: 0000000000000000 0 FUNC GLOBAL DEFAULT UND abort@GLIBC_2.17 + 79: 00000000000007b4 4 OBJECT GLOBAL DEFAULT 15 _IO_stdin_used + 80: 0000000000011038 0 NOTYPE GLOBAL DEFAULT 24 _end + 81: 0000000000000600 52 FUNC GLOBAL DEFAULT 13 _start + 82: 0000000000011038 0 NOTYPE GLOBAL DEFAULT 24 __end__ + 83: 0000000000011030 0 NOTYPE GLOBAL DEFAULT 24 __bss_start + 84: 0000000000000744 92 FUNC GLOBAL DEFAULT 13 main + 85: 0000000000011030 0 OBJECT GLOBAL HIDDEN 23 __TMC_END__ + 86: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable + 87: 0000000000000580 0 FUNC GLOBAL HIDDEN 11 _init + 88: 0000000000000714 48 FUNC GLOBAL DEFAULT 13 test diff --git a/src/main/antlr4/Semantics.g4 b/src/main/antlr4/ASLp.g4 similarity index 99% rename from src/main/antlr4/Semantics.g4 rename to src/main/antlr4/ASLp.g4 index 821111783..372f4ced5 100644 --- a/src/main/antlr4/Semantics.g4 +++ b/src/main/antlr4/ASLp.g4 @@ -1,4 +1,4 @@ -grammar Semantics; +grammar ASLp; // See aslp/libASL/asl.ott for reference grammar Bap-ali-plugin/asli_lifer.ml may also be useful for // visitors diff --git a/src/main/scala/Main.scala b/src/main/scala/Main.scala index a97e23996..4a6630ce3 100644 --- a/src/main/scala/Main.scala +++ b/src/main/scala/Main.scala @@ -57,7 +57,9 @@ object Main { @arg(name = "simplify", doc = "Partial evaluate / simplify BASIL IR before output (requires --analyse flag)") simplify: Flag, @arg(name = "validate-simplify", doc = "Emit SMT2 check for algebraic simplification translation validation to 'rewrites.smt2'") - validateSimplify: Flag + validateSimplify: Flag, + @arg(name = "memory-regions", doc = "Performs static analysis to separate memory into discrete regions in Boogie output (requires --analyse flag)") + memoryRegions: Flag ) def main(args: Array[String]): Unit = { @@ -92,7 +94,7 @@ object Main { runInterpret = conf.interpret.value, simplify = conf.simplify.value, validateSimp = conf.validateSimplify.value, - staticAnalysis = if conf.analyse.value then Some(StaticAnalysisConfig(conf.dumpIL, conf.analysisResults, conf.analysisResultsDot, conf.threadSplit.value, conf.summariseProcedures.value)) else None, + staticAnalysis = if conf.analyse.value then Some(StaticAnalysisConfig(conf.dumpIL, conf.analysisResults, conf.analysisResultsDot, conf.threadSplit.value, conf.summariseProcedures.value, conf.memoryRegions.value)) else None, boogieTranslation = BoogieGeneratorConfig(if conf.lambdaStores.value then BoogieMemoryAccessMode.LambdaStoreSelect else BoogieMemoryAccessMode.SuccessiveStoreSelect, true, rely, conf.threadSplit.value), outputPrefix = conf.outFileName, diff --git a/src/main/scala/analysis/ANR.scala b/src/main/scala/analysis/ANR.scala index b00b51b71..02fc90974 100644 --- a/src/main/scala/analysis/ANR.scala +++ b/src/main/scala/analysis/ANR.scala @@ -7,7 +7,7 @@ import scala.collection.immutable /** * Calculates the set of variables that are not read after being written up to that point in the program. - * Useful for detecting dead stores, constants and if what variables are passed as parameters in a function call. + * Useful for detecting dead stores, constants and which variables are passed as parameters in a function call. */ trait ANRAnalysis(program: Program, ignoreStackPtrs: Boolean = false) { @@ -26,38 +26,44 @@ trait ANRAnalysis(program: Program, ignoreStackPtrs: Boolean = false) { /** Default implementation of eval. */ def eval(cmd: Command, s: Set[Variable]): Set[Variable] = { - var m = s cmd match { case assume: Assume => - m.diff(assume.body.variables) + s.diff(assume.body.variables) case assert: Assert => - m.diff(assert.body.variables) - case memoryAssign: MemoryAssign => - m.diff(memoryAssign.index.variables ++ memoryAssign.value.variables) + s.diff(assert.body.variables) + case memoryStore: MemoryStore => + s.diff(memoryStore.index.variables ++ memoryStore.value.variables) case indirectCall: IndirectCall => - m - indirectCall.target + s - indirectCall.target case call: DirectCall => - m.diff(call.actualParams.flatMap(_._2.variables).toSet.filterNot(ignoreRegions.contains(_))) + s.diff(call.actualParams.flatMap(_._2.variables).toSet.filterNot(ignoreRegions.contains(_))) ++ call.outParams.map(_._2).toSet - case assign: Assign => - m = m.diff(assign.rhs.variables) - if ignoreRegions.contains(assign.lhs) then m else m + assign.lhs + case assign: LocalAssign => + val m = s.diff(assign.rhs.variables) + if (ignoreRegions.contains(assign.lhs)) { + m + } else { + m + assign.lhs + } + case memoryLoad: MemoryLoad => + val m = s.diff(memoryLoad.index.variables) + if (ignoreRegions.contains(memoryLoad.lhs)) { + m + } else { + m + memoryLoad.lhs + } case _ => - m + s } } /** Transfer function for state lattice elements. */ - def localTransfer(n: CFGPosition, s: Set[Variable]): Set[Variable] = n match { + def transfer(n: CFGPosition, s: Set[Variable]): Set[Variable] = n match { case cmd: Command => eval(cmd, s) case _ => s // ignore other kinds of nodes } - - /** Transfer function for state lattice elements. - */ - def transfer(n: CFGPosition, s: Set[Variable]): Set[Variable] = localTransfer(n, s) } class ANRAnalysisSolver(program: Program, ignoreStack : Boolean = true) extends ANRAnalysis(program, ignoreStack) diff --git a/src/main/scala/analysis/Analysis.scala b/src/main/scala/analysis/Analysis.scala index 9ab736160..9a77d4032 100644 --- a/src/main/scala/analysis/Analysis.scala +++ b/src/main/scala/analysis/Analysis.scala @@ -1,14 +1,5 @@ package analysis -import ir.* -import analysis.solvers.* - -import scala.collection.mutable.{ArrayBuffer, HashMap, ListBuffer} -import java.io.{File, PrintWriter} -import scala.collection.mutable -import scala.collection.immutable -import util.Logger - /** Trait for program analyses. * * @tparam R @@ -18,177 +9,4 @@ trait Analysis[+R]: /** Performs the analysis and returns the result. */ - def analyze(): R - -/** Base class for value analysis with simple (non-lifted) lattice. - */ -trait ConstantPropagation(val program: Program) { - /** The lattice of abstract states. - */ - - val valuelattice: ConstantPropagationLattice = ConstantPropagationLattice() - - val statelattice: MapLattice[Variable, FlatElement[BitVecLiteral], ConstantPropagationLattice] = MapLattice(valuelattice) - - /** Default implementation of eval. - */ - def eval(exp: Expr, env: Map[Variable, FlatElement[BitVecLiteral]]): FlatElement[BitVecLiteral] = - import valuelattice._ - exp match - case id: Variable => env(id) - case n: BitVecLiteral => bv(n) - case ze: ZeroExtend => zero_extend(ze.extension, eval(ze.body, env)) - case se: SignExtend => sign_extend(se.extension, eval(se.body, env)) - case e: Extract => extract(e.end, e.start, eval(e.body, env)) - case bin: BinaryExpr => - val left = eval(bin.arg1, env) - val right = eval(bin.arg2, env) - bin.op match - case BVADD => bvadd(left, right) - case BVSUB => bvsub(left, right) - case BVMUL => bvmul(left, right) - case BVUDIV => bvudiv(left, right) - case BVSDIV => bvsdiv(left, right) - case BVSREM => bvsrem(left, right) - case BVUREM => bvurem(left, right) - case BVSMOD => bvsmod(left, right) - case BVAND => bvand(left, right) - case BVOR => bvor(left, right) - case BVXOR => bvxor(left, right) - case BVNAND => bvnand(left, right) - case BVNOR => bvnor(left, right) - case BVXNOR => bvxnor(left, right) - case BVSHL => bvshl(left, right) - case BVLSHR => bvlshr(left, right) - case BVASHR => bvashr(left, right) - case BVCOMP => bvcomp(left, right) - case BVCONCAT => concat(left, right) - - case un: UnaryExpr => - val arg = eval(un.arg, env) - - un.op match - case BVNOT => bvnot(arg) - case BVNEG => bvneg(arg) - - case _ => valuelattice.top - - /** Transfer function for state lattice elements. - */ - def localTransfer(n: CFGPosition, s: Map[Variable, FlatElement[BitVecLiteral]]): Map[Variable, FlatElement[BitVecLiteral]] = - n match - case r: Command => - r match - // assignments - case la: Assign => - s + (la.lhs -> eval(la.rhs, s)) - // all others: like no-ops - case _ => s - case _ => s - - /** The analysis lattice. - */ - val lattice: MapLattice[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]], MapLattice[Variable, FlatElement[BitVecLiteral], ConstantPropagationLattice]] = MapLattice(statelattice) - - val domain: Set[CFGPosition] = Set.empty ++ program - - /** Transfer function for state lattice elements. (Same as `localTransfer` for simple value analysis.) - */ - def transfer(n: CFGPosition, s: Map[Variable, FlatElement[BitVecLiteral]]): Map[Variable, FlatElement[BitVecLiteral]] = localTransfer(n, s) -} - -class ConstantPropagationSolver(program: Program) extends ConstantPropagation(program) - with SimplePushDownWorklistFixpointSolver[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]], MapLattice[Variable, FlatElement[BitVecLiteral], ConstantPropagationLattice]] - with IRIntraproceduralForwardDependencies - with Analysis[Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]]] - -/** Base class for value analysis with simple (non-lifted) lattice. - */ -trait ConstantPropagationWithSSA(val program: Program, val reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])]) { - /** The lattice of abstract states. - */ - - val valuelattice: ConstantPropagationLatticeWithSSA = ConstantPropagationLatticeWithSSA() - - val statelattice: MapLattice[RegisterWrapperEqualSets, Set[BitVecLiteral], ConstantPropagationLatticeWithSSA] = MapLattice(valuelattice) - - /** Default implementation of eval. - */ - def eval(exp: Expr, env: Map[RegisterWrapperEqualSets, Set[BitVecLiteral]], n: CFGPosition): Set[BitVecLiteral] = - import valuelattice._ - exp match - case id: Variable => env(RegisterWrapperEqualSets(id, getUse(id, n, reachingDefs))) - case n: BitVecLiteral => bv(n) - case ze: ZeroExtend => zero_extend(ze.extension, eval(ze.body, env, n)) - case se: SignExtend => sign_extend(se.extension, eval(se.body, env, n)) - case e: Extract => extract(e.end, e.start, eval(e.body, env, n)) - case bin: BinaryExpr => - val left = eval(bin.arg1, env, n) - val right = eval(bin.arg2, env, n) - bin.op match - case BVADD => bvadd(left, right) - case BVSUB => bvsub(left, right) - case BVMUL => bvmul(left, right) - case BVUDIV => bvudiv(left, right) - case BVSDIV => bvsdiv(left, right) - case BVSREM => bvsrem(left, right) - case BVUREM => bvurem(left, right) - case BVSMOD => bvsmod(left, right) - case BVAND => bvand(left, right) - case BVOR => bvor(left, right) - case BVXOR => bvxor(left, right) - case BVNAND => bvnand(left, right) - case BVNOR => bvnor(left, right) - case BVXNOR => bvxnor(left, right) - case BVSHL => bvshl(left, right) - case BVLSHR => bvlshr(left, right) - case BVASHR => bvashr(left, right) - case BVCOMP => bvcomp(left, right) - case BVCONCAT => concat(left, right) - - case un: UnaryExpr => - val arg = eval(un.arg, env, n) - - un.op match - case BVNOT => bvnot(arg) - case BVNEG => bvneg(arg) - - case _ => Set.empty - - /** Transfer function for state lattice elements. - */ - def localTransfer(n: CFGPosition, s: Map[RegisterWrapperEqualSets, Set[BitVecLiteral]]): Map[RegisterWrapperEqualSets, Set[BitVecLiteral]] = - n match { - case r: Command => - r match { - // assignments - case a: Assign => - val lhsWrappers = s.collect { - case (k, v) if RegisterVariableWrapper(k.variable, k.assigns) == RegisterVariableWrapper(a.lhs, getDefinition(a.lhs, r, reachingDefs)) => (k, v) - } - if (lhsWrappers.nonEmpty) { - s ++ lhsWrappers.map((k, v) => (k, v.union(eval(a.rhs, s, r)))) - } else { - s + (RegisterWrapperEqualSets(a.lhs, getDefinition(a.lhs, r, reachingDefs)) -> eval(a.rhs, s, n)) - } - // all others: like no-ops - case _ => s - } - case _ => s - } - - /** The analysis lattice. - */ - val lattice: MapLattice[CFGPosition, Map[RegisterWrapperEqualSets, Set[BitVecLiteral]], MapLattice[RegisterWrapperEqualSets, Set[BitVecLiteral], ConstantPropagationLatticeWithSSA]] = MapLattice(statelattice) - - val domain: Set[CFGPosition] = Set.empty ++ program - - /** Transfer function for state lattice elements. (Same as `localTransfer` for simple value analysis.) - */ - def transfer(n: CFGPosition, s: Map[RegisterWrapperEqualSets, Set[BitVecLiteral]]): Map[RegisterWrapperEqualSets, Set[BitVecLiteral]] = localTransfer(n, s) -} - -class ConstantPropagationSolverWithSSA(program: Program, reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])]) extends ConstantPropagationWithSSA(program, reachingDefs) - with SimplePushDownWorklistFixpointSolver[CFGPosition, Map[RegisterWrapperEqualSets, Set[BitVecLiteral]], MapLattice[RegisterWrapperEqualSets, Set[BitVecLiteral], ConstantPropagationLatticeWithSSA]] - with IRIntraproceduralForwardDependencies - with Analysis[Map[CFGPosition, Map[RegisterWrapperEqualSets, Set[BitVecLiteral]]]] + def analyze(): R \ No newline at end of file diff --git a/src/main/scala/analysis/BasicIRConstProp.scala b/src/main/scala/analysis/BasicIRConstProp.scala deleted file mode 100644 index 36a6d72d8..000000000 --- a/src/main/scala/analysis/BasicIRConstProp.scala +++ /dev/null @@ -1,75 +0,0 @@ -package analysis -import ir.* -import analysis.solvers.* - -trait ILValueAnalysisMisc: - val valuelattice: ConstantPropagationLattice = ConstantPropagationLattice() - val statelattice: MapLattice[Variable, FlatElement[BitVecLiteral], ConstantPropagationLattice] = MapLattice(valuelattice) - - def eval(exp: Expr, env: Map[Variable, FlatElement[BitVecLiteral]]): FlatElement[BitVecLiteral] = - import valuelattice._ - exp match - case id: Variable => env(id) - case n: BitVecLiteral => bv(n) - case ze: ZeroExtend => zero_extend(ze.extension, eval(ze.body, env)) - case se: SignExtend => sign_extend(se.extension, eval(se.body, env)) - case e: Extract => extract(e.end, e.start, eval(e.body, env)) - case bin: BinaryExpr => - val left = eval(bin.arg1, env) - val right = eval(bin.arg2, env) - bin.op match - case BVADD => bvadd(left, right) - case BVSUB => bvsub(left, right) - case BVMUL => bvmul(left, right) - case BVUDIV => bvudiv(left, right) - case BVSDIV => bvsdiv(left, right) - case BVSREM => bvsrem(left, right) - case BVUREM => bvurem(left, right) - case BVSMOD => bvsmod(left, right) - case BVAND => bvand(left, right) - case BVOR => bvor(left, right) - case BVXOR => bvxor(left, right) - case BVNAND => bvnand(left, right) - case BVNOR => bvnor(left, right) - case BVXNOR => bvxnor(left, right) - case BVSHL => bvshl(left, right) - case BVLSHR => bvlshr(left, right) - case BVASHR => bvashr(left, right) - case BVCOMP => bvcomp(left, right) - case BVCONCAT => concat(left, right) - - case un: UnaryExpr => - val arg = eval(un.arg, env) - - un.op match - case BVNOT => bvnot(arg) - case BVNEG => bvneg(arg) - - case _ => valuelattice.top - - private final val callerPreservedRegisters = Set("R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", - "R11", "R12", "R13", "R14", "R15", "R16", "R17", "R18", "R30") - - /** Transfer function for state lattice elements. - */ - def localTransfer(n: CFGPosition, s: Map[Variable, FlatElement[BitVecLiteral]]): Map[Variable, FlatElement[BitVecLiteral]] = - n match - case la: Assign => - s + (la.lhs -> eval(la.rhs, s)) - case c: Call => s ++ callerPreservedRegisters.filter(reg => s.keys.exists(_.name == reg)).map(n => Register(n, 64) -> statelattice.sublattice.top).toMap - case _ => s - - - -object IRSimpleValueAnalysis: - - class Solver(prog: Program) extends ILValueAnalysisMisc - with IRIntraproceduralForwardDependencies - with Analysis[Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]]] - with SimplePushDownWorklistFixpointSolver[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]], MapLattice[Variable, FlatElement[BitVecLiteral], ConstantPropagationLattice]]: - /* Worklist initial set */ - //override val lattice: MapLattice[CFGPosition, statelattice.type] = MapLattice(statelattice) - override val lattice: MapLattice[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]], MapLattice[Variable, FlatElement[BitVecLiteral], ConstantPropagationLattice]] = MapLattice(statelattice) - - override val domain: Set[CFGPosition] = computeDomain(IntraProcIRCursor, prog.procedures).toSet - def transfer(n: CFGPosition, s: Map[Variable, FlatElement[BitVecLiteral]]): Map[Variable, FlatElement[BitVecLiteral]] = localTransfer(n, s) diff --git a/src/main/scala/analysis/ConstantPropagation.scala b/src/main/scala/analysis/ConstantPropagation.scala new file mode 100644 index 000000000..a5f6d2d00 --- /dev/null +++ b/src/main/scala/analysis/ConstantPropagation.scala @@ -0,0 +1,192 @@ +package analysis +import ir.* +import analysis.solvers.* + +trait ConstantPropagation { + val valuelattice: ConstantPropagationLattice = ConstantPropagationLattice() + val statelattice: MapLattice[Variable, FlatElement[BitVecLiteral], ConstantPropagationLattice] = MapLattice(valuelattice) + val lattice: MapLattice[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]], MapLattice[Variable, FlatElement[BitVecLiteral], ConstantPropagationLattice]] = MapLattice(statelattice) + + def eval(exp: Expr, env: Map[Variable, FlatElement[BitVecLiteral]]): FlatElement[BitVecLiteral] = { + import valuelattice.* + exp match { + case id: Variable => env(id) + case n: BitVecLiteral => bv(n) + case ze: ZeroExtend => zero_extend(ze.extension, eval(ze.body, env)) + case se: SignExtend => sign_extend(se.extension, eval(se.body, env)) + case e: Extract => extract(e.end, e.start, eval(e.body, env)) + case bin: BinaryExpr => + val left = eval(bin.arg1, env) + val right = eval(bin.arg2, env) + bin.op match { + case BVADD => bvadd(left, right) + case BVSUB => bvsub(left, right) + case BVMUL => bvmul(left, right) + case BVUDIV => bvudiv(left, right) + case BVSDIV => bvsdiv(left, right) + case BVSREM => bvsrem(left, right) + case BVUREM => bvurem(left, right) + case BVSMOD => bvsmod(left, right) + case BVAND => bvand(left, right) + case BVOR => bvor(left, right) + case BVXOR => bvxor(left, right) + case BVNAND => bvnand(left, right) + case BVNOR => bvnor(left, right) + case BVXNOR => bvxnor(left, right) + case BVSHL => bvshl(left, right) + case BVLSHR => bvlshr(left, right) + case BVASHR => bvashr(left, right) + case BVCOMP => bvcomp(left, right) + case BVCONCAT => concat(left, right) + } + case un: UnaryExpr => + val arg = eval(un.arg, env) + un.op match { + case BVNOT => bvnot(arg) + case BVNEG => bvneg(arg) + } + case _ => valuelattice.top + } + } +} + +class IntraProcConstantPropagation(prog: Program) extends ConstantPropagation +with IRIntraproceduralForwardDependencies +with Analysis[Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]]] +with SimplePushDownWorklistFixpointSolver[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]], MapLattice[Variable, FlatElement[BitVecLiteral], ConstantPropagationLattice]] { + override val domain: Set[CFGPosition] = computeDomain(IntraProcIRCursor, prog.procedures).toSet + + private final val callerPreservedRegisters: Set[Variable] = Set("R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", + "R11", "R12", "R13", "R14", "R15", "R16", "R17", "R18", "R30").map(n => Register(n, 64)) + + def transfer(n: CFGPosition, s: Map[Variable, FlatElement[BitVecLiteral]]): Map[Variable, FlatElement[BitVecLiteral]] = { + n match { + case la: LocalAssign => + s + (la.lhs -> eval(la.rhs, s)) + case l: MemoryLoad => + s + (l.lhs -> valuelattice.top) + case _: Call => s.map { (k, v) => + if (callerPreservedRegisters.contains(k)) { + (k, valuelattice.top) + } else { + (k, v) + } + } + case _ => s + } + } +} + +class InterProcConstantPropagation(val program: Program) extends ConstantPropagation +with SimplePushDownWorklistFixpointSolver[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]], MapLattice[Variable, FlatElement[BitVecLiteral], ConstantPropagationLattice]] +with IRInterproceduralForwardDependencies +with Analysis[Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]]] { + + def transfer(n: CFGPosition, s: Map[Variable, FlatElement[BitVecLiteral]]): Map[Variable, FlatElement[BitVecLiteral]] = { + n match { + // assignments + case la: LocalAssign => + s + (la.lhs -> eval(la.rhs, s)) + case load: MemoryLoad => + s + (load.lhs -> valuelattice.top) + // all others: like no-ops + case _ => s + } + } + + override val domain: Set[CFGPosition] = Set.empty ++ program +} + +/** Base class for value analysis with simple (non-lifted) lattice. + */ +trait ConstantPropagationWithSSA(val program: Program, val reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])]) { + /** The lattice of abstract states. + */ + + val valuelattice: ConstantPropagationLatticeWithSSA = ConstantPropagationLatticeWithSSA() + + val statelattice: MapLattice[RegisterWrapperEqualSets, Set[BitVecLiteral], ConstantPropagationLatticeWithSSA] = MapLattice(valuelattice) + + /** Default implementation of eval. + */ + def eval(exp: Expr, env: Map[RegisterWrapperEqualSets, Set[BitVecLiteral]], n: CFGPosition): Set[BitVecLiteral] = { + import valuelattice.* + exp match { + case id: Variable => env(RegisterWrapperEqualSets(id, getUse(id, n, reachingDefs))) + case n: BitVecLiteral => bv(n) + case ze: ZeroExtend => zero_extend(ze.extension, eval(ze.body, env, n)) + case se: SignExtend => sign_extend(se.extension, eval(se.body, env, n)) + case e: Extract => extract(e.end, e.start, eval(e.body, env, n)) + case bin: BinaryExpr => + val left = eval(bin.arg1, env, n) + val right = eval(bin.arg2, env, n) + bin.op match { + case BVADD => bvadd(left, right) + case BVSUB => bvsub(left, right) + case BVMUL => bvmul(left, right) + case BVUDIV => bvudiv(left, right) + case BVSDIV => bvsdiv(left, right) + case BVSREM => bvsrem(left, right) + case BVUREM => bvurem(left, right) + case BVSMOD => bvsmod(left, right) + case BVAND => bvand(left, right) + case BVOR => bvor(left, right) + case BVXOR => bvxor(left, right) + case BVNAND => bvnand(left, right) + case BVNOR => bvnor(left, right) + case BVXNOR => bvxnor(left, right) + case BVSHL => bvshl(left, right) + case BVLSHR => bvlshr(left, right) + case BVASHR => bvashr(left, right) + case BVCOMP => bvcomp(left, right) + case BVCONCAT => concat(left, right) + } + + case un: UnaryExpr => + val arg = eval(un.arg, env, n) + un.op match { + case BVNOT => bvnot(arg) + case BVNEG => bvneg(arg) + } + + case _ => Set.empty + } + } + + /** Transfer function for state lattice elements. + */ + def transfer(n: CFGPosition, s: Map[RegisterWrapperEqualSets, Set[BitVecLiteral]]): Map[RegisterWrapperEqualSets, Set[BitVecLiteral]] = + n match { + case a: LocalAssign => + val lhsWrappers = s.collect { + case (k, v) if RegisterVariableWrapper(k.variable, k.assigns) == RegisterVariableWrapper(a.lhs, getDefinition(a.lhs, a, reachingDefs)) => (k, v) + } + if (lhsWrappers.nonEmpty) { + s ++ lhsWrappers.map((k, v) => (k, v.union(eval(a.rhs, s, a)))) + } else { + s + (RegisterWrapperEqualSets(a.lhs, getDefinition(a.lhs, a, reachingDefs)) -> eval(a.rhs, s, n)) + } + case l: MemoryLoad => + val lhsWrappers = s.collect { + case (k, v) if RegisterVariableWrapper(k.variable, k.assigns) == RegisterVariableWrapper(l.lhs, getDefinition(l.lhs, l, reachingDefs)) => (k, v) + } + if (lhsWrappers.nonEmpty) { + s ++ lhsWrappers + } else { + s + (RegisterWrapperEqualSets(l.lhs, getDefinition(l.lhs, l, reachingDefs)) -> Set()) + } + + case _ => s + } + + /** The analysis lattice. + */ + val lattice: MapLattice[CFGPosition, Map[RegisterWrapperEqualSets, Set[BitVecLiteral]], MapLattice[RegisterWrapperEqualSets, Set[BitVecLiteral], ConstantPropagationLatticeWithSSA]] = MapLattice(statelattice) + + val domain: Set[CFGPosition] = Set.empty ++ program +} + +class ConstantPropagationSolverWithSSA(program: Program, reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])]) extends ConstantPropagationWithSSA(program, reachingDefs) + with SimplePushDownWorklistFixpointSolver[CFGPosition, Map[RegisterWrapperEqualSets, Set[BitVecLiteral]], MapLattice[RegisterWrapperEqualSets, Set[BitVecLiteral], ConstantPropagationLatticeWithSSA]] + with IRInterproceduralForwardDependencies + with Analysis[Map[CFGPosition, Map[RegisterWrapperEqualSets, Set[BitVecLiteral]]]] diff --git a/src/main/scala/analysis/ExprSSAEval.scala b/src/main/scala/analysis/ExprSSAEval.scala index 1d8b4a87d..95397869a 100644 --- a/src/main/scala/analysis/ExprSSAEval.scala +++ b/src/main/scala/analysis/ExprSSAEval.scala @@ -25,8 +25,6 @@ def evaluateExpression(exp: Expr, constantPropResult: Map[Variable, FlatElement[ } def evaluateExpressionWithSSA(exp: Expr, constantPropResult: Map[RegisterWrapperEqualSets, Set[BitVecLiteral]], n: CFGPosition, reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])]): Set[BitVecLiteral] = { - Logger.debug(s"evaluateExpression: $exp") - def apply(op: (BitVecLiteral, BitVecLiteral) => BitVecLiteral, a: Set[BitVecLiteral], b: Set[BitVecLiteral]): Set[BitVecLiteral] = { val res = for { x <- a @@ -36,9 +34,7 @@ def evaluateExpressionWithSSA(exp: Expr, constantPropResult: Map[RegisterWrapper } def applySingle(op: BitVecLiteral => BitVecLiteral, a: Set[BitVecLiteral]): Set[BitVecLiteral] = { - val res = for { - x <- a - } yield op(x) + val res = for (x <- a) yield op(x) res } @@ -105,21 +101,27 @@ def getUse(variable: Variable, node: CFGPosition, reachingDefs: Map[CFGPosition, out.getOrElse(variable, Set()) } -def unwrapExpr(expr: Expr): Set[Expr] = { - var buffers: Set[Expr] = Set() +def unwrapExprToVar(expr: Expr): Option[Variable] = { expr match { - case e: Extract => buffers ++= unwrapExpr(e.body) - case e: SignExtend => buffers ++= unwrapExpr(e.body) - case e: ZeroExtend => buffers ++= unwrapExpr(e.body) - case repeat: Repeat => buffers ++= unwrapExpr(repeat.body) - case unaryExpr: UnaryExpr => buffers ++= unwrapExpr(unaryExpr.arg) - case binaryExpr: BinaryExpr => - buffers ++= unwrapExpr(binaryExpr.arg1) - buffers ++= unwrapExpr(binaryExpr.arg2) - case memoryLoad: MemoryLoad => - buffers += memoryLoad - buffers ++= unwrapExpr(memoryLoad.index) + case variable: Variable => + Some(variable) + case e: Extract => unwrapExprToVar(e.body) + case e: SignExtend => unwrapExprToVar(e.body) + case e: ZeroExtend => unwrapExprToVar(e.body) + case repeat: Repeat => unwrapExprToVar(repeat.body) + case unaryExpr: UnaryExpr => unwrapExprToVar(unaryExpr.arg) + case binaryExpr: BinaryExpr => // TODO: incorrect + unwrapExprToVar(binaryExpr.arg1) + unwrapExprToVar(binaryExpr.arg2) case _ => + None + } +} + +def bitVectorOpToBigIntOp(op: BinOp, lhs: BigInt, rhs: BigInt): BigInt = { + op match { + case BVADD => lhs + rhs + case BVSUB => lhs - rhs + case _ => throw RuntimeException("Binary operation support not implemented: " + op) } - buffers } diff --git a/src/main/scala/analysis/GlobalRegionAnalysis.scala b/src/main/scala/analysis/GlobalRegionAnalysis.scala new file mode 100644 index 000000000..4aad43ba0 --- /dev/null +++ b/src/main/scala/analysis/GlobalRegionAnalysis.scala @@ -0,0 +1,198 @@ +package analysis + +import analysis.solvers.SimpleWorklistFixpointSolver +import ir.* + +import scala.collection.mutable + +trait GlobalRegionAnalysis(val program: Program, + val domain: Set[CFGPosition], + val constantProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], + val reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])], + val mmm: MemoryModelMap, + val vsaResult: Map[CFGPosition, LiftedElement[Map[Variable | MemoryRegion, Set[Value]]]]) { + + private var dataCount: Int = 0 + private def nextDataCount() = { + dataCount += 1 + s"data_$dataCount" + } + + val regionLattice: PowersetLattice[DataRegion] = PowersetLattice() + + val lattice: MapLattice[CFGPosition, Set[DataRegion], PowersetLattice[DataRegion]] = MapLattice(regionLattice) + + val first: Set[CFGPosition] = Set(program.mainProcedure) + + private val dataMap: mutable.HashMap[BigInt, DataRegion] = mutable.HashMap() + + private def dataPoolMaster(offset: BigInt, size: BigInt): DataRegion = { + assert(size >= 0) + if (dataMap.contains(offset)) { + if (dataMap(offset).size < (size.toDouble / 8).ceil.toInt) { + dataMap(offset) = DataRegion(dataMap(offset).regionIdentifier, offset, (size.toDouble / 8).ceil.toInt) + dataMap(offset) + } else { + dataMap(offset) + } + } else { + dataMap(offset) = DataRegion(nextDataCount(), offset, (size.toDouble / 8).ceil.toInt) + dataMap(offset) + } + } + + def getDataMap: mutable.HashMap[BigInt, DataRegion] = dataMap + + /** + * For DataRegions, the actual address used needs to be converted to the relocated address. + * This is because when regions are found, the relocated address is used and as such match + * the correct range. + * + * @param address: The starting DataRegion + * @return DataRegion: The relocated data region if any + */ + def resolveGlobalOffsetSecondLast(address: DataRegion): DataRegion = { + var tableAddress = address + // addresses may be layered as in jumptable2 example for which recursive search is required + var exitLoop = false + while (mmm.relocatedDataRegion(tableAddress.start).isDefined && mmm.relocatedDataRegion(mmm.relocatedDataRegion(tableAddress.start).get.start).isDefined && !exitLoop) { + val newAddress = mmm.relocatedDataRegion(tableAddress.start).getOrElse(tableAddress) + if (newAddress == tableAddress) { + exitLoop = true + } else { + tableAddress = newAddress + } + } + tableAddress + } + + def tryCoerceIntoData(exp: Expr, n: Command, subAccess: BigInt, loadOp: Boolean = false): Set[DataRegion] = { + val eval = evaluateExpression(exp, constantProp(n)) + if (eval.isDefined) { + Set(dataPoolMaster(eval.get.value, subAccess)) + } else { + exp match { + case literal: BitVecLiteral => tryCoerceIntoData(literal, n, subAccess) + case Extract(_, _, body) => tryCoerceIntoData(body, n, subAccess) + case Repeat(_, body) => tryCoerceIntoData(body, n, subAccess) + case ZeroExtend(_, body) => tryCoerceIntoData(body, n, subAccess) + case SignExtend(_, body) => tryCoerceIntoData(body, n, subAccess) + case UnaryExpr(_, arg) => tryCoerceIntoData(arg, n, subAccess) + case BinaryExpr(op, arg1, arg2) => + val evalArg2 = evaluateExpression(arg2, constantProp(n)) + if (evalArg2.isDefined) { + tryCoerceIntoData(arg1, n, subAccess, true) flatMap { i => + val newExpr = BinaryExpr(op, BitVecLiteral(i.start, evalArg2.get.size), evalArg2.get) + tryCoerceIntoData(newExpr, n, subAccess) + } + } else { + Set() + } + case _: UninterpretedFunction => Set.empty + case variable: Variable => + val ctx = getUse(variable, n, reachingDefs) + val collage = ctx.flatMap { i => + if (i != n) { + val regions: Set[DataRegion] = vsaResult.get(i) match { + case Some(Lift(el)) => + // FIXME: not correct for directall + assert(i.assignees.toSet.contains(variable)) + el.getOrElse(variable, Set()).flatMap { + case AddressValue(region) => + el.getOrElse(region, Set()).flatMap { + case AddressValue(dataRegion: DataRegion) => Some(dataRegion) + case _ => None + } + case _ => Set() + } + case _ => Set() + } + if (regions.isEmpty) { + localTransfer(i, Set()) + } else { + regions + } + } else { + Set() + } + } + collage.map { i => + if (!loadOp) { + mmm.relocatedDataRegion(i.start).getOrElse(i) + } else { + resolveGlobalOffsetSecondLast(i) + } + } + case _ => Set() + } + } + } + + def evalMemLoadToGlobal(index: Expr, size: BigInt, n: Command, loadOp: Boolean = false): Set[DataRegion] = { + val indexValue = evaluateExpression(index, constantProp(n)) + if (indexValue.isDefined) { + val indexValueBigInt = indexValue.get.value + Set(dataPoolMaster(indexValueBigInt, size)) + } else { + tryCoerceIntoData(index, n, size) + } + } + + /** + * Check if the data region is defined. + * Finds full and partial matches + * Full matches sizes are altered to match the size of the data region + * Partial matches are not altered + * Otherwise the data region is returned + * + * @param dataRegions Set[DataRegion] + * @param n CFGPosition + * @return Set[DataRegion] + */ + def checkIfDefined(dataRegions: Set[DataRegion], n: CFGPosition): Set[DataRegion] = { + dataRegions.map { i => + val (f, p) = mmm.findDataObjectWithSize(i.start, i.size) + val accesses = f.union(p) + if (accesses.isEmpty) { + i + } else if (accesses.size == 1) { + dataMap(i.start) = DataRegion(i.regionIdentifier, i.start, i.size.max(accesses.head.size)) + dataMap(i.start) + } else { + val highestRegion = accesses.maxBy(_.start) + dataMap(i.start) = DataRegion(i.regionIdentifier, i.start, i.size.max(highestRegion.end - i.start)) + dataMap(i.start) + } + } + } + + /** Transfer function for state lattice elements. + */ + def localTransfer(n: CFGPosition, s: Set[DataRegion]): Set[DataRegion] = { + n match { + case store: MemoryStore => + checkIfDefined(evalMemLoadToGlobal(store.index, store.size, store), n) + case load: MemoryLoad => + checkIfDefined(evalMemLoadToGlobal(load.index, load.size, load, loadOp = true), n) + case assign: LocalAssign => + // this is a constant but we need to check if it is a data region + checkIfDefined(evalMemLoadToGlobal(assign.rhs, 1, assign), n) + case _ => + Set() + } + } + + def transfer(n: CFGPosition, s: Set[DataRegion]): Set[DataRegion] = localTransfer(n, s) +} + +class GlobalRegionAnalysisSolver( + program: Program, + domain: Set[CFGPosition], + constantProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], + reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])], + mmm: MemoryModelMap, + vsaResult: Map[CFGPosition, LiftedElement[Map[Variable | MemoryRegion, Set[Value]]]] + ) extends GlobalRegionAnalysis(program, domain, constantProp, reachingDefs, mmm, vsaResult) + with IRIntraproceduralForwardDependencies + with Analysis[Map[CFGPosition, Set[DataRegion]]] + with SimpleWorklistFixpointSolver[CFGPosition, Set[DataRegion], PowersetLattice[DataRegion]] diff --git a/src/main/scala/analysis/InterLiveVarsAnalysis.scala b/src/main/scala/analysis/InterLiveVarsAnalysis.scala index cbe3076c6..ef9173a65 100644 --- a/src/main/scala/analysis/InterLiveVarsAnalysis.scala +++ b/src/main/scala/analysis/InterLiveVarsAnalysis.scala @@ -1,7 +1,7 @@ package analysis import analysis.solvers.BackwardIDESolver -import ir.{Assert, Assume, Block, GoTo, CFGPosition, Command, DirectCall, IndirectCall, Assign, MemoryAssign, Unreachable, Return, Procedure, Program, Variable, toShortString} +import ir.{Assert, LocalAssign, Assume, CFGPosition, Command, DirectCall, IndirectCall, MemoryLoad, MemoryStore, Procedure, Program, Return, Variable} /** * Micro-transfer-functions for LiveVar analysis @@ -28,54 +28,68 @@ trait LiveVarsAnalysisFunctions extends BackwardIDEAnalysis[Variable, TwoElement } def edgesCallToAfterCall(call: Command, aftercall: DirectCall)(d: DL): Map[DL, EdgeFunction[TwoElement]] = { - d match - case Left(value) => Map() // maps all variables before the call to bottom + d match { + case Left(_) => Map() // maps all variables before the call to bottom case Right(_) => Map(d -> IdEdge()) + } } def edgesOther(n: CFGPosition)(d: DL): Map[DL, EdgeFunction[TwoElement]] = { - n match - case Assign(variable, expr, _) => // (s - variable) ++ expr.variables - d match + n match { + case LocalAssign(variable, expr, _) => // (s - variable) ++ expr.variables + d match { case Left(value) => if value == variable then Map() else Map(d -> IdEdge()) - - case Right(_) => expr.variables.foldLeft(Map[DL, EdgeFunction[TwoElement]](d -> IdEdge())) { + case Right(_) => + expr.variables.foldLeft(Map[DL, EdgeFunction[TwoElement]](d -> IdEdge())) { + (mp, expVar) => mp + (Left(expVar) -> ConstEdge(TwoElementTop)) + } + } + case MemoryLoad(lhs, _, index, _, _, _) => + d match { + case Left(value) => + if value == lhs then + Map() + else + Map(d -> IdEdge()) + case Right(_) => index.variables.foldLeft(Map[DL, EdgeFunction[TwoElement]](d -> IdEdge())) { (mp, expVar) => mp + (Left(expVar) -> ConstEdge(TwoElementTop)) } - - case MemoryAssign(_, index, value, _, _, _) => // s ++ store.index.variables ++ store.value.variables - d match - case Left(value) => Map(d -> IdEdge()) + } + case MemoryStore(_, index, value, _, _, _) => // s ++ store.index.variables ++ store.value.variables + d match { + case Left(_) => Map(d -> IdEdge()) case Right(_) => (index.variables ++ value.variables).foldLeft(Map[DL, EdgeFunction[TwoElement]](d -> IdEdge())) { (mp, storVar) => mp + (Left(storVar) -> ConstEdge(TwoElementTop)) } - + } case Assume(expr, _, _, _) => // s ++ expr.variables - d match - case Left(value) => Map(d -> IdEdge()) + d match { + case Left(_) => Map(d -> IdEdge()) case Right(_) => expr.variables.foldLeft(Map(d -> IdEdge()): Map[DL, EdgeFunction[TwoElement]]) { (mp, expVar) => mp + (Left(expVar) -> ConstEdge(TwoElementTop)) } - + } case Assert(expr, _, _) => // s ++ expr.variables - d match - case Left(value) => Map(d -> IdEdge()) + d match { + case Left(_) => Map(d -> IdEdge()) case Right(_) => expr.variables.foldLeft(Map[DL, EdgeFunction[TwoElement]](d -> IdEdge())) { (mp, expVar) => mp + (Left(expVar) -> ConstEdge(TwoElementTop)) } + } case IndirectCall(variable, _) => - d match + d match { case Left(value) => if value != variable then Map(d -> IdEdge()) else Map() case Right(_) => Map(d -> IdEdge(), Left(variable) -> ConstEdge(TwoElementTop)) + } case _ => Map(d -> IdEdge()) - + } } } diff --git a/src/main/scala/analysis/InterprocSteensgaardAnalysis.scala b/src/main/scala/analysis/InterprocSteensgaardAnalysis.scala index 4e7ba81f1..0817628a6 100644 --- a/src/main/scala/analysis/InterprocSteensgaardAnalysis.scala +++ b/src/main/scala/analysis/InterprocSteensgaardAnalysis.scala @@ -22,321 +22,124 @@ case class RegisterVariableWrapper(variable: Variable, assigns: Set[Assign]) { /** Wrapper for variables so we can have ConstantPropegation-specific equals method indirectly * Relies on SSA sets being exactly the same * */ -case class RegisterWrapperEqualSets(variable: Variable, assigns: Set[Assign]) { - override def equals(obj: Any): Boolean = { - obj match { - case RegisterWrapperEqualSets(other, otherAssigns) => - variable == other && assigns == otherAssigns - case _ => - false - } - } -} +case class RegisterWrapperEqualSets(variable: Variable, assigns: Set[Assign]) /** Steensgaard-style pointer analysis. The analysis associates an [[StTerm]] with each variable declaration and - * expression node in the AST. It is implemented using [[analysis.solvers.UnionFindSolver]]. - */ + * expression node in the AST. It is implemented using [[analysis.solvers.UnionFindSolver]]. + */ class InterprocSteensgaardAnalysis( - program: Program, - constantProp: Map[CFGPosition, Map[RegisterWrapperEqualSets, Set[BitVecLiteral]]], - regionAccesses: Map[CFGPosition, Map[RegisterVariableWrapper, FlatElement[Expr]]], - mmm: MemoryModelMap, - reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])], - globalOffsets: Map[BigInt, BigInt]) extends Analysis[Any] { + domain: Set[CFGPosition], + mmm: MemoryModelMap, + reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])], + vsaResult: Map[CFGPosition, LiftedElement[Map[Variable | MemoryRegion, Set[Value]]]]) extends Analysis[Any] { val solver: UnionFindSolver[StTerm] = UnionFindSolver() - private val stackPointer = Register("R31", 64) - private val linkRegister = Register("R30", 64) - private val framePointer = Register("R29", 64) - private val ignoreRegions: Set[Expr] = Set(linkRegister, framePointer) private val mallocVariable = Register("R0", 64) - var mallocCount: Int = 0 - var stackCount: Int = 0 - val stackMap: mutable.Map[Expr, StackRegion] = mutable.Map() - - private val memoryRegionContents: mutable.Map[MemoryRegion, mutable.Set[BitVecLiteral | MemoryRegion]] = mutable.Map() - - def getMemoryRegionContents: Map[MemoryRegion, Set[BitVecLiteral | MemoryRegion]] = memoryRegionContents.map((k, v) => k -> v.toSet).toMap - - private def nextMallocCount() = { - mallocCount += 1 - s"malloc_$mallocCount" - } - - /** - * In expressions that have accesses within a region, we need to relocate - * the base address to the actual address using the relocation table. - * MUST RELOCATE because MMM iterate to find the lowest address - * TODO: May need to iterate over the relocation table to find the actual address - * - * @param address - * @return BitVecLiteral: the relocated address - */ - def relocatedBase(address: BitVecLiteral): BitVecLiteral = { - val tableAddress = globalOffsets.getOrElse(address.value, address.value) - // this condition checks if the address is not layered and returns if it is not - if (tableAddress != address.value && !globalOffsets.contains(tableAddress)) { - return address - } - BitVecLiteral(tableAddress, address.size) - } - - /** - * Used to reduce an expression that may be a sub-region of a memory region. - * Pointer reduction example: - * R2 = R31 + 20 - * Mem[R2 + 8] <- R1 - * - * Steps: - * 1) R2 = R31 + 20 <- ie. stack access (assume R31 = stackPointer) - * ↓ - * R2 = StackRegion("stack_1", 20) - * - * 2) Mem[R2 + 8] <- R1 <- ie. memStore - * ↓ - * (StackRegion("stack_1", 20) + 8) <- R1 - * ↓ - * MMM.get(20 + 8) <- R1 - * - * @param binExpr - * @param n - * @return Set[MemoryRegion]: a set of regions that the expression may be pointing to - */ - def reducibleToRegion(binExpr: BinaryExpr, n: Command): Set[MemoryRegion] = { - var reducedRegions = Set.empty[MemoryRegion] - binExpr.arg1 match { - case variable: Variable => - evaluateExpressionWithSSA(binExpr, constantProp(n), n, reachingDefs).foreach { b => - val region = mmm.findDataObject(b.value) - reducedRegions = reducedRegions ++ region - } - if (reducedRegions.nonEmpty) { - return reducedRegions - } - val ctx = getUse(variable, n, reachingDefs) - for (i <- ctx) { - if (i != n) { // handles loops (ie. R19 = R19 + 1) %00000662 in jumptable2 - val regions = i.rhs match { - case loadL: MemoryLoad => - val foundRegions = exprToRegion(loadL.index, i) - val toReturn = mutable.Set[MemoryRegion]().addAll(foundRegions) - for { - f <- foundRegions - } { - if (memoryRegionContents.contains(f)) { - memoryRegionContents(f).foreach { - case b: BitVecLiteral => -// val region = mmm.findDataObject(b.value) -// if (region.isDefined) { -// toReturn.addOne(region.get) -// } - case r: MemoryRegion => - toReturn.addOne(r) - toReturn.remove(f) - } - } - } - toReturn.toSet - case _: BitVecLiteral => - Set.empty[MemoryRegion] - case _ => - Logger.debug(s"Unknown expression: $i") - Logger.debug(ctx) - exprToRegion(i.rhs, i) - } - val results = evaluateExpressionWithSSA(binExpr.arg2, constantProp(n), n, reachingDefs) - for { - b <- results - r <- regions - } { - r match { - case stackRegion: StackRegion => - val nextOffset = BinaryExpr(binExpr.op, stackRegion.start, b) - evaluateExpressionWithSSA(nextOffset, constantProp(n), n, reachingDefs).foreach { b2 => - reducedRegions ++= exprToRegion(BinaryExpr(binExpr.op, stackPointer, b2), n) - } - case dataRegion: DataRegion => - Logger.debug(s"Hey, I'm a data region: $dataRegion") - Logger.debug(s"Hey, I'm a offset: $b") - val nextOffset = BinaryExpr(binExpr.op, relocatedBase(dataRegion.start), b) - evaluateExpressionWithSSA(nextOffset, constantProp(n), n, reachingDefs).foreach { b2 => - reducedRegions ++= exprToRegion(b2, n) - } - case _ => - } + def vsaApproximation(variable: Variable, n: CFGPosition): Set[MemoryRegion] = { + val ctx = getUse(variable, n, reachingDefs) + ctx.flatMap { i => + if (i != n) { + vsaResult.get(i) match { + case Some(Lift(el)) => + assert(i.assignees.contains(variable)) + el.get(variable) match { + case Some(values) => values.flatMap { + case addressValue: AddressValue => + Some(addressValue.region) + case _: LiteralValue => None } + case None => Set() } + case _ => Set() } - case _ => + } else { + Set() + } } - reducedRegions } - // TODO: You must redefine how shared regions are accessed by finding if the register we are evaluating is shared + /** @inheritdoc + */ + def analyze(): Unit = { + // generate the constraints by traversing the AST and solve them on-the-fly + domain.foreach { p => + visit(p, ()) + } + } - /** - * Finds a region for a given expression using MMM results - * - * @param expr - * @param n - * @return Set[MemoryRegion]: a set of regions that the expression may be pointing to + /** Generates the constraints for the given sub-AST. + * @param node + * the node for which it generates the constraints + * @param arg + * unused for this visitor */ - def exprToRegion(expr: Expr, n: Command): Set[MemoryRegion] = { - var res = Set[MemoryRegion]() - mmm.popContext() - mmm.pushContext(IRWalk.procedure(n).name) - expr match { // TODO: Stack detection here should be done in a better way or just merged with data - case binOp: BinaryExpr if binOp.arg1 == stackPointer => - evaluateExpressionWithSSA(binOp.arg2, constantProp(n), n, reachingDefs).foreach { b => - if binOp.arg2.variables.exists { v => v.sharedVariable } then { - Logger.debug("Shared stack object: " + b) - Logger.debug("Shared in: " + expr) - val regions = mmm.findSharedStackObject(b.value) - Logger.debug("found: " + regions) - res ++= regions - } else { - val region = mmm.findStackObject(b.value) - if (region.isDefined) { - res = res + region.get - } + def visit(node: CFGPosition, arg: Unit): Unit = { + node match { + case directCall: DirectCall if directCall.target.name == "malloc" => + // X = alloc P: [[X]] = ↑[[alloc-i]] + val alloc = mmm.nodeToRegion(directCall).head + val defs = getDefinition(mallocVariable, directCall, reachingDefs) + unify(IdentifierVariable(RegisterWrapperEqualSets(mallocVariable, defs)), PointerRef(AllocVariable(alloc))) + case assign: LocalAssign => + // TODO: unsound + val unwrapped = unwrapExprToVar(assign.rhs) + if (unwrapped.isDefined) { + // X1 = X2: [[X1]] = [[X2]] + val X1 = assign.lhs + val X2 = unwrapped.get + unify(IdentifierVariable(RegisterWrapperEqualSets(X1, getDefinition(X1, assign, reachingDefs))), IdentifierVariable(RegisterWrapperEqualSets(X2, getUse(X2, assign, reachingDefs)))) + } else { + // X1 = *X2: [[X2]] = ↑a ^ [[X1]] = a where a is a fresh term variable + val X1 = assign.lhs + val X2_star = mmm.nodeToRegion(node) + val alpha = FreshVariable() + X2_star.foreach { x => + unify(PointerRef(alpha), ExpressionVariable(x)) } + unify(IdentifierVariable(RegisterWrapperEqualSets(X1, getDefinition(X1, assign, reachingDefs))), alpha) } - res - case binaryExpr: BinaryExpr => - res ++= reducibleToRegion(binaryExpr, n) - res - case v: Variable if v == stackPointer => - res ++= mmm.findStackObject(0) - res - case v: Variable => - evaluateExpressionWithSSA(expr, constantProp(n), n, reachingDefs).foreach { b => - Logger.debug("BitVecLiteral: " + b) - val region = mmm.findDataObject(b.value) - if (region.isDefined) { - res += region.get + case memoryStore: MemoryStore => + // *X1 = X2: [[X1]] = ↑a ^ [[X2]] = a where a is a fresh term variable + val X1_star = mmm.nodeToRegion(node) + // TODO: This is not sound + val unwrapped = unwrapExprToVar(memoryStore.value) + if (unwrapped.isDefined) { + val X2 = unwrapped.get + val X2_regions: Set[MemoryRegion] = vsaApproximation(X2, node) + + val alpha = FreshVariable() + val pointerRef = PointerRef(alpha) + X1_star.foreach { x => + unify(ExpressionVariable(x), pointerRef) } - } - if (res.isEmpty) { // may be passed as param - val ctx = getUse(v, n, reachingDefs) - for (i <- ctx) { - i.rhs match { - case load: MemoryLoad => // treat as a region - res ++= exprToRegion(load.index, i) - case binaryExpr: BinaryExpr => - res ++= reducibleToRegion(binaryExpr, i) - res ++= exprToRegion(i.rhs, i) - case _ => // also treat as a region (for now) even if just Base + Offset without memLoad - res ++= exprToRegion(i.rhs, i) - } + X2_regions.foreach { x => + unify(ExpressionVariable(x), alpha) } } - res - case _ => - evaluateExpressionWithSSA(expr, constantProp(n), n, reachingDefs).foreach { b => - Logger.debug("BitVecLiteral: " + b) - val region = mmm.findDataObject(b.value) - if (region.isDefined) { - res += region.get + case memoryLoad: MemoryLoad => + // TODO: unsound + val unwrapped = unwrapExprToVar(memoryLoad.index) + if (unwrapped.isDefined) { + // X1 = X2: [[X1]] = [[X2]] + val X1 = memoryLoad.lhs + val X2 = unwrapped.get + unify(IdentifierVariable(RegisterWrapperEqualSets(X1, getDefinition(X1, memoryLoad, reachingDefs))), IdentifierVariable(RegisterWrapperEqualSets(X2, getUse(X2, memoryLoad, reachingDefs)))) + } else { + // X1 = *X2: [[X2]] = ↑a ^ [[X1]] = a where a is a fresh term variable + val X1 = memoryLoad.lhs + val X2_star = mmm.nodeToRegion(node) + val alpha = FreshVariable() + X2_star.foreach { x => + unify(PointerRef(alpha), ExpressionVariable(x)) } + unify(IdentifierVariable(RegisterWrapperEqualSets(X1, getDefinition(X1, memoryLoad, reachingDefs))), alpha) } - res - } - } - /** @inheritdoc - */ - def analyze(): Unit = - // generate the constraints by traversing the AST and solve them on-the-fly - program.procedures.foreach(p => { - p.blocks.foreach(b => b.statements.foreach(visit(_, ()))) - }) - - /** Generates the constraints for the given sub-AST. - * @param node - * the node for which it generates the constraints - * @param arg - * unused for this visitor - */ - def visit(cmd: Command, arg: Unit): Unit = { - - cmd match { - case directCall: DirectCall => - // X = alloc P: [[X]] = ↑[[alloc-i]] - if (directCall.target.name == "malloc") { - val alloc = HeapRegion(nextMallocCount(), BitVecLiteral(BigInt(0), 0), IRWalk.procedure(cmd)) - unify(IdentifierVariable(RegisterVariableWrapper(mallocVariable, getUse(mallocVariable, cmd, reachingDefs))), PointerRef(AllocVariable(alloc))) - } - - case assign: Assign => - assign.rhs match { - case binOp: BinaryExpr => - // X1 = &X2: [[X1]] = ↑[[X2]] - exprToRegion(binOp, cmd).foreach( - x => unify(IdentifierVariable(RegisterVariableWrapper(assign.lhs, getDefinition(assign.lhs, cmd, reachingDefs))), PointerRef(AllocVariable(x))) - ) - // TODO: should lookout for global base + offset case as well - case _ => - unwrapExpr(assign.rhs).foreach { - case memoryLoad: MemoryLoad => - // X1 = *X2: [[X2]] = ↑a ^ [[X1]] = a where a is a fresh term variable - val X1 = assign.lhs - val X2_star = exprToRegion(memoryLoad.index, cmd) - val alpha = FreshVariable() - X2_star.foreach( - x => unify(ExpressionVariable(x), PointerRef(alpha)) - ) - unify(alpha, IdentifierVariable(RegisterVariableWrapper(X1, getDefinition(X1, cmd, reachingDefs)))) - - Logger.debug("Memory load: " + memoryLoad) - Logger.debug("Index: " + memoryLoad.index) - Logger.debug("X2_star: " + X2_star) - Logger.debug("X1: " + X1) - Logger.debug("Assign: " + assign) - - // TODO: This might not be correct for globals - // X1 = &X: [[X1]] = ↑[[X2]] (but for globals) - val $X2 = exprToRegion(memoryLoad.index, cmd) - $X2.foreach( - x => unify(IdentifierVariable(RegisterVariableWrapper(assign.lhs, getDefinition(assign.lhs, cmd, reachingDefs))), PointerRef(AllocVariable(x))) - ) - case variable: Variable => - // X1 = X2: [[X1]] = [[X2]] - val X1 = assign.lhs - val X2 = variable - unify(IdentifierVariable(RegisterVariableWrapper(X1, getDefinition(X1, cmd, reachingDefs))), IdentifierVariable(RegisterVariableWrapper(X2, getUse(X2, cmd, reachingDefs)))) - case _ => // do nothing - } - } - case memoryAssign: MemoryAssign => - // *X1 = X2: [[X1]] = ↑a ^ [[X2]] = a where a is a fresh term variable - val X1_star = exprToRegion(memoryAssign.index, cmd) - val X2 = evaluateExpressionWithSSA(memoryAssign.value, constantProp(cmd), cmd, reachingDefs) - // TODO: This is risky as it tries to coerce every value to a region (needed for functionpointer example) - val possibleRegions = exprToRegion(memoryAssign.value, cmd) - - Logger.debug("I am at stmt: " + cmd.label) - Logger.debug("Memory assign: " + memoryAssign) - Logger.debug("X2 is: " + X2) - Logger.debug("PossibleRegions instead of X2 " + possibleRegions) - Logger.debug("Evaluated: " + memoryAssign.value) - Logger.debug("Region " + X1_star) - Logger.debug("Index " + memoryAssign.index) - val alpha = FreshVariable() - X1_star.foreach(x => - unify(ExpressionVariable(x), PointerRef(alpha)) - if (!memoryRegionContents.contains(x)) { - memoryRegionContents.addOne(x -> mutable.Set()) - } - memoryRegionContents(x).addAll(X2) - memoryRegionContents(x).addAll(possibleRegions.filter(r => r != x)) - ) - X2.foreach(x => unify(alpha, ExpressionVariable(x))) - possibleRegions.foreach(x => unify(alpha, ExpressionVariable(x))) - case _ => // do nothing TODO: Maybe LocalVar too? - } + case _ => // do nothing TODO: Maybe LocalVar too? } + } private def unify(t1: Term[StTerm], t2: Term[StTerm]): Unit = { //Logger.info(s"univfying constraint $t1 = $t2\n") @@ -345,35 +148,25 @@ class InterprocSteensgaardAnalysis( } /** @inheritdoc - */ - def pointsTo(): Map[RegisterVariableWrapper, Set[RegisterVariableWrapper | MemoryRegion]] = { + */ + def pointsTo(): Map[RegisterWrapperEqualSets, Set[RegisterWrapperEqualSets | MemoryRegion]] = { val solution = solver.solution() val unifications = solver.unifications() Logger.debug(s"Solution: \n${solution.mkString(",\n")}\n") Logger.debug(s"Sets: \n${unifications.values.map { s => s"{ ${s.mkString(",")} }"}.mkString(", ")}") val vars = solution.keys.collect { case id: IdentifierVariable => id } - val emptyMap = Map[RegisterVariableWrapper, Set[RegisterVariableWrapper | MemoryRegion]]() + val emptyMap = Map[RegisterWrapperEqualSets, Set[RegisterWrapperEqualSets | MemoryRegion]]() val pointsto = vars.foldLeft(emptyMap) { (a, v: IdentifierVariable) => - val pt: Set[RegisterVariableWrapper | MemoryRegion] = unifications(solution(v)).collect { + val pt: Set[RegisterWrapperEqualSets | MemoryRegion] = unifications(solution(v)).collect { case PointerRef(IdentifierVariable(id)) => id case PointerRef(AllocVariable(alloc)) => alloc }.toSet a + (v.id -> pt) } - Logger.debug(s"\nPoints-to:\n${pointsto.map(p => s"${p._1} -> { ${p._2.mkString(",")} }").mkString("\n")}\n") + Logger.debug(s"\nPoints-to:\n${pointsto.map((k, v) => s"$k -> { ${v.mkString(",")} }").mkString("\n")}\n") pointsto } - - /** @inheritdoc - */ - def mayAlias(): (RegisterVariableWrapper, RegisterVariableWrapper) => Boolean = { - val solution = solver.solution() - (id1: RegisterVariableWrapper, id2: RegisterVariableWrapper) => - val sol1 = solution(IdentifierVariable(id1)) - val sol2 = solution(IdentifierVariable(id2)) - sol1 == sol2 && sol1.isInstanceOf[PointerRef] // same equivalence class, and it contains a reference - } } /** Terms used in unification. @@ -388,14 +181,14 @@ case class AllocVariable(alloc: MemoryRegion) extends StTerm with Var[StTerm] { } /** A term variable that represents an identifier in the program. - */ -case class IdentifierVariable(id: RegisterVariableWrapper) extends StTerm with Var[StTerm] { + */ +case class IdentifierVariable(id: RegisterWrapperEqualSets) extends StTerm with Var[StTerm] { override def toString: String = s"$id" } /** A term variable that represents an expression in the program. - */ + */ case class ExpressionVariable(expr: MemoryRegion | Expr) extends StTerm with Var[StTerm] { override def toString: String = s"$expr" @@ -403,13 +196,22 @@ case class ExpressionVariable(expr: MemoryRegion | Expr) extends StTerm with Var /** A fresh term variable. */ -case class FreshVariable(var id: Int = 0) extends StTerm with Var[StTerm] { +case class FreshVariable(id: Int) extends StTerm with Var[StTerm] { + override def toString: String = s"x$id" +} - id = Fresh.next() +object FreshVariable { + private var n = 0 - override def toString: String = s"x$id" + def next(): Int = { + n += 1 + n + } + + def apply(): FreshVariable = FreshVariable(next()) } + /** A constructor term that represents a pointer to another term. */ case class PointerRef(of: Term[StTerm]) extends StTerm with Cons[StTerm] { @@ -420,15 +222,3 @@ case class PointerRef(of: Term[StTerm]) extends StTerm with Cons[StTerm] { override def toString: String = s"$of" } - -/** Counter for producing fresh IDs. - */ -object Fresh { - - var n = 0 - - def next(): Int = { - n += 1 - n - } -} diff --git a/src/main/scala/analysis/IntraLiveVarsAnalysis.scala b/src/main/scala/analysis/IntraLiveVarsAnalysis.scala index f17d91590..46015d9a8 100644 --- a/src/main/scala/analysis/IntraLiveVarsAnalysis.scala +++ b/src/main/scala/analysis/IntraLiveVarsAnalysis.scala @@ -1,29 +1,32 @@ package analysis import analysis.solvers.SimpleWorklistFixpointSolver -import ir.{Assert, Assume, Block, CFGPosition, Call, DirectCall, GoTo, IndirectCall, Jump, Assign, MemoryAssign, NOP, Procedure, Program, Statement, Variable, Return, Unreachable} +import ir.* -abstract class LivenessAnalysis(program: Program) extends Analysis[Any]: +abstract class LivenessAnalysis(program: Program) extends Analysis[Any] { val lattice: MapLattice[CFGPosition, Set[Variable], PowersetLattice[Variable]] = MapLattice(PowersetLattice()) val domain: Set[CFGPosition] = Set.empty ++ program def transfer(n: CFGPosition, s: Set[Variable]): Set[Variable] = { n match { - case p: Procedure => s - case b: Block => s - case a : Assign => (s - a.lhs) ++ a.rhs.variables - case m: MemoryAssign => s ++ m.index.variables ++ m.value.variables - case a : Assume => s ++ a.body.variables - case a : Assert => s ++ a.body.variables - case i : IndirectCall => s + i.target - case c: DirectCall => (s -- c.outParams.map(_._2)) ++ c.actualParams.flatMap(_._2.variables) - case g: GoTo => s - case r: Return => s ++ r.outParams.flatMap(_._2.variables) - case r: Unreachable => s + case p: Procedure => s + case b: Block => s + case a: LocalAssign => (s - a.lhs) ++ a.rhs.variables + case m: MemoryStore => s ++ m.index.variables ++ m.value.variables + case m: MemoryLoad => (s - m.lhs) ++ m.index.variables + case a: Assume => s ++ a.body.variables + case a: Assert => s ++ a.body.variables + case i: IndirectCall => s + i.target + case c: DirectCall => (s -- c.outParams.map(_._2)) ++ c.actualParams.flatMap(_._2.variables) + case g: GoTo => s + case r: Return => s ++ r.outParams.flatMap(_._2.variables) + case r: Unreachable => s + case n: NOP => s } } +} class IntraLiveVarsAnalysis(program: Program) - extends LivenessAnalysis(program) + extends LivenessAnalysis(program) with SimpleWorklistFixpointSolver[CFGPosition, Set[Variable], PowersetLattice[Variable]] with IRIntraproceduralBackwardDependencies diff --git a/src/main/scala/analysis/MemoryModelMap.scala b/src/main/scala/analysis/MemoryModelMap.scala index d91340d5b..0df82014c 100644 --- a/src/main/scala/analysis/MemoryModelMap.scala +++ b/src/main/scala/analysis/MemoryModelMap.scala @@ -4,40 +4,68 @@ import analysis.* import ir.* import util.Logger +import scala.collection.immutable.TreeMap import scala.collection.mutable // Define a case class to represent a range case class RangeKey(start: BigInt, end: BigInt) extends Ordered[RangeKey]: - val size: BigInt = end - start + val size: BigInt = end - start + 1 override def compare(that: RangeKey): Int = { if (start < that.start) -1 else if (start > that.start) 1 else 0 } - override def toString: String = s"Range[$start, $end]" - + override def toString: String = s"Range[$start, $end] (size: $size)" // Custom data structure for storing range-to-object mappings -class MemoryModelMap { - private val MAX_BIGINT: BigInt = BigInt(Long.MaxValue) - private val contextStack = mutable.Stack.empty[List[StackRegion]] +class MemoryModelMap(val globalOffsets: Map[BigInt, BigInt]) { + private val contextStack = mutable.Stack.empty[String] private val sharedContextStack = mutable.Stack.empty[List[StackRegion]] - private val localStacks = mutable.Map[String, List[StackRegion]]() + private val localStacks = mutable.Map[String, List[StackRegion]]().withDefaultValue(List.empty) private val sharedStacks = mutable.Map[String, List[StackRegion]]() private val stackMap: mutable.Map[RangeKey, StackRegion] = mutable.TreeMap() + private val bufferedStackMap: mutable.Map[String, mutable.Map[RangeKey, StackRegion]] = mutable.Map() private val sharedStackMap: mutable.Map[Procedure, mutable.TreeMap[RangeKey, StackRegion]] = mutable.Map[Procedure, mutable.TreeMap[RangeKey, StackRegion]]() + private val bufferedSharedStackMap: mutable.Map[String, mutable.Map[Procedure, mutable.TreeMap[RangeKey, StackRegion]]] = mutable.Map() private val heapMap: mutable.Map[RangeKey, HeapRegion] = mutable.TreeMap() private val dataMap: mutable.Map[RangeKey, DataRegion] = mutable.TreeMap() + private val cfgPositionToDataRegion: mutable.Map[CFGPosition, Set[DataRegion]] = mutable.Map() + private val heapCalls: mutable.Map[DirectCall, HeapRegion] = mutable.Map() + private var relocatedAddressesMap: Map[BigInt, DataRegion] = Map() + + private val stackAllocationSites: mutable.Map[CFGPosition, Set[StackRegion]] = mutable.Map() + + private val uf = UnionFind() + val relfContent: mutable.Map[DataRegion, mutable.Set[String]] = mutable.Map() + val stackSubAccesses: mutable.Map[StackRegion, mutable.Set[BigInt]] = mutable.Map() /** Add a range and object to the mapping * - * @param offset the offset of the range + * @param offset the offset of the range, if a heap region is given, the offsets controls the shift of regions from the start * @param region the region to add * @param shared if the region is shared. When true, the region is added to the sharedStackMap * otherwise to the stackMap */ def add(offset: BigInt, region: MemoryRegion, shared: Boolean = false): Unit = { + def maxSize(r: MemoryRegion): BigInt = { + r match { + case DataRegion(_, start, size) => start + size + case _: HeapRegion => ??? + case s: StackRegion => + if (stackSubAccesses.contains(s) && stackSubAccesses(s).nonEmpty) { + s.start + stackSubAccesses(s).max + } else { + ??? + } + case _ => ??? + } + } + + def regionsOverlap(r1: RangeKey, r2: RangeKey): Boolean = { + r1.start <= r2.end && r2.start <= r1.end + } + region match { case s: StackRegion => var currentStackMap = stackMap @@ -45,132 +73,142 @@ class MemoryModelMap { currentStackMap = sharedStackMap.getOrElseUpdate(s.parent, mutable.TreeMap()) } if (currentStackMap.isEmpty) { - currentStackMap(RangeKey(offset, MAX_BIGINT)) = s + currentStackMap(RangeKey(offset, maxSize(region) - 1)) = s } else { val currentMaxRange = currentStackMap.keys.maxBy(_.end) val currentMaxRegion = currentStackMap(currentMaxRange) - currentStackMap.remove(currentMaxRange) - val updatedRange = RangeKey(currentMaxRange.start, offset - 1) - currentStackMap.addOne(updatedRange -> currentMaxRegion) - currentStackMap(RangeKey(offset, MAX_BIGINT)) = s + if (offset <= currentMaxRange.end) { + currentStackMap.remove(currentMaxRange) + val updatedRange = RangeKey(currentMaxRange.start, (maxSize(region) - 1).max(currentMaxRange.end)) + currentStackMap.addOne(updatedRange -> currentMaxRegion) + } else { + currentStackMap(RangeKey(offset, maxSize(region) - 1)) = s + } } case d: DataRegion => val currentDataMap = dataMap if (currentDataMap.isEmpty) { - currentDataMap(RangeKey(offset, MAX_BIGINT)) = d + currentDataMap(RangeKey(offset, maxSize(d) - 1)) = d } else { val currentMaxRange = currentDataMap.keys.maxBy(_.end) - val currentMaxRegion = currentDataMap(currentMaxRange) - currentDataMap.remove(currentMaxRange) - val updatedRange = RangeKey(currentMaxRange.start, offset - 1) - currentDataMap.addOne(updatedRange -> currentMaxRegion) - currentDataMap(RangeKey(offset, MAX_BIGINT)) = d + if (regionsOverlap(currentMaxRange, RangeKey(offset, maxSize(d) - 1))) { + currentDataMap.remove(currentMaxRange) // TODO: this removes previously overlapping parent region (jumptable2 example) which favours more fine grained regions + currentDataMap(RangeKey(offset, maxSize(d) - 1)) = d + } else { + currentDataMap(RangeKey(offset, maxSize(d) - 1)) = d + } + } + case h: HeapRegion => + val currentHeapMap = heapMap + if (currentHeapMap.isEmpty) { + currentHeapMap(RangeKey(offset, offset + h.size - 1)) = h + } else { + val currentMaxRange = currentHeapMap.keys.maxBy(_.end) + currentHeapMap(RangeKey(currentMaxRange.start + 1, h.size - 1)) = h } } } - /** - * For DataRegions, the actual address used needs to be converted to the relocated address. - * This is because when regions are found, the relocated address is used and as such match - * the correct range. - * - * @param name - * @param address - * @param globalOffsets - * @return DataRegion: a DataRegion representing the actual address - */ - private def resolveInverseGlobalOffset(name: String, address: BitVecLiteral, globalOffsets: Map[BigInt, BigInt]): DataRegion = { - val inverseGlobalOffsets = globalOffsets.map(_.swap) - var tableAddress = inverseGlobalOffsets.getOrElse(address.value, address.value) - // addresses may be layered as in jumptable2 example for which recursive search is required - var exitLoop = false - while (inverseGlobalOffsets.contains(tableAddress) && !exitLoop) { - val newAddress = inverseGlobalOffsets.getOrElse(tableAddress, tableAddress) - if (newAddress == tableAddress) { - exitLoop = true - } else { - tableAddress = newAddress - } + private var relocCount: Int = 0 + private def nextRelocCount() = { + relocCount += 1 + s"reloc_$relocCount" + } + + // size of pointer is 8 bytes + private val SIZE_OF_POINTER = 8 + + def preLoadGlobals(externalFunctions: Map[BigInt, String], globalAddresses: Map[BigInt, String], globalSizes: Map[String, Int]): Unit = { + val relocRegions = globalOffsets.keys.map(offset => DataRegion(nextRelocCount(), offset, SIZE_OF_POINTER)) + + // map externalFunctions name, value to DataRegion(name, value) and then sort by value + val filteredGlobalOffsets = globalAddresses.filterNot((offset, _) => externalFunctions.contains(offset)) + + val externalFunctionRgns = (externalFunctions ++ filteredGlobalOffsets).map((offset, name) => DataRegion(name, offset, (globalSizes.getOrElse(name, 1).toDouble / 8).ceil.toInt)) + + // add externalFunctionRgn to dataRgns and sort by value + val allDataRgns = (externalFunctionRgns ++ relocRegions).toList.sortBy(_.start) + for (dataRgn <- allDataRgns) { + add(dataRgn.start, dataRgn) } - DataRegion(name, BitVecLiteral(tableAddress, 64)) + // cannot fail to find any regions here + relocatedAddressesMap = globalOffsets.map { (offset, offset2) => + (offset, findDataObject(offset2).get) + } } - /** - * Get the mapping of procedures to memory regions - * Gets the regions from each CFGPosition and maps them to the corresponding procedure based on the - * parent field of the StackRegion - * No shared regions here - * @param memoryRegions - * @return - */ - def getProceduresToRegionsMapping(memoryRegions: Map[CFGPosition, LiftedElement[Set[MemoryRegion]]]): mutable.Map[Procedure, mutable.Set[MemoryRegion]] = { - val procedureToRegions = mutable.Map[Procedure, mutable.Set[MemoryRegion]]() - for ((position, regions) <- memoryRegions) { - regions match { - case Lift(node) => - for (region <- node) { - region match { - case stackRegion: StackRegion => - val procedure = stackRegion.parent - if (!procedureToRegions.contains(procedure)) { - procedureToRegions(procedure) = mutable.Set() - } - procedureToRegions(procedure) += stackRegion - case heapRegion: HeapRegion => - val procedure = heapRegion.parent - if (!procedureToRegions.contains(procedure)) { - procedureToRegions(procedure) = mutable.Set() - } - procedureToRegions(procedure) += heapRegion - case _ => - } - } - case LiftedBottom => - } + def relocatedDataRegion(value: BigInt): Option[DataRegion] = { + relocatedAddressesMap.get(value) + } + + def convertMemoryRegions(stackRegionsPerProcedure: mutable.Map[Procedure, mutable.Set[StackRegion]], + heapRegions: mutable.Map[DirectCall, HeapRegion], + allocationSites: Map[CFGPosition, Set[StackRegion]], + procedureToSharedRegions: mutable.Map[Procedure, mutable.Set[MemoryRegion]], + graRegions: mutable.HashMap[BigInt, DataRegion], + graResults: Map[CFGPosition, Set[DataRegion]]): Unit = { + //val keepData = dataMap.filterNot((range, region) => graRegions.contains(region.start)).map((range, region) => region) + val oldRegions = dataMap.values.toSet + dataMap.clear() + for (dr <- graRegions.values) { + add(dr.start, dr) } - // make sure all procedures have results otherwise make them empty - memoryRegions.keys.collect {case procedure: Procedure => procedure}.foreach(procedure => { - if (!procedureToRegions.contains(procedure)) { - procedureToRegions(procedure) = mutable.Set() + for (dr <- oldRegions) { + val obj = findDataObject(dr.start) + if (obj.isEmpty) { + Logger.debug(s"Data region $dr not found in the new data map") + } else { + val isRelocated = relocatedDataRegion(dr.start) + if (isRelocated.isDefined) { + relfContent(obj.get) = relfContent.getOrElse(obj.get, mutable.Set()) += isRelocated.get.regionIdentifier + } else { + relfContent(obj.get) = relfContent.getOrElse(obj.get, mutable.Set()) += dr.regionIdentifier + } } - }) - procedureToRegions - } + } - def convertMemoryRegions(memoryRegions: Map[CFGPosition, LiftedElement[Set[MemoryRegion]]], externalFunctions: Map[BigInt, String], globalOffsets: Map[BigInt, BigInt], procedureToSharedRegions: mutable.Map[Procedure, mutable.Set[MemoryRegion]]): Unit = { - // map externalFunctions name, value to DataRegion(name, value) and then sort by value - val externalFunctionRgns = externalFunctions.map((offset, name) => resolveInverseGlobalOffset(name, BitVecLiteral(offset, 64), globalOffsets)) - - // we should collect all data regions otherwise the ordering might be wrong - var dataRgns: Set[DataRegion] = Set.empty - // get all function exit node - val regionsPerProcedure = getProceduresToRegionsMapping(memoryRegions) - val exitNodes = regionsPerProcedure.keys.collect { case procedure: Procedure => procedure } - - exitNodes.foreach(exitNode => - if (procedureToSharedRegions.contains(exitNode)) { - val sharedRegions = procedureToSharedRegions(exitNode) - sharedStacks(exitNode.name) = sharedRegions.collect { case r: StackRegion => r }.toList.sortBy(_.start.value) + cfgPositionToDataRegion ++= graResults + stackAllocationSites ++= allocationSites + stackRegionsPerProcedure.keys.foreach { proc => + if (procedureToSharedRegions.contains(proc)) { + val sharedRegions = procedureToSharedRegions(proc) + sharedStacks(proc.name) = sharedRegions.collect { case r: StackRegion => r }.toList.sortBy(_.start) } // for each function exit node we get the memory region and add it to the mapping - val stackRgns = regionsPerProcedure(exitNode).collect { case r: StackRegion => r }.toList.sortBy(_.start.value) - dataRgns = dataRgns ++ regionsPerProcedure(exitNode).collect { case r: DataRegion => r } + val stackRgns = stackRegionsPerProcedure(proc).toList.sortBy(_.start) + localStacks(proc.name) = stackRgns + } - localStacks(exitNode.name) = stackRgns - ) - // add externalFunctionRgn to dataRgns and sort by value - val allDataRgns = (dataRgns ++ externalFunctionRgns).toList.sortBy(_.start.value) - for (dataRgn <- allDataRgns) { - add(dataRgn.start.value, dataRgn) + heapCalls ++= heapRegions + // add heap regions + val rangeStart = 0 + for (heapRegion <- heapRegions.values) { + add(rangeStart, heapRegion) + } + + /* this is done because the stack regions will change after MMM transforms them + and merges some of them based on size, thus we need to alter the results of + the analysis to match MMM transformations + TODO: Can this be done directly in MRA? + */ + for ((n, stacks) <- stackAllocationSites) { + pushContext(IRWalk.procedure(n).name) + stackAllocationSites(n) = stacks.map(r => findStackObject(r.start).getOrElse(r)) + pushContext(IRWalk.procedure(n).name) } } - // TODO: push and pop could be optimised by caching the results + def pushContext(funName: String): Unit = { - contextStack.push(localStacks(funName)) + contextStack.push(funName) stackMap.clear() - for (stackRgn <- contextStack.top) { - add(stackRgn.start.value, stackRgn) + if (bufferedStackMap.contains(funName)) { + stackMap ++= bufferedStackMap(funName) + } else { + for (stackRgn <- localStacks(contextStack.top).sortBy(_.start)) { + add(stackRgn.start, stackRgn) + } + bufferedStackMap(funName) = stackMap.clone() } if (!sharedStacks.contains(funName)) { @@ -178,8 +216,13 @@ class MemoryModelMap { } sharedContextStack.push(sharedStacks(funName)) sharedStackMap.clear() - for (stackRgn <- sharedContextStack.top) { - add(stackRgn.start.value, stackRgn, true) + if (bufferedSharedStackMap.contains(funName)) { + sharedStackMap ++= bufferedSharedStackMap(funName) + } else { + for (stackRgn <- sharedContextStack.top.sortBy(_.start)) { + add(stackRgn.start, stackRgn, true) + } + bufferedSharedStackMap(funName) = sharedStackMap.clone() } } @@ -187,29 +230,48 @@ class MemoryModelMap { if (contextStack.size > 1) { contextStack.pop() stackMap.clear() - for (stackRgn <- contextStack.top) { - add(stackRgn.start.value, stackRgn) + if (bufferedStackMap.contains(contextStack.top)) { + stackMap ++= bufferedStackMap(contextStack.top) + } else { + for (stackRgn <- localStacks(contextStack.top)) { + add(stackRgn.start, stackRgn) + } } } if (sharedContextStack.size > 1) { sharedContextStack.pop() sharedStackMap.clear() - for (stackRgn <- sharedContextStack.top) { - add(stackRgn.start.value, stackRgn, true) + if (bufferedSharedStackMap.contains(contextStack.top)) { + sharedStackMap ++= bufferedSharedStackMap(contextStack.top) + } else { + for (stackRgn <- sharedContextStack.top) { + add(stackRgn.start, stackRgn, true) + } } } } - def findStackObject(value: BigInt): Option[StackRegion] = - stackMap.find((range, _) => range.start <= value && value <= range.end).map((range, obj) => obj) + stackMap.find((range, _) => range.start <= value && value <= range.end).map((range, obj) => returnRegion(obj)) def findSharedStackObject(value: BigInt): Set[StackRegion] = - sharedStackMap.values.flatMap(_.find((range, _) => range.start <= value && value <= range.end).map((range, obj) => obj)).toSet + sharedStackMap.values.flatMap(_.find((range, _) => range.start <= value && value <= range.end).map((range, obj) => returnRegion(obj))).toSet + + def findDataObject(value: BigInt): Option[DataRegion] = + dataMap.find((range, _) => range.start <= value && value <= range.end).map((range, obj) => returnRegion(obj)) - def findDataObject(value: BigInt): Option[DataRegion] = - dataMap.find((range, _) => range.start <= value && value <= range.end).map((range, obj) => obj) + def findDataObjectWithSize(value: BigInt, size: BigInt): (Set[DataRegion], Set[DataRegion]) = + // get regions that are between value and value + size and put partial regions (if part of the regions is between value and value + size) in a separate set + dataMap.foldLeft((Set.empty[DataRegion], Set.empty[DataRegion])) { case ((fullRegions, partialRegions), (range, region)) => + if (range.start >= value && range.end <= value + size - 1) { + (fullRegions + returnRegion(region), partialRegions) + } else if ((range.start < value && range.end >= value) || (range.start <= value + size - 1 && range.end > value + size - 1)) { + (fullRegions, partialRegions + returnRegion(region)) + } else { + (fullRegions, partialRegions) + } + } override def toString: String = s"Stack: $stackMap\n Heap: $heapMap\n Data: $dataMap\n" @@ -245,6 +307,25 @@ class MemoryModelMap { logRegion(range, region, true) } } + Logger.debug("Stack Union-Find Roots:") + for name <- localStacks.keys do + popContext() + pushContext(name) + Logger.debug(s" Function: $name") + var parentCount = 0 + // get root regions + for ((range, region) <- stackMap) { + val root = uf.find(region) + if root == region then + logRegion(range, root) + parentCount += 1 + } + if parentCount == 0 then Logger.debug(" No root regions") else Logger.debug(s" Parents: $parentCount/${stackMap.size}") + Logger.debug("Shared Stacks:") + for (name, sharedStacks) <- sharedStacks do + Logger.debug(s" Function: $name") + for region <- sharedStacks do + Logger.debug(s" $region") Logger.debug("Heap:") for ((range, region) <- heapMap) { logRegion(range, region) @@ -254,20 +335,110 @@ class MemoryModelMap { logRegion(range, region) } } + + def mergeRegions(regions: Set[MemoryRegion]): MemoryRegion = { + // assert regions are of the same type + regions.foreach(uf.makeSet) + regions.foreach(uf.union(regions.head, _)) + uf.find(regions.head) + } + + private def returnRegion(region: MemoryRegion): MemoryRegion = { + uf.find(region) + } + + private def returnRegion(region: StackRegion): StackRegion = { + uf.find(region).asInstanceOf[StackRegion] + } + + private def returnRegion(region: DataRegion): DataRegion = { + uf.find(region).asInstanceOf[DataRegion] + } + + private def returnRegion(region: HeapRegion): HeapRegion = { + uf.find(region).asInstanceOf[HeapRegion] + } + + def getHeap(directCall: DirectCall): HeapRegion = { + require(directCall.target.name == "malloc", "Should be a malloc call") + heapCalls(directCall) + } + + def getStack(allocationSite: CFGPosition): Set[StackRegion] = { + stackAllocationSites.getOrElse(allocationSite, Set.empty).map(returnRegion) + } + + def getData(cfgPosition: CFGPosition): Set[DataRegion] = { + cfgPositionToDataRegion.getOrElse(cfgPosition, Set.empty).map(returnRegion) + } + + def nodeToRegion(n: CFGPosition): Set[MemoryRegion] = { + n match { + case directCall: DirectCall => + Set(getHeap(directCall)) + case _ => + getStack(n) ++ getData(n) + } + } } trait MemoryRegion { val regionIdentifier: String + val start: BigInt } -case class StackRegion(override val regionIdentifier: String, start: BitVecLiteral, parent: Procedure) extends MemoryRegion { - override def toString: String = s"Stack($regionIdentifier, $start, ${parent.name})" +case class StackRegion(override val regionIdentifier: String, override val start: BigInt, parent: Procedure) extends MemoryRegion { + override def toString: String = s"Stack($regionIdentifier, $start, ${parent.name}" } -case class HeapRegion(override val regionIdentifier: String, size: BitVecLiteral, parent: Procedure) extends MemoryRegion { +case class HeapRegion(override val regionIdentifier: String, override val start: BigInt, size: BigInt, parent: Procedure) extends MemoryRegion { override def toString: String = s"Heap($regionIdentifier, $size)" } -case class DataRegion(override val regionIdentifier: String, start: BitVecLiteral) extends MemoryRegion { - override def toString: String = s"Data($regionIdentifier, $start)" +case class DataRegion(override val regionIdentifier: String, override val start: BigInt, size: BigInt) extends MemoryRegion { + override def toString: String = s"Data($regionIdentifier, $start, $size)" + val end: BigInt = start + size - 1 } + +class UnionFind { + // Map to store the parent of each region + private val parent: mutable.Map[MemoryRegion, MemoryRegion] = mutable.Map() + + // Map to store the size of each set, used for union by rank + private val size: mutable.Map[MemoryRegion, Int] = mutable.Map() + + // Initialise each region to be its own parent and set size to 1 + def makeSet(region: MemoryRegion): Unit = { + parent(region) = region + size(region) = 1 + } + + // Find operation with path compression + def find(region: MemoryRegion): MemoryRegion = { + if (!parent.contains(region)) { + makeSet(region) + } + + if (parent(region) != region) { + parent(region) = find(parent(region)) // Path compression + } + parent(region) + } + + // Union operation with union by rank + def union(region1: MemoryRegion, region2: MemoryRegion): Unit = { + val root1 = find(region1) + val root2 = find(region2) + + if (root1 != root2) { + if (size(root1) < size(root2)) { + parent(root1) = root2 + size(root2) += size(root1) + } else { + parent(root2) = root1 + size(root1) += size(root2) + } + } + } + +} \ No newline at end of file diff --git a/src/main/scala/analysis/MemoryRegionAnalysis.scala b/src/main/scala/analysis/MemoryRegionAnalysis.scala index 2d1125b68..2cec5dbfa 100644 --- a/src/main/scala/analysis/MemoryRegionAnalysis.scala +++ b/src/main/scala/analysis/MemoryRegionAnalysis.scala @@ -1,6 +1,7 @@ package analysis -import analysis.solvers.WorklistFixpointSolverWithReachability +import ir.eval.BitVectorEval.bv2SignedInt +import analysis.solvers.SimpleWorklistFixpointSolver import ir.* import util.Logger @@ -8,22 +9,25 @@ import scala.collection.mutable import scala.collection.mutable.ListBuffer trait MemoryRegionAnalysis(val program: Program, + val domain: Set[CFGPosition], val globals: Map[BigInt, String], val globalOffsets: Map[BigInt, BigInt], val subroutines: Map[BigInt, String], val constantProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], val ANRResult: Map[CFGPosition, Set[Variable]], val RNAResult: Map[CFGPosition, Set[Variable]], - val regionAccesses: Map[CFGPosition, Map[RegisterVariableWrapper, FlatElement[Expr]]], - reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])]) { + val reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])], + val graResult: Map[CFGPosition, Set[DataRegion]], + val mmm: MemoryModelMap) { - var mallocCount: Int = 0 + private var mallocCount: BigInt = 0 private var stackCount: Int = 0 - val stackMap: mutable.Map[Procedure, mutable.Map[Expr, StackRegion]] = mutable.Map() + val stackMap: mutable.Map[Procedure, mutable.Map[BigInt, StackRegion]] = mutable.Map() - private def nextMallocCount() = { - mallocCount += 1 - s"malloc_$mallocCount" + private def nextMallocCount(size: BigInt) = { + val start = mallocCount + mallocCount += (size.toDouble/8).ceil.toInt + 1 + (s"malloc_$mallocCount", start) } private def nextStackCount() = { @@ -35,152 +39,155 @@ trait MemoryRegionAnalysis(val program: Program, * Controls the pool of stack regions. Each pool is unique to a function. * If the offset has already been defined in the context of the function, then the same region is returned. * - * @param expr : the offset + * @param base : the offset * @param parent : the function entry node * @return the stack region corresponding to the offset */ - private def poolMaster(expr: BitVecLiteral, stackBase: Procedure): StackRegion = { + private def poolMaster(base: BigInt, stackBase: Procedure, subAccess: BigInt): StackRegion = { + assert(subAccess >= 0) val stackPool = stackMap.getOrElseUpdate(stackBase, mutable.HashMap()) - if (stackPool.contains(expr)) { - stackPool(expr) + val region = if (stackPool.contains(base)) { + stackPool(base) } else { - val newRegion = StackRegion(nextStackCount(), expr, stackBase) - stackPool += (expr -> newRegion) + val newRegion = StackRegion(nextStackCount(), base, stackBase) + addReturnStack(stackBase, newRegion) + stackPool += (base -> newRegion) newRegion } + mmm.stackSubAccesses(region) = mmm.stackSubAccesses.getOrElse(region, mutable.Set()) += (subAccess.toDouble/8).ceil.toInt + region } private def stackDetection(stmt: Statement): Unit = { Logger.debug("Stack detection") Logger.debug(spList) stmt match { - case assign: Assign => + case assign: LocalAssign => if (spList.contains(assign.rhs)) { // add lhs to spList spList.addOne(assign.lhs) - } else { + // TODO: This is a hack: it should check for stack ptr using the wrapper + } else if (spList.contains(assign.lhs) && assign.lhs != stackPointer) { // remove lhs from spList - if spList.contains(assign.lhs) && assign.lhs != stackPointer then // TODO: This is a hack: it should check for stack ptr using the wrapper - spList.remove(spList.indexOf(assign.lhs)) + spList.remove(spList.indexOf(assign.lhs)) } // TODO: should handle the store case (last case) case _ => } } - val regionLattice: PowersetLattice[MemoryRegion] = PowersetLattice() + val regionLattice: PowersetLattice[StackRegion] = PowersetLattice() - /** - * Lifted memory region lattice, with new bottom element representing "unreachable". - */ - val liftedLattice: LiftLattice[Set[MemoryRegion], PowersetLattice[MemoryRegion]] = LiftLattice(regionLattice) - - val lattice: MapLattice[CFGPosition, LiftedElement[Set[MemoryRegion]], LiftLattice[Set[MemoryRegion], PowersetLattice[MemoryRegion]]] = MapLattice(liftedLattice) + val lattice: MapLattice[CFGPosition, Set[StackRegion], PowersetLattice[StackRegion]] = MapLattice(regionLattice) - val domain: Set[CFGPosition] = Set.empty ++ program - - val first: Set[CFGPosition] = Set.empty ++ program.procedures + val first: Set[CFGPosition] = Set.empty + program.mainProcedure private val stackPointer = Register("R31", 64) - private val linkRegister = Register("R30", 64) - private val framePointer = Register("R29", 64) private val mallocVariable = Register("R0", 64) private val spList = ListBuffer[Expr](stackPointer) - private val ignoreRegions: Set[Expr] = Set(linkRegister, framePointer) - // TODO: this could be used instead of regionAccesses in other analyses to reduce the Expr to region conversion - private val registerToRegions: mutable.Map[RegisterVariableWrapper, mutable.Set[MemoryRegion]] = mutable.Map() val procedureToSharedRegions: mutable.Map[Procedure, mutable.Set[MemoryRegion]] = mutable.Map() + var procedureToStackRegions: mutable.Map[Procedure, mutable.Set[StackRegion]] = mutable.Map() + var procedureToHeapRegions: mutable.Map[DirectCall, HeapRegion] = mutable.Map() + var mergeRegions: mutable.Set[Set[MemoryRegion]] = mutable.Set() - def reducibleToRegion(binExpr: BinaryExpr, n: Command): Set[MemoryRegion] = { - var reducedRegions = Set.empty[MemoryRegion] - binExpr.arg1 match { - case variable: Variable => - val ctx = getUse(variable, n, reachingDefs) - for (i <- ctx) { - val regions = i.rhs match { - case memoryLoad: MemoryLoad => - eval(memoryLoad.index, Set.empty, i) - case _: BitVecLiteral => - Set.empty - case _ => - eval(i.rhs, Set.empty, i) - } - evaluateExpression(binExpr.arg2, constantProp(n)) match { - case Some(b: BitVecLiteral) => - regions.foreach { - case stackRegion: StackRegion => - val nextOffset = BinaryExpr(binExpr.op, stackRegion.start, b) - evaluateExpression(nextOffset, constantProp(n)) match { - case Some(b2: BitVecLiteral) => - reducedRegions = reducedRegions + poolMaster(b2, IRWalk.procedure(n)) - case None => - } - case _ => - } - case None => - } + def addReturnStack(procedure: Procedure, returnRegion: StackRegion): Unit = { + procedureToStackRegions.getOrElseUpdate(procedure, mutable.Set.empty).add(returnRegion) + } + + def addReturnHeap(directCall: DirectCall, returnRegion: HeapRegion): Unit = { + procedureToHeapRegions.put(directCall, returnRegion) + } + + def reducibleToRegion(binExpr: BinaryExpr, n: Command, subAccess: BigInt): Set[StackRegion] = { + val reducedRegions = binExpr.arg1 match { + case variable: Variable if !spList.contains(variable) => + evaluateExpression(binExpr.arg2, constantProp(n)) match { + case Some(b: BitVecLiteral) => + val ctx = getUse(variable, n, reachingDefs) + val stackRegions = ctx.flatMap { + case l: LocalAssign => eval(l.rhs, l, subAccess) + case m: MemoryLoad => eval(m.index, m, m.size) + } + for (stackRegion <- stackRegions) yield { + val nextOffset = bitVectorOpToBigIntOp(binExpr.op, stackRegion.start, b.value) + poolMaster(nextOffset, IRWalk.procedure(n), subAccess) + } + case None => + Set() } case _ => + eval(binExpr, n, subAccess) } reducedRegions } - def eval(exp: Expr, env: Set[MemoryRegion], n: Command): Set[MemoryRegion] = { - Logger.debug(s"evaluating $exp") - Logger.debug(s"env: $env") - Logger.debug(s"n: $n") - exp match { - case binOp: BinaryExpr => - if (spList.contains(binOp.arg1)) { - evaluateExpression(binOp.arg2, constantProp(n)) match { - case Some(b: BitVecLiteral) => Set(poolMaster(b, IRWalk.procedure(n))) - case None => env - } - } else if (reducibleToRegion(binOp, n).nonEmpty) { - reducibleToRegion(binOp, n) - } else { - evaluateExpression(binOp, constantProp(n)) match { - case Some(b: BitVecLiteral) => eval(b, env, n) - case None => env - } + def reducibleVariable(variable: Variable, n: Command, subAccess: BigInt): Set[StackRegion] = { + val ctx = getDefinition(variable, n, reachingDefs) + + // TODO: nicer way to deal with loops (a variable is being incremented in a loop) + val regions = ctx.flatMap { i => + if (i != n) { + i match { + case l: LocalAssign => eval(l.rhs, l, subAccess) + case m: MemoryLoad => eval(m.index, m, m.size) } - case variable: Variable => - variable match { - case _: LocalVar => - env - case reg: Register if spList.contains(reg) => - eval(BitVecLiteral(0, 64), env, n) - case _ => - evaluateExpression(variable, constantProp(n)) match { + } else { + Set() + } + } + regions + } + + def eval(exp: Expr, n: Command, subAccess: BigInt): Set[StackRegion] = { + if (graResult(n).nonEmpty) { + Set.empty // skip global memory regions + } else { + exp match { + case binOp: BinaryExpr => + if (spList.contains(binOp.arg1)) { + evaluateExpression(binOp.arg2, constantProp(n)) match { case Some(b: BitVecLiteral) => - eval(b, env, n) - case _ => - env // we cannot evaluate this to a concrete value, we need VSA for this + val negB = bv2SignedInt(b) + Set(poolMaster(negB, IRWalk.procedure(n), subAccess)) + case None => Set.empty } - } - case memoryLoad: MemoryLoad => - eval(memoryLoad.index, env, n) - // ignore case where it could be a global region (loaded later in MMM from relf) - case b: BitVecLiteral => - Set(poolMaster(b, IRWalk.procedure(n))) - // we cannot evaluate this to a concrete value, we need VSA for this - case _ => - Logger.debug(s"type: ${exp.getClass} $exp\n") - Set() - // throw new Exception("Unknown type") + } else if (reducibleToRegion(binOp, n, subAccess).nonEmpty) { + reducibleToRegion(binOp, n, subAccess) + } else { + Set.empty + } + case reg: Register if spList.contains(reg) => // TODO: this is a hack because spList is not comprehensive it needs to be a standalone analysis + if (getDefinition(reg, n, reachingDefs).isEmpty) { + Set(poolMaster(Long.MaxValue, IRWalk.procedure(n), subAccess)) + } else { + reducibleVariable(reg, n, subAccess) + } + case variable: Variable => + evaluateExpression(variable, constantProp(n)) match { + case Some(b: BitVecLiteral) => + eval(b, n, subAccess) + case _ => + reducibleVariable(variable, n, subAccess) + } + // ignore case where it could be a global region (loaded later in MMM from relf) + case _: BitVecLiteral => + Set.empty + // we cannot evaluate this to a concrete value, we need VSA for this + case _ => + Logger.debug(s"type: ${exp.getClass} $exp\n") + throw new Exception("Unknown type") + } } } /** Transfer function for state lattice elements. */ - def localTransfer(n: CFGPosition, s: Set[MemoryRegion]): Set[MemoryRegion] = n match { - case cmd: Command => - cmd match { - case directCall: DirectCall => - val ANR = ANRResult(cmd) - val RNA = RNAResult(program.procedures.filter(fn => fn == directCall.target).head) - val parameters = RNA.intersect(ANR) - // TODO: Re-enable when ReachingDef has interprocedural option + def localTransfer(n: CFGPosition, s: Set[StackRegion]): Set[StackRegion] = n match { + case directCall: DirectCall => + // TODO: Re-enable when ReachingDef has interprocedural option + // val ANR = ANRResult(directCall) + // val RNA = RNAResult(program.procedures.filter(fn => fn == directCall.target).head) + // val parameters = RNA.intersect(ANR) // val ctx = regionAccesses(cmd) // for (elem <- parameters) { // if (ctx.contains(RegisterVariableWrapper(elem, getUse(elem, cmd.data, reachingDefs)))) { @@ -194,60 +201,56 @@ trait MemoryRegionAnalysis(val program: Program, // } // } // } - if (directCall.target.name == "malloc") { - evaluateExpression(mallocVariable, constantProp(n)) match { - case Some(b: BitVecLiteral) => regionLattice.lub(s, Set(HeapRegion(nextMallocCount(), b, IRWalk.procedure(n)))) - case None => s - } - } else { + if (directCall.target.name == "malloc") { + evaluateExpression(mallocVariable, constantProp(n)) match { + case Some(b: BitVecLiteral) => + val negB = bv2SignedInt(b) + val (name, start) = nextMallocCount(negB) + val newHeapRegion = HeapRegion(name, start, negB, IRWalk.procedure(n)) + addReturnHeap(directCall, newHeapRegion) s - } - case memAssign: MemoryAssign => - if (ignoreRegions.contains(memAssign.value)) { + case None => + // Assume heap region size is at least 1 TODO: must approximate size of heap + val negB = 1 + val (name, start) = nextMallocCount(negB) + val newHeapRegion = HeapRegion(name, start, negB, IRWalk.procedure(n)) + addReturnHeap(directCall, newHeapRegion) s - } else { - val result = eval(memAssign.index, s, cmd) - regionLattice.lub(s, result) - } - case assign: Assign => - stackDetection(assign) - var m = s - unwrapExpr(assign.rhs).foreach { - case memoryLoad: MemoryLoad => - val result = eval(memoryLoad.index, s, cmd) - m = regionLattice.lub(m, result) - case _ => m - } - m - case _ => s + } + } else { + s } - case _ => s // ignore other kinds of nodes + case memAssign: MemoryStore => + val result = eval(memAssign.index, memAssign, memAssign.size) +// if (result.size > 1) { +// //throw new Exception(s"Memory load resulted in multiple regions ${result} for mem load $memoryLoad") +// addMergableRegions(result) +// } + result + case assign: LocalAssign => + stackDetection(assign) + Set() + case load: MemoryLoad => + eval(load.index, load, load.size) + case _ => s } - def transferUnlifted(n: CFGPosition, s: Set[MemoryRegion]): Set[MemoryRegion] = localTransfer(n, s) + def transfer(n: CFGPosition, s: Set[StackRegion]): Set[StackRegion] = localTransfer(n, s) } class MemoryRegionAnalysisSolver( - program: Program, - globals: Map[BigInt, String], - globalOffsets: Map[BigInt, BigInt], - subroutines: Map[BigInt, String], - constantProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], - ANRResult: Map[CFGPosition, Set[Variable]], - RNAResult: Map[CFGPosition, Set[Variable]], - regionAccesses: Map[CFGPosition, Map[RegisterVariableWrapper, FlatElement[Expr]]], - reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])] - ) extends MemoryRegionAnalysis(program, globals, globalOffsets, subroutines, constantProp, ANRResult, RNAResult, regionAccesses, reachingDefs) + program: Program, + domain: Set[CFGPosition], + globals: Map[BigInt, String], + globalOffsets: Map[BigInt, BigInt], + subroutines: Map[BigInt, String], + constantProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], + ANRResult: Map[CFGPosition, Set[Variable]], + RNAResult: Map[CFGPosition, Set[Variable]], + reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])], + graResult: Map[CFGPosition, Set[DataRegion]], + mmm: MemoryModelMap + ) extends MemoryRegionAnalysis(program, domain, globals, globalOffsets, subroutines, constantProp, ANRResult, RNAResult, reachingDefs, graResult, mmm) with IRIntraproceduralForwardDependencies - with Analysis[Map[CFGPosition, LiftedElement[Set[MemoryRegion]]]] - with WorklistFixpointSolverWithReachability[CFGPosition, Set[MemoryRegion], PowersetLattice[MemoryRegion]] { - - override def funsub(n: CFGPosition, x: Map[CFGPosition, LiftedElement[Set[MemoryRegion]]]): LiftedElement[Set[MemoryRegion]] = { - n match { - // function entry nodes are always reachable as this is intraprocedural - case _: Procedure => liftedLattice.lift(regionLattice.bottom) - // all other nodes are processed with join+transfer - case _ => super.funsub(n, x) - } - } -} + with Analysis[Map[CFGPosition, Set[StackRegion]]] + with SimpleWorklistFixpointSolver[CFGPosition, Set[StackRegion], PowersetLattice[StackRegion]] diff --git a/src/main/scala/analysis/RNA.scala b/src/main/scala/analysis/RNA.scala index b65959222..3dc3e0f7b 100644 --- a/src/main/scala/analysis/RNA.scala +++ b/src/main/scala/analysis/RNA.scala @@ -22,51 +22,47 @@ trait RNAAnalysis(program: Program, ignoreStackPtrs: Boolean = true) { private val linkRegister = Register("R30", 64) private val framePointer = Register("R29", 64) - private val ignoreRegions: Set[Expr] = if (ignoreStackPtrs) then Set(linkRegister, framePointer, stackPointer) else Set() + private val ignoreRegions: Set[Variable] = Set(linkRegister, framePointer, stackPointer) - /** Default implementation of eval. - */ def eval(cmd: Command, s: Set[Variable]): Set[Variable] = { - var m = s cmd match { case assume: Assume => - m.union(assume.body.variables.filter(!ignoreRegions.contains(_))) + s ++ (assume.body.variables -- ignoreRegions) case assert: Assert => - m.union(assert.body.variables.filter(!ignoreRegions.contains(_))) - case memoryAssign: MemoryAssign => - m.union((memoryAssign.index.variables ++ memoryAssign.value.variables).filter(!ignoreRegions.contains(_))) - case indirectCall: IndirectCall => - if (ignoreRegions.contains(indirectCall.target)) return m - m + indirectCall.target + s ++ (assert.body.variables -- ignoreRegions) + case memoryStore: MemoryStore => + s ++ (memoryStore.index.variables -- ignoreRegions) case call: DirectCall=> - (m ++ call.actualParams.flatMap(_._2.variables).toSet.filterNot(ignoreRegions.contains(_))) + (s ++ call.actualParams.flatMap(_._2.variables).toSet.filterNot(ignoreRegions.contains(_))) .diff(call.outParams.map(_._2).toSet) - case assign: Assign => - m = m - assign.lhs - m.union(assign.rhs.variables.filter(!ignoreRegions.contains(_))) + case indirectCall: IndirectCall => + if (ignoreRegions.contains(indirectCall.target)) { + s + } else { + s + indirectCall.target + } + case assign: LocalAssign => + val m = s - assign.lhs + m ++ (assign.rhs.variables -- ignoreRegions) + case memoryLoad: MemoryLoad => + val m = s - memoryLoad.lhs + m ++ (memoryLoad.index.variables -- ignoreRegions) case _ => - m + s } } /** Transfer function for state lattice elements. */ - def localTransfer(n: CFGPosition, s: Set[Variable]): Set[Variable] = n match { + def transfer(n: CFGPosition, s: Set[Variable]): Set[Variable] = n match { case cmd: Command => eval(cmd, s) case _ => s // ignore other kinds of nodes } - /** Transfer function for state lattice elements. - */ - def transfer(n: CFGPosition, s: Set[Variable]): Set[Variable] = localTransfer(n, s) } -class RNAAnalysisSolver( - program: Program, - ignoreStackPtrs: Boolean = true, -) extends RNAAnalysis(program, ignoreStackPtrs) +class RNAAnalysisSolver(program: Program) extends RNAAnalysis(program) with IRIntraproceduralBackwardDependencies with Analysis[Map[CFGPosition, Set[Variable]]] - with SimpleWorklistFixpointSolver[CFGPosition, Set[Variable], PowersetLattice[Variable]] { -} + with SimpleWorklistFixpointSolver[CFGPosition, Set[Variable], PowersetLattice[Variable]] diff --git a/src/main/scala/analysis/ReachingDefinitionsAnalysis.scala b/src/main/scala/analysis/ReachingDefinitionsAnalysis.scala index 975fd72c4..455f4554e 100644 --- a/src/main/scala/analysis/ReachingDefinitionsAnalysis.scala +++ b/src/main/scala/analysis/ReachingDefinitionsAnalysis.scala @@ -3,62 +3,64 @@ package analysis import ir.* import analysis.solvers.SimpleWorklistFixpointSolver -case class ReachingDefinitionsAnalysis(program: Program) { +type TupleElement = + TupleLattice[MapLattice[Variable, Set[Assign], PowersetLattice[Assign]], MapLattice[Variable, Set[Assign], PowersetLattice[Assign]], Map[Variable, Set[Assign]], Map[Variable, Set[Assign]]] - type Definition = Assign // local assign is a definition because it is a statement and statements are assumed to be unique - type TupleElement = - TupleLattice[MapLattice[Variable, Set[Definition], PowersetLattice[Definition]], MapLattice[Variable, Set[Definition], PowersetLattice[Definition]], Map[Variable, Set[Definition]], Map[Variable, Set[Definition]]] +trait ReachingDefinitionsAnalysis(program: Program) { - val tupleLattice: TupleLattice[MapLattice[Variable, Set[Definition], PowersetLattice[Definition]], MapLattice[Variable, Set[Assign], PowersetLattice[ - Assign]], Map[Variable, Set[Definition]], Map[Variable, Set[Definition]]] = - new TupleLattice( - new MapLattice[Variable, Set[Definition], PowersetLattice[Definition]](new PowersetLattice[Definition]()), - new MapLattice[Variable, Set[Definition], PowersetLattice[Definition]](new PowersetLattice[Definition]()) + private val tupleLattice: TupleLattice[MapLattice[Variable, Set[Assign], PowersetLattice[Assign]], MapLattice[Variable, Set[Assign], PowersetLattice[ + Assign]], Map[Variable, Set[Assign]], Map[Variable, Set[Assign]]] = + TupleLattice( + MapLattice[Variable, Set[Assign], PowersetLattice[Assign]](PowersetLattice[Assign]()), + MapLattice[Variable, Set[Assign], PowersetLattice[Assign]](PowersetLattice[Assign]()) ) - val lattice: MapLattice[CFGPosition, (Map[Variable, Set[Definition]], Map[Variable, Set[Definition]]), TupleElement] = MapLattice( + val lattice: MapLattice[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]]), TupleElement] = MapLattice( tupleLattice ) val domain: Set[CFGPosition] = Set.empty ++ program - - def transfer(n: CFGPosition, s: (Map[Variable, Set[Definition]], Map[Variable, Set[Definition]])): (Map[Variable, Set[Definition]], Map[Variable, Set[Definition]]) = - localTransfer(n, s) - - def localTransfer( - n: CFGPosition, - s: (Map[Variable, Set[Definition]], Map[Variable, Set[Definition]]) - ): (Map[Variable, Set[Definition]], Map[Variable, Set[Definition]]) = n match { - case cmd: Command => - eval(cmd, s) - case _ => s + def transfer(n: CFGPosition, s: (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])): (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]]) = { + n match { + case cmd: Command => + eval(cmd, s) + case _ => s + } } - def transformUses(vars: Set[Variable], s: (Map[Variable, Set[Definition]], Map[Variable, Set[Definition]])): (Map[Variable, Set[Definition]], Map[Variable, Set[Definition]]) = { - vars.foldLeft((s._1, Map.empty[Variable, Set[Definition]])) { + private def transformUses(vars: Set[Variable], s: (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])): (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]]) = { + vars.foldLeft((s(0), Map.empty[Variable, Set[Assign]])) { case ((state, acc), v) => (state, acc + (v -> state(v))) } } - def eval(cmd: Command, s: (Map[Variable, Set[Definition]], Map[Variable, Set[Definition]]) - ): (Map[Variable, Set[Definition]], Map[Variable, Set[Definition]]) = cmd match { - case assign: Assign => + def eval(cmd: Command, s: (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])): + (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]]) = cmd match { + case assign: LocalAssign => // do the rhs first (should reset the values for this node to the empty set) // for each variable in the rhs, find the definitions from the lattice lhs and add them to the lattice rhs // for lhs, addOrReplace the definition val rhs = assign.rhs.variables val lhs = assign.lhs - val rhsUseDefs: Map[Variable, Set[Definition]] = rhs.foldLeft(Map.empty[Variable, Set[Definition]]) { + val rhsUseDefs: Map[Variable, Set[Assign]] = rhs.foldLeft(Map.empty[Variable, Set[Assign]]) { case (acc, v) => - acc + (v -> s._1(v)) + acc + (v -> s(0)(v)) } - (s._1 + (lhs -> Set(assign)), rhsUseDefs) + (s(0) + (lhs -> Set(assign)), rhsUseDefs) case assert: Assert => transformUses(assert.body.variables, s) - case memoryAssign: MemoryAssign => - transformUses(memoryAssign.index.variables ++ memoryAssign.value.variables, s) + case memoryStore: MemoryStore => + transformUses(memoryStore.index.variables ++ memoryStore.value.variables, s) + case memoryLoad: MemoryLoad => + val lhs = memoryLoad.lhs + val rhs = memoryLoad.index.variables + val rhsUseDefs: Map[Variable, Set[Assign]] = rhs.foldLeft(Map.empty[Variable, Set[Assign]]) { + case (acc, v) => + acc + (v -> s(0)(v)) + } + (s(0) + (lhs -> Set(memoryLoad)), rhsUseDefs) case assume: Assume => transformUses(assume.body.variables, s) case indirectCall: IndirectCall => @@ -71,7 +73,7 @@ case class ReachingDefinitionsAnalysis(program: Program) { } } -class ReachingDefinitionsAnalysisSolver(program: Program) +class InterprocReachingDefinitionsAnalysisSolver(program: Program) extends ReachingDefinitionsAnalysis(program) - with SimpleWorklistFixpointSolver[CFGPosition, (Map[Variable, Set[ReachingDefinitionsAnalysis#Definition]], Map[Variable, Set[ReachingDefinitionsAnalysis#Definition]]), ReachingDefinitionsAnalysis#TupleElement] - with IRIntraproceduralForwardDependencies + with SimpleWorklistFixpointSolver[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]]), TupleElement] + with IRInterproceduralForwardDependencies diff --git a/src/main/scala/analysis/ReachingDefs.scala b/src/main/scala/analysis/ReachingDefs.scala new file mode 100644 index 000000000..5931f6f3f --- /dev/null +++ b/src/main/scala/analysis/ReachingDefs.scala @@ -0,0 +1,34 @@ +package analysis + +import analysis.solvers.SimplePushDownWorklistFixpointSolver +import ir.{LocalAssign, CFGPosition, DirectCall, IntraProcIRCursor, MemoryLoad, Procedure, Program, Register, Variable, computeDomain} + +abstract class ReachingDefs(program: Program, writesTo: Map[Procedure, Set[Register]]) extends Analysis[Map[CFGPosition, Map[Variable, Set[CFGPosition]]]] { + + val mallocRegister = Register("R0", 64) + val domain: Set[CFGPosition] = computeDomain(IntraProcIRCursor, program.procedures).toSet + val lattice: MapLattice[CFGPosition, Map[Variable, Set[CFGPosition]], MapLattice[Variable, Set[CFGPosition], PowersetLattice[CFGPosition]]] = MapLattice(MapLattice(PowersetLattice[CFGPosition]())) + + def transfer(n: CFGPosition, s: Map[Variable, Set[CFGPosition]]): Map[Variable, Set[CFGPosition]] = { + n match { + case loc: LocalAssign => + s + (loc.lhs -> Set(n)) + case load: MemoryLoad => + s + (load.lhs -> Set(n)) + case DirectCall(target, _, _, _) if target.name == "malloc" => + s + (mallocRegister -> Set(n)) + case DirectCall(target, _, _, _) if writesTo.contains(target) => + val result: Map[Variable, Set[CFGPosition]] = writesTo(target).foldLeft(Map[Variable, Set[CFGPosition]]()) { + (m, register) => + m + (register -> Set(n)) + } + s ++ result + case _ => s + } + } + +} + +class ReachingDefsAnalysis(program: Program, writesTo: Map[Procedure, Set[Register]]) extends ReachingDefs(program, writesTo), IRIntraproceduralForwardDependencies, + SimplePushDownWorklistFixpointSolver[CFGPosition, Map[Variable, Set[CFGPosition]], MapLattice[Variable, Set[CFGPosition], PowersetLattice[CFGPosition]]] + diff --git a/src/main/scala/analysis/RegToMemAnalysis.scala b/src/main/scala/analysis/RegToMemAnalysis.scala deleted file mode 100644 index 1afde6f4d..000000000 --- a/src/main/scala/analysis/RegToMemAnalysis.scala +++ /dev/null @@ -1,72 +0,0 @@ -package analysis - -import ir.{MemoryLoad, *} -import analysis.solvers.* -import util.Logger - -import scala.collection.immutable - -/** - * Collects all the memory loads and the expressions that are assigned to a register but cannot be evaluated. - * - * Tracks: - * R_x = MemoryLoad[Base + Offset] - * R_x = Base + Offset - * - * Both in which constant propagation mark as TOP which is not useful. - */ -trait RegionAccessesAnalysis(program: Program, constantProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])]) { - - val mapLattice: MapLattice[RegisterVariableWrapper, FlatElement[Expr], FlatLattice[Expr]] = MapLattice(FlatLattice[_root_.ir.Expr]()) - - val lattice: MapLattice[CFGPosition, Map[RegisterVariableWrapper, FlatElement[Expr]], MapLattice[RegisterVariableWrapper, FlatElement[Expr], FlatLattice[Expr]]] = MapLattice(mapLattice) - - val domain: Set[CFGPosition] = program.toSet - - val first: Set[CFGPosition] = program.procedures.toSet - - /** Default implementation of eval. - */ - def eval(cmd: Statement, constants: Map[Variable, FlatElement[BitVecLiteral]], s: Map[RegisterVariableWrapper, FlatElement[Expr]]): Map[RegisterVariableWrapper, FlatElement[Expr]] = { - cmd match { - case assign: Assign => - assign.rhs match { - case memoryLoad: MemoryLoad => - s + (RegisterVariableWrapper(assign.lhs, getDefinition(assign.lhs, cmd, reachingDefs)) -> FlatEl(memoryLoad)) - case binaryExpr: BinaryExpr => - if (evaluateExpression(binaryExpr.arg1, constants).isEmpty) { // approximates Base + Offset - Logger.debug(s"Approximating $assign in $binaryExpr") - Logger.debug(s"Reaching defs: ${reachingDefs(cmd)}") - s + (RegisterVariableWrapper(assign.lhs, getDefinition(assign.lhs, cmd, reachingDefs)) -> FlatEl(binaryExpr)) - } else { - s - } - case _ => s - } - case _ => - s - } - } - - /** Transfer function for state lattice elements. - */ - def localTransfer(n: CFGPosition, s: Map[RegisterVariableWrapper, FlatElement[Expr]]): Map[RegisterVariableWrapper, FlatElement[Expr]] = n match { - case cmd: Statement => - eval(cmd, constantProp(cmd), s) - case _ => s // ignore other kinds of nodes - } - - /** Transfer function for state lattice elements. - */ - def transfer(n: CFGPosition, s: Map[RegisterVariableWrapper, FlatElement[Expr]]): Map[RegisterVariableWrapper, FlatElement[Expr]] = localTransfer(n, s) -} - -class RegionAccessesAnalysisSolver( - program: Program, - constantProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], - reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])], - ) extends RegionAccessesAnalysis(program, constantProp, reachingDefs) - with IRInterproceduralForwardDependencies - with Analysis[Map[CFGPosition, Map[RegisterVariableWrapper, FlatElement[Expr]]]] - with SimpleWorklistFixpointSolver[CFGPosition, Map[RegisterVariableWrapper, FlatElement[Expr]], MapLattice[RegisterVariableWrapper, FlatElement[Expr], FlatLattice[Expr]]] { -} diff --git a/src/main/scala/analysis/RegionInjector.scala b/src/main/scala/analysis/RegionInjector.scala new file mode 100644 index 000000000..0b178f1b2 --- /dev/null +++ b/src/main/scala/analysis/RegionInjector.scala @@ -0,0 +1,160 @@ +package analysis + +import ir.eval.BitVectorEval.isNegative +import ir.* +import util.Logger + +import scala.collection.mutable +import scala.collection.mutable.ArrayBuffer + +/** + * Replaces the region access with the calculated memory region. + */ + +class MergedRegion(var name: String, val subregions: mutable.Set[MemoryRegion]) + +class RegionInjector(program: Program, mmm: MemoryModelMap) { + private val accessToRegion = mutable.Map[Statement, Set[MemoryRegion]]() + val mergedRegions: mutable.Map[MemoryRegion, MergedRegion] = mutable.Map() + + def nodeVisitor(): Unit = { + // visit reachable procedures + val queue = mutable.Queue[Procedure]() + val visited = mutable.Set[Procedure]() + queue.enqueue(program.mainProcedure) + + while (queue.nonEmpty) { + val procedure = queue.dequeue() + for { + b <- procedure.blocks + s <- b.statements + } { + visitStatement(s) + } + visited.add(procedure) + for (call <- procedure.calls) { + if (!queue.contains(call) && !visited.contains(call)) { + queue.enqueue(call) + } + } + } + + for (access <- accessToRegion.keys) { + val regions = accessToRegion(access) + if (regions.isEmpty) { + //throw Exception("no regions found for " + access) + } else { + mergeRegions(regions) + } + } + + // rename all regions + renameMemory() + + transformMemorySections(program) + } + + def mergeRegions(regions: Set[MemoryRegion]): Unit = { + // TODO need to check that all regions are the same type + val oldMergedRegions = regions.flatMap(r => mergedRegions.get(r)) + if (oldMergedRegions.nonEmpty) { + // TODO rename in sensible deterministic way + val oldRegion = oldMergedRegions.head + for (o <- oldMergedRegions.tail) { + oldRegion.subregions.addAll(o.subregions) + } + oldRegion.subregions.addAll(regions) + for (o <- oldRegion.subregions) { + mergedRegions(o) = oldRegion + } + } else { + // TODO give sensible deterministic name + val mergedRegion = MergedRegion(regions.head.regionIdentifier, mutable.Set()) + mergedRegion.subregions.addAll(regions) + for (m <- mergedRegion.subregions) { + mergedRegions(m) = mergedRegion + } + } + } + + def renameMemory(): Unit = { + for (access <- accessToRegion.keys) { + // all regions associated with an access should have same merged region so no need to check others + val regions = accessToRegion(access) + if (regions.nonEmpty) { + val regionsHead = regions.head + val mergedRegion = mergedRegions(regionsHead) + + access match { + case store: MemoryStore => + val newMemory = replaceMemory(store.mem, regionsHead, mergedRegion) + store.mem = newMemory + case load: MemoryLoad => + val newMemory = replaceMemory(load.mem, regionsHead, mergedRegion) + load.mem = newMemory + case _ => + } + } + + } + } + + def replaceMemory(memory: Memory, region: MemoryRegion, mergedRegion: MergedRegion): Memory = { + region match { + case _: StackRegion => + StackMemory(mergedRegion.name, memory.addressSize, memory.valueSize) + case _: DataRegion => + SharedMemory(mergedRegion.name, memory.addressSize, memory.valueSize) + case _: HeapRegion => + SharedMemory(mergedRegion.name, memory.addressSize, memory.valueSize) + } + } + + private def statementToRegions(n: Statement): Set[MemoryRegion] = { + mmm.getStack(n) ++ mmm.getData(n) + } + + def visitStatement(n: Statement): Unit = n match { + case m: MemoryStore => + val regions = statementToRegions(m) + accessToRegion(m) = regions + case m: MemoryLoad => + val regions = statementToRegions(n) + accessToRegion(n) = regions + case _ => // ignore other kinds of nodes + } + + // replace memory renamer with something that creates map from access to region + // then handle all the merging required + // then do the renaming + // then get regions per procedure, handle initial memory with those + + def transformMemorySections(program: Program): Unit = { + val dataRegions = mergedRegions.keys.collect { case d: DataRegion => d } + + for (region <- dataRegions) { + program.initialMemoryLookup(region.start) match { + case Some(section) => + val size = region.size.toInt + val bytes = section.getBytes(region.start, size) + // should probably check that region is entirely contained within section but shouldn't happen in practice? + val newSection = MemorySection(region.regionIdentifier, region.start, size, bytes, section.readOnly, Some(mergedRegions(region))) + program.usedMemory(region.start) = newSection + case None => + } + } + } + + def getMergedRegion(address: BigInt): Option[MergedRegion] = { + val region = mmm.findDataObject(address) + if (region.isDefined && mergedRegions.contains(region.get)) { + Some(mergedRegions(region.get)) + } else { + None + } + } +} + +class RegionRenamer(memory: Memory) extends Visitor { + override def visitMemory(node: Memory): Memory = memory +} diff --git a/src/main/scala/analysis/SSAForm.scala b/src/main/scala/analysis/SSAForm.scala deleted file mode 100644 index 044780a6b..000000000 --- a/src/main/scala/analysis/SSAForm.scala +++ /dev/null @@ -1,100 +0,0 @@ -//package analysis -// -//import analysis.* -//import ir.{SignExtend, *} -//import util.Logger -// -//import scala.collection.mutable -// -///** Set-Based SSA -// * - Each variable has a set of versions -// * - New assignments create new versions and replaces any new versions -// * -// * NOTE: This approach does not make an attempt to handle loops -// */ -//class SSAForm(program: Program) { -// -// private val varMaxTracker = mutable.HashMap[String, Int]() -// private val blockBasedMappings = mutable.HashMap[(Block, String), mutable.Set[Int]]().withDefault(_ => mutable.Set()) -// private val context = mutable.HashMap[(Procedure, String), mutable.Set[Int]]().withDefault(_ => mutable.Set()) -// private def getMax(varName: String): Int = -// val ret = varMaxTracker.getOrElse(varName, 0) -// varMaxTracker(varName) = ret + 1 -// ret -// -// private def transformVariables(vars: Set[Variable], block: Block, proc: Procedure): Unit = { -// vars.foreach { v => -// if (context.contains((proc, v.name))) { -// v.sharedVariable = true -// } -// v.ssa_id.clear() -// val contextResult = context.getOrElseUpdate((proc, v.name), mutable.Set(getMax(v.name))) -// v.ssa_id.addAll(blockBasedMappings.getOrElseUpdate((block, v.name), contextResult)) -// } -// } -// -// def applySSA(): Unit = { -// for (proc <- program.procedures) { -// val visitedBlocks = mutable.Set[Block]() -// val stack = mutable.Stack[Block]() -// -// // Start with the entry block -// if (proc.entryBlock.isDefined) { -// stack.push(proc.entryBlock.get) -// } -// -// while (stack.nonEmpty) { -// val currentBlock = stack.pop() -// -// if (!visitedBlocks.contains(currentBlock)) { -// visitedBlocks.add(currentBlock) -// -// for (stmt <- currentBlock.statements) { -// Logger.debug(stmt) -// stmt match { -// case localAssign: LocalAssign => -// transformVariables(localAssign.rhs.variables, currentBlock, proc) -// val maxVal = varMaxTracker.getOrElseUpdate(localAssign.lhs.name, 0) -// blockBasedMappings((currentBlock, localAssign.lhs.name)) = mutable.Set(maxVal) -// -// localAssign.lhs.ssa_id.clear() -// localAssign.lhs.ssa_id.addAll(blockBasedMappings((currentBlock, localAssign.lhs.name))) -// -// varMaxTracker(localAssign.lhs.name) = blockBasedMappings((currentBlock, localAssign.lhs.name)).max + 1 -// -// case memoryAssign: MemoryAssign => -// transformVariables(memoryAssign.rhs.variables, currentBlock, proc) -// -// case assume: Assume => -// transformVariables(assume.body.variables, currentBlock, proc) -// // no required for analyses -// case assert: Assert => -// transformVariables(assert.body.variables, currentBlock, proc) -// // no required for analyses -// case _ => throw new RuntimeException("No SSA form for " + stmt.getClass + " yet") -// } -// } -// currentBlock.jump match { -// case directCall: DirectCall => -// // TODO: transfers the whole context but it could be using ANR and RNA to transfer only the relevant context -// varMaxTracker.keys.foreach { varr => -// //context((directCall.target, varr)) = context((directCall.target, varr)) ++ blockBasedMappings(block, varr) -// context.getOrElseUpdate((directCall.target, varr), mutable.Set()) ++= blockBasedMappings((currentBlock, varr)) -// } -// case indirectCall: IndirectCall => -// transformVariables(indirectCall.target.variables, currentBlock, proc) -// case goTo: GoTo => -// for { -// b <- goTo.targets -// varr <- varMaxTracker.keys -// } { -// blockBasedMappings((b, varr)) ++= blockBasedMappings(currentBlock, varr) -// } -// } -// // Push unvisited successors onto the stack -// stack.pushAll(currentBlock.nextBlocks) -// } -// } -// } -// } -//} diff --git a/src/main/scala/analysis/SteensgaardAnalysis.scala b/src/main/scala/analysis/SteensgaardAnalysis.scala deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/scala/analysis/SummaryGenerator.scala b/src/main/scala/analysis/SummaryGenerator.scala index afd8a229b..5cb0b5ab3 100644 --- a/src/main/scala/analysis/SummaryGenerator.scala +++ b/src/main/scala/analysis/SummaryGenerator.scala @@ -24,35 +24,31 @@ private trait RNATaintableAnalysis( private val linkRegister = Register("R30", 64) private val framePointer = Register("R29", 64) - private val ignoreRegions: Set[Expr] = Set(linkRegister, framePointer, stackPointer) + private val ignoreRegions: Set[Variable] = Set(linkRegister, framePointer, stackPointer) def eval(cmd: Command, s: Set[Taintable]): Set[Taintable] = { - var m = s - val exprs = cmd match { + cmd match { case assume: Assume => - Set(assume.body) + s ++ assume.body.variables -- ignoreRegions case assert: Assert => - Set(assert.body) - case memoryAssign: MemoryAssign => - m = m -- getMemoryVariable(cmd, memoryAssign.mem, memoryAssign.index, memoryAssign.size, constProp, globals) - Set(memoryAssign.index, memoryAssign.value) + s ++ assert.body.variables -- ignoreRegions + case memoryStore: MemoryStore => + val m = s -- getMemoryVariable(cmd, memoryStore.mem, memoryStore.index, memoryStore.size, constProp, globals) + m ++ memoryStore.index.variables ++ memoryStore.value.variables -- ignoreRegions case indirectCall: IndirectCall => - if (ignoreRegions.contains(indirectCall.target)) return m - Set(indirectCall.target) - case assign: Assign => - m = m - assign.lhs - Set(assign.rhs) - case _ => return m - } - - exprs.foldLeft(m) { - (m, expr) => { - val vars = expr.variables.filter(!ignoreRegions.contains(_)).map { v => v: Taintable } - val memvars: Set[Taintable] = expr.loads.flatMap { - l => getMemoryVariable(cmd, l.mem, l.index, l.size, constProp, globals) + if (ignoreRegions.contains(indirectCall.target)) { + s + } else { + s + indirectCall.target -- ignoreRegions } - m.union(vars).union(memvars) - } + case assign: LocalAssign => + val m = s - assign.lhs + m ++ assign.rhs.variables -- ignoreRegions + case memoryLoad: MemoryLoad => + val m = s - memoryLoad.lhs + val memvar = getMemoryVariable(cmd, memoryLoad.mem, memoryLoad.index, memoryLoad.size, constProp, globals) + m ++ memvar ++ memoryLoad.index.variables -- ignoreRegions + case _ => s } } @@ -96,10 +92,10 @@ class SummaryGenerator( private def toGamma(variable: Taintable): Option[BExpr] = { variable match { case variable: Register => Some(variable.toGamma) - case variable: LocalVar => None + case _: LocalVar => None case variable: GlobalVariable => Some(variable.toGamma) //case variable: LocalStackVariable => None - case variable: UnknownMemory => Some(FalseBLiteral) + case _: UnknownMemory => Some(FalseBLiteral) } } @@ -184,4 +180,4 @@ class SummaryGenerator( } } } -} +} \ No newline at end of file diff --git a/src/main/scala/analysis/TaintAnalysis.scala b/src/main/scala/analysis/TaintAnalysis.scala index d51eda374..d18e27d48 100644 --- a/src/main/scala/analysis/TaintAnalysis.scala +++ b/src/main/scala/analysis/TaintAnalysis.scala @@ -15,7 +15,7 @@ type Taintable = Variable | GlobalVariable /*| LocalStackVariable*/ | UnknownMem /** * A global variable in memory. */ -case class GlobalVariable(val mem: Memory, val address: BitVecLiteral, val size: Int, val identifier: String) { +case class GlobalVariable(mem: Memory, address: BitVecLiteral, size: Int, identifier: String) { override def toString(): String = { s"GlobalVariable($mem, $identifier, $size, $address)" } @@ -59,7 +59,10 @@ case class UnknownMemory() { } def getMemoryVariable( - n: CFGPosition, mem: Memory, expression: Expr, size: Int, + n: CFGPosition, + mem: Memory, + expression: Expr, + size: Int, constProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], globals: Map[BigInt, String], ): Option[GlobalVariable/*| LocalStackVariable*/] = { @@ -69,25 +72,23 @@ def getMemoryVariable( expression match { // TODO assumes stack var accesses are all of the form R31 + n, or just R31, when in reality they could be more complex. - case BinaryExpr(BVADD, arg1, arg2) if arg1 == stackPointer => { + case BinaryExpr(BVADD, arg1, arg2) if arg1 == stackPointer => evaluateExpression(arg2, constProp(n)) match // TODO This assumes that all stack variables are initialized local variables, which is not necessarily the case. // If a stack address is read, without being assigned a value in this procedure, it will be // assumed untainted, when in reality it may be UnknownMemory. //case Some(addr) => Some(LocalStackVariable(addr, size)) - case Some(addr) => None + case Some(_) => None case None => None - } //case v: Variable if v == stackPointer => Some(LocalStackVariable(BitVecLiteral(0, 64), size)) case v: Variable if v == stackPointer => None - case _ => { + case _ => // TOOD check that the global access has the right size evaluateExpression(expression, constProp(n)) match case Some(addr) => globals.get(addr.value) match case Some(global) => Some(GlobalVariable(mem, addr, size, global)) case None => None case None => None - } } } @@ -100,8 +101,6 @@ trait TaintAnalysisFunctions( val edgelattice = EdgeFunctionLattice(valuelattice) import edgelattice.{IdEdge, ConstEdge} - private val stackPointer = Register("R31", 64) - def edgesCallToEntry(call: DirectCall, entry: Procedure)(d: DL): Map[DL, EdgeFunction[TwoElement]] = { Map(d -> IdEdge()) } @@ -115,39 +114,34 @@ trait TaintAnalysisFunctions( } def edgesOther(n: CFGPosition)(d: DL): Map[DL, EdgeFunction[TwoElement]] = { - def containsValue(expression: Expr, value: Taintable): Boolean = { - value match { - case (v: Variable) => expression.variables.contains(v) - case v => { - expression.loads.map { - load => getMemoryVariable(n, load.mem, load.index, load.size, constProp, globals).getOrElse(UnknownMemory()) - }.contains(v) - } - } - } - (n match { - case Assign(variable, expression, _) => { + case LocalAssign(variable, expression, _) => d match { - case Left(v) => { - if containsValue(expression, v) then Map(d -> IdEdge(), Left(variable) -> IdEdge()) - else if v == variable then Map() - else Map(d -> IdEdge()) - } + case Left(v: Variable) => + if (expression.variables.contains(v)) { + Map(d -> IdEdge(), Left(variable) -> IdEdge()) + } else if (v == variable) { + Map() + } else { + Map(d -> IdEdge()) + } case _ => Map(d -> IdEdge()) } - } - case MemoryAssign(mem, index, expression, _, size, _) => { - val variable = getMemoryVariable(n, mem, index, size, constProp, globals).getOrElse(UnknownMemory()) + case MemoryStore(mem, index, expression, _, size, _) => + val variable: Taintable = getMemoryVariable(n, mem, index, size, constProp, globals).getOrElse(UnknownMemory()) d match { - case Left(v) => { - if containsValue(expression, v) then Map(d -> IdEdge(), Left(variable) -> IdEdge()) - else if variable == v && v != UnknownMemory() then Map() - else Map(d -> IdEdge()) - } - case Right(_) => Map(d -> IdEdge()) + case Left(v: Variable) if expression.variables.contains(v) => Map(d -> IdEdge(), Left(variable) -> IdEdge()) + case Left(v: GlobalVariable) if variable == v => Map() + case _ => Map(d -> IdEdge()) + } + case MemoryLoad(lhs, mem, index, _, size, _) => + val memoryVariable: Taintable = getMemoryVariable(n, mem, index, size, constProp, globals).getOrElse(UnknownMemory()) + d match { + case Left(v: Variable) if index.variables.contains(v) => Map(d -> IdEdge(), Left(lhs) -> IdEdge()) + case Left(v: Variable) if v == lhs => Map() + case Left(v: Taintable) if memoryVariable == v => Map(d -> IdEdge(), Left(lhs) -> IdEdge()) + case _ => Map(d -> IdEdge()) } - } case _ => Map(d -> IdEdge()) }) ++ ( d match diff --git a/src/main/scala/analysis/VSA.scala b/src/main/scala/analysis/VSA.scala index 734f9bf11..4a9f11a14 100644 --- a/src/main/scala/analysis/VSA.scala +++ b/src/main/scala/analysis/VSA.scala @@ -10,19 +10,10 @@ import scala.collection.immutable import util.Logger /** ValueSets are PowerSet of possible values */ -trait Value { - val expr: BitVecLiteral -} -trait AddressValue extends Value { - val name: String -} +trait Value -case class GlobalAddress(override val expr: BitVecLiteral, override val name: String) extends AddressValue { - override def toString: String = "GlobalAddress(" + expr + ", " + name + ")" -} - -case class LocalAddress(override val expr: BitVecLiteral, override val name: String) extends AddressValue { - override def toString: String = "LocalAddress(" + expr + ", " + name + ")" +case class AddressValue(region: MemoryRegion) extends Value { + override def toString: String = "Address(" + region + ")" } case class LiteralValue(expr: BitVecLiteral) extends Value { @@ -30,12 +21,8 @@ case class LiteralValue(expr: BitVecLiteral) extends Value { } trait ValueSetAnalysis(program: Program, - globals: Map[BigInt, String], - externalFunctions: Map[BigInt, String], - globalOffsets: Map[BigInt, BigInt], - subroutines: Map[BigInt, String], - mmm: MemoryModelMap, - constantProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]]) { + mmm: MemoryModelMap, + constantProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]]) { val powersetLattice: PowersetLattice[Value] = PowersetLattice() @@ -45,157 +32,112 @@ trait ValueSetAnalysis(program: Program, val lattice: MapLattice[CFGPosition, LiftedElement[Map[Variable | MemoryRegion, Set[Value]]], LiftLattice[Map[Variable | MemoryRegion, Set[Value]], mapLattice.type]] = MapLattice(liftedLattice) - val domain: Set[CFGPosition] = Set.empty ++ program - - val first: Set[CFGPosition] = Set.empty ++ program - - private val stackPointer = Register("R31", 64) - private val linkRegister = Register("R30", 64) - private val framePointer = Register("R29", 64) - - private val ignoreRegions: Set[Expr] = Set(linkRegister, framePointer) + val first: Set[CFGPosition] = Set(program.mainProcedure) private val mallocVariable = Register("R0", 64) - private def resolveGlobalOffset(address: BigInt): String = { - val tableAddress = globalOffsets(address) - if (globals.contains(tableAddress)) { - globals(tableAddress) - } else if (subroutines.contains(tableAddress)) { - subroutines(tableAddress) - } else { - //throw Exception("Error: cannot resolve global offset " + address + " -> " + tableAddress) - "@ERROR" - } - } - - def exprToRegion(expr: Expr, n: CFGPosition): Option[MemoryRegion] = { - expr match { - case binOp: BinaryExpr if binOp.arg1 == stackPointer => - evaluateExpression(binOp.arg2, constantProp(n)) match { - case Some(b: BitVecLiteral) => mmm.findStackObject(b.value) - case None => None - } - case _ => - evaluateExpression(expr, constantProp(n)) match { - case Some(b: BitVecLiteral) => mmm.findDataObject(b.value) - case None => None - } - } - } - - private def getValueType(bitVecLiteral: BitVecLiteral): Value = { - if (externalFunctions.contains(bitVecLiteral.value)) { - LocalAddress(bitVecLiteral, externalFunctions(bitVecLiteral.value)) - } else if (globals.contains(bitVecLiteral.value)) { - GlobalAddress(bitVecLiteral, globals(bitVecLiteral.value)) - } else if (globalOffsets.contains(bitVecLiteral.value)) { - GlobalAddress(bitVecLiteral, resolveGlobalOffset(bitVecLiteral.value)) - } else if (subroutines.contains(bitVecLiteral.value)) { - GlobalAddress(bitVecLiteral, subroutines(bitVecLiteral.value)) - } else { - LiteralValue(bitVecLiteral) - } + def canCoerceIntoDataRegion(bitVecLiteral: BitVecLiteral, size: Int): Option[DataRegion] = { + mmm.findDataObject(bitVecLiteral.value) } /** Default implementation of eval. */ - def eval(cmd: Command, s: Map[Variable | MemoryRegion, Set[Value]], n: CFGPosition): Map[Variable | MemoryRegion, Set[Value]] = { - Logger.debug(s"eval: $cmd") - Logger.debug(s"state: $s") - Logger.debug(s"node: $n") - var m = s - cmd match - case localAssign: Assign => - localAssign.rhs match - case memoryLoad: MemoryLoad => - exprToRegion(memoryLoad.index, n) match - case Some(r: MemoryRegion) => - // this is an exception to the rule and only applies to data regions - evaluateExpression(memoryLoad.index, constantProp(n)) match - case Some(bitVecLiteral: BitVecLiteral) => - m = m + (r -> Set(getValueType(bitVecLiteral))) - m = m + (localAssign.lhs -> m(r)) - m - case None => - m = m + (localAssign.lhs -> m(r)) - m - case None => - Logger.debug("could not find region for " + localAssign) - m - case e: Expr => - evaluateExpression(e, constantProp(n)) match { - case Some(bv: BitVecLiteral) => - m = m + (localAssign.lhs -> Set(getValueType(bv))) - m - case None => - Logger.debug("could not evaluate expression" + e) - m + def eval(cmd: Command, s: Map[Variable | MemoryRegion, Set[Value]]): Map[Variable | MemoryRegion, Set[Value]] = { + cmd match { + case directCall: DirectCall if directCall.target.name == "malloc" => + val regions = mmm.nodeToRegion(cmd) + // malloc variable + s + (mallocVariable -> regions.map(r => AddressValue(r))) + case localAssign: LocalAssign => + val regions = mmm.nodeToRegion(cmd) + if (regions.nonEmpty) { + s + (localAssign.lhs -> regions.map(r => AddressValue(r))) + } else { + evaluateExpression(localAssign.rhs, constantProp(cmd)) match { + case Some(bitVecLiteral: BitVecLiteral) => + val possibleData = canCoerceIntoDataRegion(bitVecLiteral, 1) + if (possibleData.isDefined) { + s + (localAssign.lhs -> Set(AddressValue(possibleData.get))) + } else { + s + (localAssign.lhs -> Set(LiteralValue(bitVecLiteral))) + } + case None => + // TODO this is not at all sound + val unwrapValue = unwrapExprToVar(localAssign.rhs) + unwrapValue match { + case Some(v: Variable) => + s + (localAssign.lhs -> s(v)) + case None => + Logger.debug(s"Too Complex: ${localAssign.rhs}") // do nothing + s + } + } + } + case load: MemoryLoad => + val regions = mmm.nodeToRegion(cmd) + if (regions.nonEmpty) { + s + (load.lhs -> regions.map(r => AddressValue(r))) + } else { + // TODO this is blatantly incorrect but maintaining current functionality to start + val unwrapValue = unwrapExprToVar(load.index) + unwrapValue match { + case Some(v: Variable) => + s + (load.lhs -> s(v)) + case None => + Logger.debug(s"Too Complex: ${load.index}") // do nothing + s + } + } + case store: MemoryStore => + val regions = mmm.nodeToRegion(cmd) + evaluateExpression(store.value, constantProp(cmd)) match { + case Some(bitVecLiteral: BitVecLiteral) => + val possibleData = canCoerceIntoDataRegion(bitVecLiteral, store.size) + if (possibleData.isDefined) { + s ++ regions.map(r => r -> Set(AddressValue(possibleData.get))) + } else { + s ++ regions.map(r => r -> Set(LiteralValue(bitVecLiteral))) } - case memAssign: MemoryAssign => - memAssign.index match - case binOp: BinaryExpr => - val region: Option[MemoryRegion] = exprToRegion(binOp, n) - region match - case Some(r: MemoryRegion) => - val storeValue = memAssign.value - evaluateExpression(storeValue, constantProp(n)) match - case Some(bitVecLiteral: BitVecLiteral) => - m = m + (r -> Set(getValueType(bitVecLiteral))) - m - /* - // TODO constant prop returned BOT OR TOP. Merge regions because RHS could be a memory loaded address - case variable: Variable => - s + (r -> s(variable)) - */ - case None => - storeValue.match { - case v: Variable => - m = m + (r -> m(v)) - m - case _ => - Logger.debug(s"Too Complex: $storeValue") // do nothing - m - } + case None => + // TODO: unsound + val unwrapValue = unwrapExprToVar(store.value) + unwrapValue match { + case Some(v: Variable) => + s ++ regions.map(r => r -> s(v)) case None => - Logger.debug("could not find region for " + memAssign) - m - case _ => - m + Logger.debug(s"Too Complex: $store.value") // do nothing + s + } + } case _ => - m + s + } } - /** Transfer function for state lattice elements. + /** Transfer function for state lattice elements. (Same as `localTransfer` for simple value analysis.) */ - def localTransfer(n: CFGPosition, s: Map[Variable | MemoryRegion, Set[Value]]): Map[Variable | MemoryRegion, Set[Value]] = - if (IRWalk.procedure(n) == n) { - mmm.pushContext(n.asInstanceOf[Procedure].name) - s - } else if (IRWalk.lastInProc(IRWalk.procedure(n)) == n) { - mmm.popContext() - s - } else n match + def transferUnlifted(n: CFGPosition, s: Map[Variable | MemoryRegion, Set[Value]]): Map[Variable | MemoryRegion, Set[Value]] = { + n match { + case p: Procedure => + mmm.pushContext(p.name) + s + case _: Return => + mmm.popContext() + s case command: Command => - eval(command, s, n) + eval(command, s) case _ => s - - /** Transfer function for state lattice elements. (Same as `localTransfer` for simple value analysis.) - */ - def transferUnlifted(n: CFGPosition, s: Map[Variable | MemoryRegion, Set[Value]]): Map[Variable | MemoryRegion, Set[Value]] = localTransfer(n, s) + } + } } class ValueSetAnalysisSolver( program: Program, - globals: Map[BigInt, String], - externalFunctions: Map[BigInt, String], - globalOffsets: Map[BigInt, BigInt], - subroutines: Map[BigInt, String], mmm: MemoryModelMap, constantProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], -) extends ValueSetAnalysis(program, globals, externalFunctions, globalOffsets, subroutines, mmm, constantProp) - with IRInterproceduralForwardDependencies +) extends ValueSetAnalysis(program, mmm, constantProp) + with IRIntraproceduralForwardDependencies with Analysis[Map[CFGPosition, LiftedElement[Map[Variable | MemoryRegion, Set[Value]]]]] with WorklistFixpointSolverWithReachability[CFGPosition, Map[Variable | MemoryRegion, Set[Value]], MapLattice[Variable | MemoryRegion, Set[Value], PowersetLattice[Value]]] { diff --git a/src/main/scala/analysis/VariableDependencyAnalysis.scala b/src/main/scala/analysis/VariableDependencyAnalysis.scala index 7ce228503..570d65898 100644 --- a/src/main/scala/analysis/VariableDependencyAnalysis.scala +++ b/src/main/scala/analysis/VariableDependencyAnalysis.scala @@ -37,46 +37,50 @@ trait ProcVariableDependencyAnalysisFunctions( def edgesCallToAfterCall(call: DirectCall, aftercall: Command)(d: DL): Map[DL, EdgeFunction[Set[Taintable]]] = { d match { - case Left(v) => varDepsSummaries.get(call.target).flatMap(_.get(v).map( _.foldLeft(Map[DL, EdgeFunction[Set[Taintable]]]()) { - (m, d) => m + (Left(d) -> IdEdge()) - })).getOrElse(Map()) + case Left(v) => + varDepsSummaries.get(call.target).flatMap { + _.get(v).map { + _.foldLeft(Map[DL, EdgeFunction[Set[Taintable]]]()) { + (m, d) => m + (Left(d) -> IdEdge()) + } + } + }.getOrElse(Map()) case Right(_) => Map(d -> IdEdge()) } } def edgesOther(n: CFGPosition)(d: DL): Map[DL, EdgeFunction[Set[Taintable]]] = { - def getVars(expression: Expr): Set[Taintable] = { - expression.variables.map { v => v: Taintable } ++ - expression.loads.map { l => getMemoryVariable(n, l.mem, l.index, l.size, constProp, globals).getOrElse(UnknownMemory()) } - } - if n == procedure then d match { // At the start of the procedure, no variables should depend on anything but themselves. case Left(_) => Map() - case Right(_) => { + case Right(_) => variables.foldLeft(Map(d -> IdEdge())) { (m: Map[DL, EdgeFunction[Set[Taintable]]], v) => m + (Left(v) -> ConstEdge(Set(v))) } - } } else n match { - case Assign(assigned, expression, _) => { - val vars = getVars(expression) -- ignoredRegisters + case LocalAssign(assigned, expression, _) => + val vars = expression.variables -- ignoredRegisters d match { - case Left(v) if vars.contains(v) => Map(d -> IdEdge(), Left(assigned) -> IdEdge()) - case Left(v) if v == assigned => Map() + case Left(v: Variable) if vars.contains(v) => Map(d -> IdEdge(), Left(assigned) -> IdEdge()) + case Left(v: Variable) if v == assigned => Map() case _ => Map(d -> IdEdge()) } - } - case MemoryAssign(mem, index, expression, _, size, _) => { - val assigned = getMemoryVariable(n, mem, index, size, constProp, globals).getOrElse(UnknownMemory()) - - val vars = getVars(expression) -- ignoredRegisters + case MemoryStore(mem, index, expression, _, size, _) => + val assigned: Taintable = getMemoryVariable(n, mem, index, size, constProp, globals).getOrElse(UnknownMemory()) + val vars = expression.variables -- ignoredRegisters d match { - case Left(v) if vars.contains(v) => Map(d -> IdEdge(), Left(assigned) -> IdEdge()) - case Left(v) if v == assigned && v != UnknownMemory() => Map() + case Left(v: Variable) if vars.contains(v) => Map(d -> IdEdge(), Left(assigned) -> IdEdge()) + case Left(v: GlobalVariable) if v == assigned => Map() + case _ => Map(d -> IdEdge()) + } + case MemoryLoad(lhs, mem, index, _, size, _) => + val memoryVariable: Taintable = getMemoryVariable(n, mem, index, size, constProp, globals).getOrElse(UnknownMemory()) + val vars: Set[Taintable] = Set(memoryVariable) ++ index.variables -- ignoredRegisters + d match { + case Left(v) if vars.contains(v) => Map(d -> IdEdge(), Left(lhs) -> IdEdge()) + case Left(v) if v == lhs => Map() case _ => Map(d -> IdEdge()) } - } case _ => Map(d -> IdEdge()) } } @@ -97,7 +101,7 @@ class ProcVariableDependencyAnalysis( { override def phase2Init: Set[Taintable] = Set(Register("R0", 64)) - override val startNode: CFGPosition = procedure + override def start: CFGPosition = procedure } class VariableDependencyAnalysis( @@ -107,7 +111,7 @@ class VariableDependencyAnalysis( constProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], scc: mutable.ListBuffer[mutable.Set[Procedure]], ) { - val varDepVariables: Set[analysis.Taintable] = 0.to(28).map { n => + val varDepVariables: Set[Taintable] = 0.to(28).map { n => Register(s"R$n", 64) }.toSet ++ specGlobals.map { g => analysis.GlobalVariable(dsl.mem, BitVecLiteral(g.address, 64), g.size, g.name) diff --git a/src/main/scala/analysis/WriteToAnalysis.scala b/src/main/scala/analysis/WriteToAnalysis.scala new file mode 100644 index 000000000..52e0142ac --- /dev/null +++ b/src/main/scala/analysis/WriteToAnalysis.scala @@ -0,0 +1,48 @@ +package analysis + +import ir.{DirectCall, LocalAssign, MemoryLoad, MemoryStore, Procedure, Program, Register} + +import scala.collection.mutable + +class WriteToAnalysis(program: Program) extends Analysis[Map[Procedure, Set[Register]]] { + + val writesTo: mutable.Map[Procedure, Set[Register]] = mutable.Map() + val mallocRegister = Register("R0", 64) + val paramRegisters: Set[Register] = Set( + mallocRegister, + Register("R1", 64), + Register("R2", 64), + Register("R3", 64), + Register("R4", 64), + Register("R5", 64), + Register("R6", 64), + Register("R7", 64), + ) + + def getWritesTos(proc: Procedure): Set[Register] = { + if writesTo.contains(proc) then + writesTo(proc) + else + val writtenTo: mutable.Set[Register] = mutable.Set() + proc.blocks.foreach { block => + block.statements.foreach { + case LocalAssign(variable: Register, _, _) if paramRegisters.contains(variable) => + writtenTo.add(variable) + case MemoryLoad(lhs: Register, _, _, _, _, _) if paramRegisters.contains(lhs) => + writtenTo.add(lhs) + case DirectCall(target, _, _, _) if target.name == "malloc" => + writtenTo.add(mallocRegister) + case d: DirectCall if program.procedures.contains(d.target) => + writtenTo.addAll(getWritesTos(d.target)) + case _ => + } + } + + writesTo.update(proc, writtenTo.toSet) + writesTo(proc) + } + + def analyze(): Map[Procedure, Set[Register]] = + program.procedures.foreach(getWritesTos) + writesTo.toMap +} diff --git a/src/main/scala/analysis/data_structure_analysis/DataStructureAnalysis.scala b/src/main/scala/analysis/data_structure_analysis/DataStructureAnalysis.scala new file mode 100644 index 000000000..08b7386d6 --- /dev/null +++ b/src/main/scala/analysis/data_structure_analysis/DataStructureAnalysis.scala @@ -0,0 +1,219 @@ +package analysis.data_structure_analysis + +import analysis.* +import ir.* +import specification.{ExternalFunction, SymbolTableEntry} +import boogie.SpecGlobal + +import scala.collection.mutable + +/** + * Data Structure Analysis + * Performs all phases of DSA and stores the results in member variables + * local, bottom-up, top-down results in member variables locals, bu and td respectively. + * @param program program to be analysed + * @param symResults result of symbolic access analysis + * @param constProp + * @param globals + * @param globalOffsets + * @param externalFunctions + * @param reachingDefs + * @param writesTo mapping from procedures to registers they change + * @param params mapping from procedures to their parameters + */ +class DataStructureAnalysis(program: Program, + symResults: Map[CFGPosition, Map[SymbolicAddress, TwoElement]], + constProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], + globals: Set[SymbolTableEntry], + globalOffsets: Map[BigInt, BigInt], + externalFunctions: Set[ExternalFunction], + reachingDefs: Map[CFGPosition, Map[Variable, Set[CFGPosition]]], + writesTo: Map[Procedure, Set[Register]], + params: Map[Procedure, Set[Variable]] + ) extends Analysis[Map[Procedure, Graph]] { + + val local: mutable.Map[Procedure, Graph] = mutable.Map() + val bottomUp: mutable.Map[Procedure, Graph] = mutable.Map() + val topDown: mutable.Map[Procedure, Graph] = mutable.Map() + + private val stackPointer = Register("R31", 64) + private val returnPointer = Register("R30", 64) + private val framePointer = Register("R29", 64) + + private val ignoreRegisters: Set[Variable] = Set(stackPointer, returnPointer, framePointer) + + private def findLeaf(procedure: Procedure): Set[Procedure] = { + val succ = CallGraph.succ(procedure) + if (succ.isEmpty) { + Set(procedure) + } else { + succ.flatMap(findLeaf) + } + } + + private var visited = Set[Procedure]() + private val queue = mutable.Queue[Procedure]() + + override def analyze(): Map[Procedure, Graph] = { + var domain: Set[Procedure] = Set(program.mainProcedure) + val stack: mutable.Stack[Procedure] = mutable.Stack() + stack.pushAll(program.mainProcedure.calls) + + // calculate the procedures used in the program + while (stack.nonEmpty) { + val current = stack.pop() + domain += current + stack.pushAll(current.calls.diff(domain)) + } + + // perform local analysis on all procs + domain.foreach { proc => + val dsg = LocalPhase(proc, symResults, constProp, globals, globalOffsets, externalFunctions, reachingDefs, writesTo, params).analyze() + + local.update(proc, dsg) + bottomUp.update(proc, dsg.cloneSelf()) + } + + val leafNodes = findLeaf(program.mainProcedure) + + leafNodes.foreach { proc => + assert(local(proc).callsites.isEmpty) + visited += proc + //val preds: Set[Procedure] = CallGraph.pred(proc) + queue.enqueueAll(CallGraph.pred(proc).diff(visited).intersect(domain)) + } + + // bottom up phase + while queue.nonEmpty do + var proc = queue.dequeue() + while !local.contains(proc) && queue.nonEmpty do proc = queue.dequeue() + visited += proc + if local.contains(proc) then + queue.enqueueAll(CallGraph.pred(proc).diff(visited)) + val buGraph = bottomUp(proc) + + buGraph.callsites.foreach { callSite => + val callee = callSite.proc + val calleeGraph = local(callee) //.cloneSelf() + assert(buGraph.globalMapping.keySet.equals(calleeGraph.globalMapping.keySet)) + assert(calleeGraph.formals.keySet.diff(ignoreRegisters).equals(callSite.paramCells.keySet)) + calleeGraph.globalMapping.values.foreach { field => + val newNode = calleeGraph.find(field.node).node + newNode.cloneNode(calleeGraph, buGraph) + } + + calleeGraph.formals.foreach { (variable, slice) => + if (!ignoreRegisters.contains(variable)) { + assert(callSite.paramCells.contains(variable)) + val node = calleeGraph.find(slice).node + node.cloneNode(calleeGraph, buGraph) + } + } + + assert(writesTo(callee).equals(callSite.returnCells.keySet)) + writesTo(callee).foreach { reg => + assert(callSite.returnCells.contains(reg)) + val returnCells = calleeGraph.getCells(IRWalk.lastInProc(callee).get, reg).map(calleeGraph.find) + assert(returnCells.nonEmpty) + returnCells.foreach { slice => + val node = calleeGraph.find(slice).node + node.cloneNode(calleeGraph, buGraph) + } + } + + // assert(calleeGraph.formals.isEmpty || buGraph.varToCell(begin(callee)).equals(calleeGraph.formals)) + calleeGraph.globalMapping.foreach { + case (range: AddressRange, Field(node: Node, offset: BigInt)) => + val field = calleeGraph.find(node) + buGraph.mergeCells( + buGraph.globalMapping(range).node.getCell(buGraph.globalMapping(range).offset), + field.node.getCell(field.offset + offset) + ) + } + + if (buGraph.varToCell.contains(callee)) { + buGraph.varToCell(callee).keys.foreach { variable => + if (!ignoreRegisters.contains(variable)) { + val formal = buGraph.varToCell(callee)(variable) + buGraph.mergeCells(buGraph.adjust(formal), buGraph.adjust(callSite.paramCells(variable))) + } + } + } + + writesTo(callee).foreach { reg => + val returnCells = buGraph.getCells(IRWalk.lastInProc(callee).get, reg) + // assert(returnCells.nonEmpty) + returnCells.foldLeft(buGraph.adjust(callSite.returnCells(reg))) { (c, ret) => + buGraph.mergeCells(c, buGraph.adjust(ret)) + } + } + } + buGraph.collectNodes() + // bottom up phase finished + // clone bu graphs to top-down graphs + domain.foreach { proc => + topDown.update(proc, bottomUp(proc).cloneSelf()) + } + + queue.enqueue(program.mainProcedure) + visited = Set() + + // top-down phase + while (queue.nonEmpty) { + val proc = queue.dequeue() + visited += proc + queue.enqueueAll(CallGraph.succ(proc).diff(visited)) + val callersGraph = topDown(proc) + callersGraph.callsites.foreach { callSite => + val callee = callSite.proc + val calleesGraph = topDown(callee) + assert(callersGraph.globalMapping.keySet.equals(calleesGraph.globalMapping.keySet)) + + callersGraph.globalMapping.values.foreach { field => + val oldNode = field.node + val node = callersGraph.find(oldNode).node + node.cloneNode(callersGraph, calleesGraph) + } + + callSite.paramCells.values.foreach { slice => + val node = callersGraph.find(slice).node + node.cloneNode(callersGraph, calleesGraph) + } + + callSite.returnCells.values.foreach { slice => + val node = callersGraph.find(slice).node + node.cloneNode(callersGraph, callersGraph) + } + + callersGraph.globalMapping.foreach { case (range: AddressRange, Field(oldNode, internal)) => + // val node = callersGraph + val field = callersGraph.find(oldNode) + calleesGraph.mergeCells( + calleesGraph.globalMapping(range).node.getCell(calleesGraph.globalMapping(range).offset), + field.node.getCell(field.offset + internal) + ) + } + + callSite.paramCells.keySet.foreach { variable => + val paramCells = calleesGraph.getCells(callSite.call, variable) // wrong param offset + paramCells.foldLeft(calleesGraph.adjust(calleesGraph.formals(variable))) { + (cell, slice) => calleesGraph.mergeCells(calleesGraph.adjust(slice), cell) + } + } + + if (calleesGraph.varToCell.contains(callSite.call)) { + calleesGraph.varToCell(callSite.call).foreach { (variable, oldSlice) => + val slice = callersGraph.find(oldSlice) + val returnCells = calleesGraph.getCells(IRWalk.lastInProc(callee).get, variable) + returnCells.foldLeft(calleesGraph.adjust(slice)) { + (c, retCell) => calleesGraph.mergeCells(c, calleesGraph.adjust(retCell)) + } + } + } + } + callersGraph.collectNodes() + } + topDown.toMap + + } +} diff --git a/src/main/scala/analysis/data_structure_analysis/Graph.scala b/src/main/scala/analysis/data_structure_analysis/Graph.scala new file mode 100644 index 000000000..8268e297c --- /dev/null +++ b/src/main/scala/analysis/data_structure_analysis/Graph.scala @@ -0,0 +1,747 @@ +package analysis.data_structure_analysis + +import analysis.FlatElement +import analysis.solvers.DSAUnionFindSolver +import analysis.evaluateExpression +import cfg_visualiser.* +import ir.* +import specification.{ExternalFunction, SymbolTableEntry} + +import scala.collection.mutable +import scala.collection.mutable.ArrayBuffer +import scala.util.control.Breaks.{break, breakable} + +/** + * Data Structure Graph for DSA + * + * @param proc procedure of DSG + * @param constProp + * @param varToSym mapping flow-sensitive (position sensitive) mapping from registers to their set of symbolic accesses + * @param globals + * @param globalOffsets + * @param externalFunctions + * @param reachingDefs + * @param writesTo + * @param params + */ +class Graph(val proc: Procedure, + constProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], + varToSym: Map[CFGPosition, Map[Variable, Set[SymbolicAddress]]], + globals: Set[SymbolTableEntry], + globalOffsets: Map[BigInt, BigInt], + externalFunctions: Set[ExternalFunction], + val reachingDefs: Map[CFGPosition, Map[Variable, Set[CFGPosition]]], + val writesTo: Map[Procedure, Set[Register]], + val params: Map[Procedure, Set[Variable]] + ) { + + // DSNodes owned by this graph, only updated once analysis is done, + val nodes: mutable.Set[Node] = mutable.Set() + + // Points-to relations in this graph, only updated once the analysis is done, + val pointsto: mutable.Map[Cell, Slice] = mutable.Map() + + // represent callees in proc + val callsites: mutable.Set[CallSite] = mutable.Set() + + private val mallocRegister = Register("R0", 64) + + // collect all stack access and their maximum accessed size + // BigInt is the offset of the stack position and Int is it's size + private val stackAccesses: Map[BigInt, Int] = { + computeDomain(IntraProcIRCursor, Set(proc)).toSeq.sortBy(_.toShortString).foldLeft(Map[BigInt, Int]()) { + (results, pos) => + pos match { + case LocalAssign(_, expr, _) => + visitStackAccess(pos, expr, 0).foldLeft(results) { + (res, access) => + if !res.contains(access.offset) || (res.getOrElse(access.offset, -1) < access.size) then + res + (access.offset -> access.size) + else + res + } + case MemoryStore(_, index, _, _, size, _) => + visitStackAccess(pos, index, size).foldLeft(results) { + (res, access) => + if !res.contains(access.offset) || (res.getOrElse(access.offset, -1) < access.size) then + res + (access.offset -> access.size) + else + res + } + case MemoryLoad(_, _, index, _, size, _) => + visitStackAccess(pos, index, size).foldLeft(results) { + (res, access) => + if !res.contains(access.offset) || (res.getOrElse(access.offset, -1) < access.size) then + res + (access.offset -> access.size) + else + res + } + case _ => results + } + } + } + + private case class StackAccess(offset: BigInt, size: Int) + + private def visitStackAccess(pos: CFGPosition, index: Expr, size: Int): Set[StackAccess] = { + assert(size % 8 == 0) + val byteSize = size / 8 + index match + case BinaryExpr(_, arg1: Variable, arg2) if varToSym.contains(pos) && varToSym(pos).contains(arg1) && + evaluateExpression(arg2, constProp(pos)).isDefined => + val offset = evaluateExpression(arg2, constProp(pos)).get.value + varToSym(pos)(arg1).flatMap { + case SymbolicAddress(_, _: StackLocation, symOffset) => // only consider stack accesses + Some(StackAccess(offset + symOffset, byteSize)) + case _ => None + } + case arg: Variable if varToSym.contains(pos) && varToSym(pos).contains(arg) => + varToSym(pos)(arg).flatMap { + case SymbolicAddress(_, _: StackLocation, offset) => + // createStackMapping(pos.toShortString, offset, m, byteSize) + Some(StackAccess(offset, byteSize)) + case _ => + None + } + case _ => Set.empty + } + + // this is the mapping from offsets/positions on the stack to their representative DS nodes + val stackMapping: mutable.Map[BigInt, Node] = mutable.Map() + private var lastOffset: BigInt = -1 + private var nextValidOffset: BigInt = 0 + stackAccesses.keys.toSeq.sorted.foreach { offset => + val byteSize = stackAccesses(offset) + if offset >= nextValidOffset then + val node = Node(Some(this), byteSize) + node.allocationRegions.add(StackLocation(s"Stack_${proc}_$offset", proc, byteSize)) + node.flags.stack = true + node.addCell(0, byteSize) + stackMapping.update(offset, node) + lastOffset = offset + else + val diff = nextValidOffset - offset + stackMapping(lastOffset).addCell(diff, byteSize) + nextValidOffset = offset + byteSize + } + + private val swappedOffsets = globalOffsets.map(_.swap) + + // creates the globals from the symbol tables + val globalMapping = mutable.Map[AddressRange, Field]() + globals.foreach { global => + val node = Node(Some(this), global.size) + node.allocationRegions.add(DataLocation(global.name, global.address, global.size / 8)) + node.flags.global = true + node.flags.incomplete = true + globalMapping.update(AddressRange(global.address, global.address + global.size / 8), Field(node, 0)) + } + + // creates a global for each relocation entry in the symbol table + // the global corresponding to the relocated address points to the global corresponding to the original address + globals.foreach { global => + var address = global.address + breakable { + while (swappedOffsets.contains(address)) { + val relocatedAddress = swappedOffsets(address) + if relocatedAddress == address then + break + + var field: BigInt = 0 + val node: Node = isGlobal(relocatedAddress) match + case Some(value) => + field = relocatedAddress - value.addressRange.start + val node = value.field.node + node.addCell(field, 8) + node + + case None => + val node = Node(Some(this)) + node.allocationRegions.add(DataLocation(s"Relocated_$relocatedAddress", relocatedAddress, 8)) + node.flags.global = true + node.flags.incomplete = true + globalMapping.update(AddressRange(relocatedAddress, relocatedAddress + 8), Field(node, 0)) + node + + node.cells(field).pointee = Some(Slice(isGlobal(address).get.field.node.cells(0), 0)) + address = relocatedAddress + } + } + } + + externalFunctions.foreach { external => + val node = Node(Some(this)) + node.allocationRegions.add(DataLocation(external.name, external.offset, 0)) + node.flags.global = true + node.flags.incomplete = true + globalMapping.update(AddressRange(external.offset, external.offset), Field(node, 0)) + } + + // determine if an address is a global and return the corresponding global if it is. + def isGlobal(address: BigInt): Option[DSAGlobal] = { + var global: Option[DSAGlobal] = None + breakable { + for ((range, field) <- globalMapping) { + if address >= range.start && (address < range.end || (range.start == range.end && range.end == address)) then + global = Some(DSAGlobal(range, field)) + break + } + } + global + } + + def getCells(pos: CFGPosition, arg: Variable): Set[Slice] = { + if (reachingDefs(pos).contains(arg)) { + reachingDefs(pos)(arg).map(definition => varToCell(definition)(arg)) + } else { + Set(formals(arg)) + } + } + + + /** + * collects all the nodes that are currently in the DSG and updates nodes member variable + */ + def collectNodes(): Unit = { + nodes.clear() + pointsto.clear() + nodes.addAll(formals.values.map(n => find(n.cell.node.get).node)) + varToCell.values.foreach { + value => nodes.addAll(value.values.map(n => find(n.cell.node.get).node)) + } + nodes.addAll(stackMapping.values.map(n => find(n).node)) + nodes.addAll(globalMapping.values.map(n => find(n.node).node)) + + val queue: mutable.Queue[Node] = mutable.Queue() + queue.enqueueAll(nodes) + while (queue.nonEmpty) { + val cur = queue.dequeue() + cur.cells.values.foreach { cell => + if (cell.pointee.isDefined) { + val node = find(cell.getPointee.node).node + if !nodes.contains(node) then + nodes.add(node) + queue.enqueue(node) + assert(!pointsto.contains(cell)) + pointsto.update(cell, find(cell.getPointee)) + } + } + } + } + + def toDot: String = { + collectNodes() + + val structs = ArrayBuffer[DotStruct]() + val arrows = ArrayBuffer[StructArrow]() + + nodes.foreach { n => + structs.append(DotStruct(n.id.toString, n.toString, Some(n.cells.keys.map(o => o.toString)))) + } + + formals.keys.foreach { variable => + var varName = variable.name + if (varName.startsWith("#")) { + varName = s"LocalVar_${varName.drop(1)}" + } + structs.append(DotStruct(s"Formal_${varName}", s"Formal_${varName}", None)) + } + + pointsto.foreach { (cell, pointee) => + val pointerID = cell.node.get.id.toString + val pointerOffset = cell.offset.toString + arrows.append(StructArrow(DotStructElement(pointerID, Some(pointerOffset)), DotStructElement(pointee.node.id.toString, Some(pointee.cell.offset.toString)), pointee.internalOffset.toString)) + } + + formals.foreach { (variable, slice) => + val value = find(slice) + arrows.append(StructArrow(DotStructElement(s"Formal_${variable.name}", None), DotStructElement(value.node.id.toString, Some(value.cell.offset.toString)), value.internalOffset.toString)) + } + + varToCell.foreach { (pos, mapping) => + var id = pos match { + case p: Procedure => p.name + case b: Block => b.label + case c: Command => c.label.getOrElse("") + } + if (id.startsWith("%")) { + id = id.drop(1) + } + mapping.foreach { (variable, slice) => + var varName = variable.name + if (varName.startsWith("#")) { + varName = s"LocalVar_${varName.drop(1)}" + } + structs.append(DotStruct(s"SSA_${id}_$varName", s"SSA_${pos}_$varName", None, false)) + val value = find(slice) + arrows.append(StructArrow(DotStructElement(s"SSA_${id}_$varName", None), DotStructElement(value.node.id.toString, Some(value.cell.offset.toString)), value.internalOffset.toString)) + } + } + + globalMapping.foreach { (range, field) => + structs.append(DotStruct(s"Global_${range.start}_${range.end}", s"Global_$range", None)) + val node = find(field.node).node + val offset = field.offset + find(field.node).offset + val cellOffset = node.getCell(offset).offset + val internalOffset = offset - cellOffset + arrows.append(StructArrow(DotStructElement(s"Global_${range.start}_${range.end}", None), DotStructElement(node.id.toString, Some(cellOffset.toString)), internalOffset.toString)) + } + + stackMapping.foreach { (offset, dsn) => + structs.append(DotStruct(s"Stack_$offset", s"Stack_$offset", None)) + val node = find(dsn).node + val nodeOffset = find(dsn).offset + val cellOffset = node.getCell(nodeOffset).offset + val internalOffset = nodeOffset - cellOffset + arrows.append(StructArrow(DotStructElement(s"Stack_$offset", None), DotStructElement(node.id.toString, Some(cellOffset.toString)), internalOffset.toString)) + } + + StructDotGraph(proc.name, structs, arrows).toDotString + } + + + /** + * Collapses the node causing it to lose field sensitivity + */ + def collapseNode(n: Node): Node = { + val (term, _) = solver.findWithOffset(n.term) + val node: Node = term.node + + if (!(n.collapsed || find(n).node.collapsed)) { + val collapsedNode: Node = Node(n.graph) + val collapsedCell = Cell(Some(collapsedNode), 0) + + n.flags.collapsed = true + collapsedNode.flags.collapsed = true + + var pointeeInternalOffset: BigInt = 0 + var pointToItself = false + val cells = node.cells.values + var cell = cells.tail.foldLeft(adjust(cells.head.getPointee)) { (c, cell) => + val pointee = cell.pointee + if (pointee.isDefined && adjust(cell.getPointee) == cell) { + pointToItself = true + c + } else if (pointee.isDefined) { + val slice = cell.getPointee + if (slice.internalOffset > pointeeInternalOffset) { + pointeeInternalOffset = slice.internalOffset + } + mergeCells(c, adjust(slice)) + } else { + c + } + } + + if (pointToItself) { + cell = mergeCells(cell, collapsedCell) + } + + collapsedCell.pointee = Some(Slice(collapsedCell, 0)) + + assert(collapsedNode.cells.size == 1) + + collapsedNode.children.addAll(node.children) + collapsedNode.children += (node -> 0) + collapsedNode.allocationRegions.addAll(node.allocationRegions) // add regions and flags of node 1 to node 2 + collapsedNode.flags.join(node.flags) + + solver.unify(n.term, collapsedNode.term, 0) + + collapsedNode + } else { + assert(find(n).node.collapsed) + find(n).node + } + } + + + /** + * this function merges all the overlapping cells in the given node + * The node DOESN'T lose field sensitivity after this + */ + def selfCollapse(node: Node): Unit = { + var lastOffset: BigInt = -1 + var lastAccess: BigInt = -1 + val removed = mutable.Set[BigInt]() + val sortedOffsets = node.cells.keys.toSeq.sorted + sortedOffsets.foreach { offset => + val cell = node.cells(offset) + if (lastOffset + lastAccess > offset) { + val result = mergeNeighbours(node.cells(lastOffset), cell) + removed.add(offset) + lastAccess = result.largestAccessedSize + } else { + lastOffset = offset + lastAccess = cell.largestAccessedSize + } + } + removed.foreach(node.cells.remove) + } + + /** + * merges two neighbouring cells into one + */ + private def mergeNeighbours(cell1: Cell, cell2: Cell): Cell = { + require(cell1.node.equals(cell2.node) && cell1.offset < cell2.offset) + if (cell2.pointee.isDefined) { + if (cell1.pointee.isDefined) { + val slice1 = cell1.getPointee + val slice2 = cell2.getPointee + val result = mergeCells(adjust(slice1), adjust(slice2)) + cell1.pointee = Some(Slice(result, slice2.internalOffset.max(slice1.internalOffset))) + } else { + cell1.pointee = cell2.pointee + } + } + val internalOffsetChange = cell2.offset - cell1.offset + cell2.node.get.cells.remove(cell2.offset) + cell1.growSize((cell2.offset - cell1.offset).toInt + cell2.largestAccessedSize) // might cause another collapse + cell1 + } + + // private val parent = mutable.Map[DSC, DSC]() + val solver: DSAUnionFindSolver = DSAUnionFindSolver() + + /** + * wrapper for find functionality of the union-find + * @param node the node to perform find on + * @return a field which is the tuple (parent node of the input node, starting offset of the input node in its parent) + */ + def find(node: Node): Field = { + val (n, offset) = solver.findWithOffset(node.term) + val resultNode = n.node + Field(resultNode, offset) + } + + /** + * wrapper for find functionality of the union-find + * + * @param cell the cell to perform find on + * @return the input cell's equivalent cell in the parent + */ + def find(cell: Cell): Cell = { + val node = cell.node.get + val parent: Field = find(node) + parent.node.addCell(cell.offset + parent.offset, cell.largestAccessedSize) + } + + def find(slice: Slice): Slice = deadjust(adjust(slice)) + + /** + * merges two cells and unifies their nodes + * @param cell1 + * @param cell2 + * @return the resulting cell in the unified node + */ + def mergeCells(c1: Cell, c2: Cell): Cell = { + var cell1 = c1 + var cell2 = c2 + if c1.node.isDefined then + cell1 = find(c1) + + if c2.node.isDefined then + cell2 = find(c2) + + if cell1.equals(cell2) then // same cell no action required + cell1 + else if cell1.node.isDefined && cell1.node.equals(cell2.node) then // same node different cells causes collapse + val ne = collapseNode(cell1.node.get) + ne.cells(0) + else if cell1.node.isEmpty then + ??? // not sure how to handle this yet TODO possibly take it out of the merge? + cell2 + else if cell1.node.get.collapsed || cell2.node.get.collapsed then // a collapsed node + + var node1 = cell1.node.get + var node2 = cell2.node.get + + assert(node1.collapsed || node2.collapsed) + + node1 = collapseNode(node1) // collapse the other node + node2 = collapseNode(node2) + node2.children.addAll(node1.children) + node2.children += (node1 -> 0) + node2.allocationRegions.addAll(node1.allocationRegions) // add regions and flags of node 1 to node 2 + node2.flags.join(node1.flags) + if node1.cells(0).pointee.isDefined then // merge the pointees of the two collapsed (single cell) nodes + if node2.cells(0).pointee.isDefined then + val slice1 = node1.cells(0).getPointee + val slice2 = node2.cells(0).getPointee + val result = mergeCells(adjust(slice1), adjust(slice2)) + node2.cells(0).pointee = Some(Slice(result, slice1.internalOffset.max(slice2.internalOffset))) + else + node2.cells(0).pointee = node1.cells(0).pointee + // node1.cells(0).pointee = None + // replace(node1.cells(0), node2.cells(0), 0) + solver.unify(node1.term, node2.term, 0) + node2.cells(0) + else // standard merge + + // node 1 is the cell with the higher offset + + var delta = cell1.offset - cell2.offset + var node1 = cell1.node.get + var node2 = cell2.node.get + if cell1.offset < cell2.offset then + delta = cell2.offset - cell1.offset + node1 = cell2.node.get + node2 = cell1.node.get + + + // create a seq of all cells from both nodes in order of their offsets in the resulting unified node + + val node2CellsOffset = node2.cells.toSeq.map((offset, cell) => (offset + delta, cell)) + + val cells: Seq[(BigInt, Cell)] = (node1.cells.toSeq ++ node2CellsOffset).sortBy(_(0)) + + var lastOffset: BigInt = -1 + var lastAccess: Int = -1 + // create a new node to represent the unified node + val resultNode = Node(Some(this)) + // add nodes flags and regions to the resulting node + resultNode.allocationRegions.addAll(node1.allocationRegions ++ node2.allocationRegions) + resultNode.flags.join(node1.flags) + resultNode.flags.join(node2.flags) + resultNode.children.addAll(node1.children) + resultNode.children += (node1 -> 0) + node2.children.keys.foreach { k => + resultNode.children(k) = node2.children(k) + delta + } + resultNode.children += (node2 -> delta) + if node2.flags.global then // node 2 may have been adjusted depending on cell1 and cell2 offsets + globalMapping.foreach { // update global mapping if node 2 was global + case (range: AddressRange, Field(node, offset)) => + if node.equals(node2) then + globalMapping.update(range, Field(node, offset + delta)) + } + + // compute the cells present in the resulting unified node + // a mapping from offsets to the set of old cells which are merged to form a cell in the new unified node + // values in the mapping also include the largest access size so far computed for each resulting cell + val resultCells = mutable.Map[BigInt, mutable.Set[Cell]]() + val resultLargestAccesses = mutable.Map[BigInt, Int]() + cells.foreach { (offset, cell) => + if ((lastOffset + lastAccess > offset) || lastOffset == offset) { // includes this cell + if ((offset - lastOffset) + cell.largestAccessedSize > lastAccess) { + lastAccess = (offset - lastOffset).toInt + cell.largestAccessedSize + } + if (resultCells.contains(lastOffset)) { + resultCells(lastOffset).addOne(cell) + } else { + resultCells(lastOffset) = mutable.Set(cell) + } + resultLargestAccesses(lastOffset) = lastAccess + } else { + lastOffset = offset + lastAccess = cell.largestAccessedSize + resultCells(lastOffset) = mutable.Set(cell) + resultLargestAccesses(lastOffset) = lastAccess + } + } + + resultCells.keys.foreach { offset => + val collapsedCell = resultNode.addCell(offset, resultLargestAccesses(offset)) + val outgoing: Set[Slice] = cells.flatMap { (_, cell) => + if (cell.pointee.isDefined) { + Some(cell.getPointee) + } else { + None + } + }.toSet + // replace outgoing edges + if (outgoing.size == 1) { + collapsedCell.pointee = Some(outgoing.head) + } else if (outgoing.size > 1) { + val result = outgoing.tail.foldLeft(adjust(outgoing.head)) { + (result, pointee) => + mergeCells(result, adjust(pointee)) + } + collapsedCell.pointee = Some(deadjust(result)) + } + } + + solver.unify(node1.term, resultNode.term, 0) + solver.unify(node2.term, resultNode.term, delta) + if cell1.offset >= cell2.offset then + resultNode.getCell(cell1.offset) + else + resultNode.getCell(cell2.offset) + } + + def adjust(cell: Cell, internalOffset: BigInt): Cell = { + val (term, linkOffset) = solver.findWithOffset(cell.node.get.term) + val node = term.node + node.addCell(cell.offset + internalOffset + linkOffset, 0) + } + + def adjust(slice: Slice, offset: BigInt = 0): Cell = { + val cell = slice.cell + val internal = slice.internalOffset + adjust(cell, internal + offset) + } + + def deadjust(cell: Cell): Slice = { + val node = cell.node.get + val offset = cell.offset + selfCollapse(node) + val newCell = node.getCell(offset) + assert(offset >= newCell.offset) + Slice(newCell, offset - newCell.offset) + } + + private def isFormal(pos: CFGPosition, variable: Variable): Boolean = !reachingDefs(pos).contains(variable) + + // formal arguments to this function + val formals: mutable.Map[Variable, Slice] = mutable.Map() + + // mapping from each SSA variable (position, variable) to a slice + val varToCell: mutable.Map[CFGPosition, mutable.Map[Variable, Slice]] = varToCellInit(proc) + + private def varToCellInit(proc: Procedure): mutable.Map[CFGPosition, mutable.Map[Variable, Slice]] = { + val varToCell = mutable.Map[CFGPosition, mutable.Map[Variable, Slice]]() + val domain = computeDomain(IntraProcIRCursor, Set(proc)) + domain.foreach { + case pos @ LocalAssign(variable, value, _) => + value.variables.foreach { v => + if (isFormal(pos, v)) { + val node = Node(Some(this)) + node.flags.incomplete = true + nodes.add(node) + formals.update(v, Slice(node.cells(0), 0)) + } + } + val node = Node(Some(this)) + varToCell(pos) = mutable.Map(variable -> Slice(node.cells(0), 0)) + case pos @ MemoryLoad(lhs, _, index, _, _, _) => + index.variables.foreach { v => + if (isFormal(pos, v)) { + val node = Node(Some(this)) + node.flags.incomplete = true + nodes.add(node) + formals.update(v, Slice(node.cells(0), 0)) + } + } + val node = Node(Some(this)) + varToCell(pos) = mutable.Map(lhs -> Slice(node.cells(0), 0)) + case pos @ DirectCall(target, _, _, _) if target.name == "malloc" => + val node = Node(Some(this)) + varToCell(pos) = mutable.Map(mallocRegister -> Slice(node.cells(0), 0)) + case pos @ DirectCall(target, _, _, _) if writesTo.contains(target) => + val result = mutable.Map[Variable, Slice]() + writesTo(target).foreach { variable => + val node = Node(Some(this)) + result(variable) = Slice(node.cells(0), 0) + } + varToCell(pos) = result + case pos @ MemoryStore(_, _, expr, _, _, _) => + unwrapPaddingAndSlicing(expr) match { + case value: Variable => + if (isFormal(pos, value)) { + val node = Node(Some(this)) + node.flags.incomplete = true + nodes.add(node) + formals.update(value, Slice(node.cells(0), 0)) + } + case _ => + } + case _ => + } + varToCell + } + + def cloneSelf(): Graph = { + val newGraph = Graph(proc, constProp, varToSym, globals, globalOffsets, externalFunctions, reachingDefs, writesTo, params) + assert(formals.size == newGraph.formals.size) + val nodes = mutable.Set[Node]() + val idToNode: mutable.Map[Int, Node] = mutable.Map() + formals.foreach { (variable, slice) => + // assert(newGraph.formals.contains(variable)) + val node = find(slice).node + nodes.add(node) + if !idToNode.contains(node.id) then + val newNode = node.cloneSelf(newGraph) + idToNode.update(node.id, newNode) + newGraph.formals.update(variable, Slice(idToNode(node.id).cells(slice.offset), slice.internalOffset)) + } + + varToCell.foreach { (position, values) => + // assert(newGraph.varToCell.contains(position)) + if (!newGraph.varToCell.contains(position)) { + newGraph.varToCell.update(position, mutable.Map[Variable, Slice]()) + } + values.foreach { (variable, s) => + // assert(newGraph.varToCell(position).contains(variable)) + val slice = find(s) + val node = slice.node + nodes.add(node) + if (!idToNode.contains(node.id)) { + val newNode = node.cloneSelf(newGraph) + idToNode.update(node.id, newNode) + } + newGraph.varToCell(position).update(variable, Slice(idToNode(node.id).cells(slice.offset), slice.internalOffset)) + } + } + + stackMapping.foreach { (offset, oldNode) => + val node = find(oldNode).node + nodes.add(node) + assert(newGraph.stackMapping.contains(offset)) + if !idToNode.contains(node.id) then + val newNode = node.cloneSelf(newGraph) + idToNode.update(node.id, newNode) + newGraph.stackMapping.update(offset, idToNode(node.id)) + } + + globalMapping.foreach { case (range: AddressRange, Field(node, offset)) => + assert(newGraph.globalMapping.contains(range)) + val field = find(node) + nodes.add(field.node) + if !idToNode.contains(field.node.id) then + val newNode = node.cloneSelf(newGraph) + idToNode.update(field.node.id, newNode) + newGraph.globalMapping.update(range, Field(idToNode(field.node.id), field.offset + offset)) + } + + val queue = mutable.Queue[Node]() + queue.addAll(nodes) + while (queue.nonEmpty) { + val node = queue.dequeue() + node.cells.values.foreach { cell => + if (cell.pointee.isDefined) { + val id = cell.node.get.id + val pointee = find(cell.getPointee) + val pointeeId = pointee.node.id + if (!idToNode.contains(pointeeId)) { + queue.enqueue(pointee.node) + val newNode = pointee.node.cloneSelf(newGraph) + idToNode.update(pointeeId, newNode) + } + idToNode(id).cells(cell.offset).pointee = Some(Slice(idToNode(pointeeId).cells(pointee.offset), pointee.internalOffset)) + } + } + } + + callsites.foreach { callSite => + val cs = CallSite(callSite.call, newGraph) + newGraph.callsites.add(cs) + assert(cs.paramCells.keySet.equals(callSite.paramCells.keySet)) + callSite.paramCells.foreach { (variable, oldSlice) => + val slice = find(oldSlice) + assert(cs.paramCells.contains(variable)) + val id = slice.node.id + cs.paramCells.update(variable, Slice(idToNode(id).cells(slice.offset), slice.internalOffset)) + } + + callSite.returnCells.foreach { (variable, oldSlice) => + val slice = find(oldSlice) + assert(cs.returnCells.contains(variable)) + val id = slice.node.id + cs.returnCells.update(variable, Slice(idToNode(id).cells(slice.offset), slice.internalOffset)) + } + } + + newGraph.nodes.addAll(idToNode.values) + newGraph + } +} diff --git a/src/main/scala/analysis/data_structure_analysis/LocalPhase.scala b/src/main/scala/analysis/data_structure_analysis/LocalPhase.scala new file mode 100644 index 000000000..e28778e52 --- /dev/null +++ b/src/main/scala/analysis/data_structure_analysis/LocalPhase.scala @@ -0,0 +1,369 @@ +package analysis.data_structure_analysis + +import ir.eval.BitVectorEval.{bv2SignedInt, isNegative} +import analysis.* +import ir.* +import boogie.SpecGlobal +import specification.{ExternalFunction, SymbolTableEntry} +import util.writeToFile + +import java.math.BigInteger +import scala.collection.mutable +import scala.util.control.Breaks.{break, breakable} + +/** + * The local phase of Data Structure Analysis + * @param proc procedure to be analysed + * @param symResults result of symbolic access analysis + * @param constProp + * @param globals + * @param globalOffsets + * @param externalFunctions + * @param reachingDefs + * @param writesTo mapping from procedures to registers they change + * @param params mapping from procedures to their parameters + */ +class LocalPhase(proc: Procedure, + symResults: Map[CFGPosition, Map[SymbolicAddress, TwoElement]], + constProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], + globals: Set[SymbolTableEntry], globalOffsets: Map[BigInt, BigInt], + externalFunctions: Set[ExternalFunction], + reachingDefs: Map[CFGPosition, Map[Variable, Set[CFGPosition]]], + writesTo: Map[Procedure, Set[Register]], + params: Map[Procedure, Set[Variable]] + ) extends Analysis[Any] { + + private val mallocRegister = Register("R0", 64) + private val stackPointer = Register("R31", 64) + + // set of cfg positions already processed by the analysis local phase + private val visited: mutable.Set[CFGPosition] = mutable.Set() + + val varToSym: Map[CFGPosition, Map[Variable, Set[SymbolicAddress]]] = symResults.map { (position, innerMap) => + val newMap = innerMap.keys.foldLeft(Map[Variable, Set[SymbolicAddress]]()) { (m, access) => + if (m.contains(access.accessor)) { + // every variable pointing to a stack region ONLY has one symbolic access associated with it. + // m(access.accessor).foreach( + // sym => + // if (sym.symbolicBase.isInstanceOf[StackLocation]) then + // println(m) + // println(access.accessor) + // println(access) + // print("") + // //assert(!sym.symbolicBase.isInstanceOf[StackLocation]) + // ) + // assert(!access.symbolicBase.isInstanceOf[StackLocation]) + m + (access.accessor -> (m(access.accessor) + access)) + } else { + m + (access.accessor -> Set(access)) + } + } + position -> newMap + } + + private def getStack(offset: BigInt): Cell = { + var last: BigInt = 0 + if graph.stackMapping.contains(offset) then + graph.stackMapping(offset).cells(0) + else + breakable { + graph.stackMapping.keys.foreach { + elementOffset => + if offset < elementOffset then + break + else + last = elementOffset + } + } + val diff = offset - last + assert(graph.stackMapping.contains(last)) + graph.stackMapping(last).getCell(diff) + } + + /** + * if an expr is the address of a stack location return its corresponding cell + * @param pos IL position where the expression is used + */ + private def isStack(expr: Expr, pos: CFGPosition): Option[Cell] = { + expr match + case BinaryExpr(_, arg1: Variable, arg2) if varToSym.contains(pos) && varToSym(pos).contains(arg1) && + varToSym(pos)(arg1).exists(s => s.symbolicBase.isInstanceOf[StackLocation]) => + evaluateExpression(arg2, constProp(pos)) match + case Some(v) => + val stackRegions = varToSym(pos)(arg1).filter(s => s.symbolicBase.isInstanceOf[StackLocation]) + val res = stackRegions.tail.foldLeft(getStack(v.value + stackRegions.head.offset)) { + (res, sym) => + graph.mergeCells(res, getStack(v.value + sym.offset)) + } + Some(res) + case None => None + case arg: Variable if varToSym.contains(pos) && varToSym(pos).contains(arg) && + varToSym(pos)(arg).exists(s => s.symbolicBase.isInstanceOf[StackLocation]) => + val stackRegions = varToSym(pos)(arg).filter(s => s.symbolicBase.isInstanceOf[StackLocation]) + val res = stackRegions.tail.foldLeft(getStack(stackRegions.head.offset)) { + (res, sym) => + graph.mergeCells(res, getStack(sym.offset)) + } + Some(res) + case _ => None + } + + var mallocCount: Int = 0 + + private def nextMallocCount = { + mallocCount += 1 + s"malloc_$mallocCount" + } + + val graph: Graph = Graph(proc, constProp, varToSym, globals, globalOffsets, externalFunctions, reachingDefs, writesTo, params) + + /** + * if an expr is the address of a global location return its corresponding cell + * @param pos IL position where the expression is used + */ + def isGlobal(expr: Expr, pos: CFGPosition, size: Int = 0): Option[Cell] = { + val value = evaluateExpression(expr, constProp(pos)) + if value.isDefined then + val global = graph.isGlobal(value.get.value) + if global.isDefined then + val address = value.get.value + val DSAGlobal(range: AddressRange, Field(node, internal)) = global.get + val offset = address - range.start + node.addCell(internal + offset, size) + graph.selfCollapse(node) + if node.collapsed then + Some(node.cells(0)) + else + Some(node.getCell(internal + offset)) + else + None + else + None + } + + /** + * Handles unification for instructions of the form R_x = R_y [+ offset] where R_y is a pointer and [+ offset] is optional + * @param position the cfg position being visited (note this might be a local assign of the form R_x = R_y [+ offset] + * or it might be memory load/store where the index is of the form R_y [+ offset] + * @param lhs Ev(R_x) if position is local assign or a cell from an empty node if R_y [+ offset] is the index of a memoryStore + * @param rhs R_y, reachingDefs(position)(R_y) can be used to find the set of SSA variables that may define R_x + * @param pointee if false, the position is local pointer arithmetic therefore Ev(R_y [+ offset]) is merged with lhs + * else, the position is a memory read/write therefore E(Ev(R_y [+ offset])) is merged with lhs + * @param offset offset if [+ offset] is present + * @return the cell resulting from the unification + */ + private def visitPointerArithmeticOperation(position: CFGPosition, lhs: Cell, rhs: Variable, size: Int, pointee: Boolean = false, offset: BigInt = 0, collapse: Boolean = false): Cell = + // visit all the defining pointer operation on rhs variable first + reachingDefs(position)(rhs).foreach(visit) + // get the cells of all the SSA variables in the set + val cells: Set[Slice] = graph.getCells(position, rhs).foldLeft(Set[Slice]()) { + (col, slice) => + col + Slice(graph.find(slice.cell), slice.internalOffset) + } + // merge the cells or their pointees with lhs + var result = cells.foldLeft(lhs) { + (c, t) => + val cell = t.cell + val internalOffset = t.internalOffset + if !collapse then // offset != 0 then // it's R_x = R_y + offset + val node = cell.node.get // get the node of R_y + var field = offset + cell.offset + internalOffset // calculate the total offset + node.addCell(field, size) // add cell there if doesn't already exists + if node.collapsed then + field = 0 + graph.mergeCells(c, + if pointee then + graph.adjust(node.getCell(field).getPointee) + else + node.getCell(field) + ) + else + var node = cell.node.get + node = graph.collapseNode(node) + graph.mergeCells(c, if pointee then graph.adjust(node.cells(0).getPointee) else node.cells(0)) + + } + if pointee then + cells.foreach { t => + val offset = t.cell.offset + val internalOffset = t.internalOffset + val node = t.cell.node.get + val cell = graph.find(node.getCell(offset + internalOffset)) + if cell.pointee.isDefined && graph.find(cell.getPointee.cell).equals(result) then + graph.selfCollapse(node) + // assert(graph.pointTo.contains(node.getCell(offset))) TODO + result = graph.find(graph.find(node.getCell(offset)).getPointee.cell) + else + graph.selfCollapse(node) + } + val resultOffset = result.offset + graph.selfCollapse(result.node.get) + result.node.get.getCell(result.offset) + + /** + * handles unsupported pointer arithmetic by collapsing all the nodes invloved + */ + private def unsupportedPointerArithmeticOperation(n: CFGPosition, expr: Expr, lhsCell: Cell): Cell = { + val cell = expr.variables.foldLeft(lhsCell) { + (c, v) => + val cells: Set[Slice] = graph.getCells(n, v) + + cells.foldLeft(c) { + (c, p) => + graph.mergeCells(c, p.cell) + } + } + + val node = cell.node.get + node.flags.unknown = true + graph.collapseNode(node) + + node.cells(0) + } + + def visit(n: CFGPosition): Unit = { + if visited.contains(n) then + return + else + visited.add(n) + n match + case DirectCall(target, _, _, _) if target.name == "malloc" => // R0 = Malloc() + val size: BigInt = evaluateExpression(mallocRegister, constProp(n)) match + case Some(value) => value.value + case None => 0 + val node = Node(Some(graph), size) + node.allocationRegions.add(HeapLocation(nextMallocCount, target, size)) + node.flags.heap = true + graph.mergeCells(graph.varToCell(n)(mallocRegister).cell, node.cells(0)) + case call: DirectCall if params.contains(call.target) => // Rx, Ry, ... Rn = FunctionCall() + // create call sites for the callees + val cs = CallSite(call, graph) + graph.callsites.add(cs) + cs.paramCells.foreach { (variable, slice) => + visitPointerArithmeticOperation(call, graph.adjust(slice), variable, 0) + } + cs.returnCells.foreach { (variable, slice) => + val returnArgument = graph.varToCell(n)(variable) + graph.mergeCells(graph.adjust(returnArgument), graph.adjust(slice)) + } + case LocalAssign(variable, rhs, _) => + val expr: Expr = unwrapPaddingAndSlicing(rhs) + val lhsCell = graph.adjust(graph.varToCell(n)(variable)) + val global = isGlobal(rhs, n) + val stack = isStack(rhs, n) + if global.isDefined then // Rx = global address + graph.mergeCells(lhsCell, global.get) + else if stack.isDefined then // Rx = stack address + graph.mergeCells(lhsCell, stack.get) + else + expr match + case BinaryExpr(op, arg1: Variable, arg2) if op.equals(BVADD) => // Rx = Rx + c + val arg2Offset = evaluateExpression(arg2, constProp(n)) + if op.equals(BVADD) && arg1.equals(stackPointer) + && arg2Offset.isDefined && isNegative(arg2Offset.get) then + () // the stack is handled prior to this + else if /*varToSym.contains(n) && varToSym(n).contains(arg1) && */ arg2Offset.isDefined then + // merge lhs with cell(s) corresponding to (arg1 + arg2) where arg1 is cell and arg2 is an offset + val offset = evaluateExpression(arg2, constProp(n)).get.value + visitPointerArithmeticOperation(n, lhsCell, arg1, 0, false, offset) + else // c can't be statically evaluated + unsupportedPointerArithmeticOperation(n, expr, lhsCell) + + // Rx = Ry merge corresponding cells to Rx and Ry + case arg: Variable /*if varToSym.contains(n) && varToSym(n).contains(arg)*/ => + visitPointerArithmeticOperation(n, lhsCell, arg, 0) + case _ => + unsupportedPointerArithmeticOperation(n, expr, lhsCell) + + case MemoryLoad(lhs, _, index, _, size, _) => // Rx = Mem[Ry], merge Rx and pointee of Ry (E(Ry)) + val indexUnwrapped = unwrapPaddingAndSlicing(index) + val lhsCell = graph.adjust(graph.varToCell(n)(lhs)) + assert(size % 8 == 0) + val byteSize = size / 8 + lhsCell.node.get.flags.read = true + val global = isGlobal(indexUnwrapped, n, byteSize) + val stack = isStack(indexUnwrapped, n) + if global.isDefined then + graph.mergeCells(lhsCell, graph.adjust(graph.find(global.get).getPointee)) + else if stack.isDefined then + graph.mergeCells(lhsCell, graph.adjust(graph.find(stack.get).getPointee)) + else + indexUnwrapped match + case BinaryExpr(op, arg1: Variable, arg2) if op.equals(BVADD) => + evaluateExpression(arg2, constProp(n)) match + case Some(v) => + // assert(varToSym(n).contains(arg1)) + val offset = v.value + visitPointerArithmeticOperation(n, lhsCell, arg1, byteSize, true, offset) + case None => + // assert(varToSym(n).contains(arg1)) + // collapse the result + // visitPointerArithmeticOperation(n, lhsCell, arg1, byteSize, true, 0, true) + unsupportedPointerArithmeticOperation(n, indexUnwrapped, Node(Some(graph)).cells(0)) + case arg: Variable => + // assert(varToSym(n).contains(arg)) + visitPointerArithmeticOperation(n, lhsCell, arg, byteSize, true) + case _ => ??? + case MemoryStore(_, ind, expr, _, size, _) => + val unwrapped = unwrapPaddingAndSlicing(expr) + unwrapped match { + // Mem[Ry] = Rx + case value: Variable => + val index: Expr = unwrapPaddingAndSlicing(ind) + reachingDefs(n)(value).foreach(visit) + assert(size % 8 == 0) + val byteSize = size / 8 + val global = isGlobal(index, n, byteSize) + val stack = isStack(index, n) + val addressPointee: Cell = + if global.isDefined then + graph.adjust(graph.find(global.get).getPointee) + else if stack.isDefined then + graph.adjust(graph.find(stack.get).getPointee) + else + index match + case BinaryExpr(op, arg1: Variable, arg2) if op.equals(BVADD) => + evaluateExpression(arg2, constProp(n)) match + case Some(v) => + // assert(varToSym(n).contains(arg1)) + val offset = v.value + visitPointerArithmeticOperation(n, Node(Some(graph)).cells(0), arg1, byteSize, true, offset) + case None => + // assert(varToSym(n).contains(arg1)) + // collapse the results + // visitPointerArithmeticOperation(n, DSN(Some(graph)).cells(0), arg1, byteSize, true, 0, true) + unsupportedPointerArithmeticOperation(n, index, Node(Some(graph)).cells(0)) + case arg: Variable => + // assert(varToSym(n).contains(arg)) + visitPointerArithmeticOperation(n, Node(Some(graph)).cells(0), arg, byteSize, true) + case _ => + ??? + + addressPointee.node.get.flags.modified = true + val valueCells = graph.getCells(n, value) + val result = valueCells.foldLeft(addressPointee) { (c, slice) => + graph.mergeCells(graph.adjust(slice), c) + } + case _ => // if value is a literal ignore it + } + case _ => + + } + def analyze(): Graph = { + val domain = computeDomain(IntraProcIRCursor, Set(proc)).toSeq.sortBy(_.toShortString) + + domain.foreach(visit) + + val b = graph.solver.solution() + graph.collectNodes() + // graph.nodes.foreach(node => + // node.children.foreach( + // child => + // assert(graph.solver.find(child._1.term).equals(graph.solver.find(node.term))) + // assert(graph.solver.find(child._1.term)._2.equals(child._2)) + // + // ) + // ) + graph + } +} diff --git a/src/main/scala/analysis/data_structure_analysis/SymbolicAddressAnalysis.scala b/src/main/scala/analysis/data_structure_analysis/SymbolicAddressAnalysis.scala new file mode 100644 index 000000000..ddb47d372 --- /dev/null +++ b/src/main/scala/analysis/data_structure_analysis/SymbolicAddressAnalysis.scala @@ -0,0 +1,157 @@ +package analysis.data_structure_analysis + +import ir.eval.BitVectorEval.{bv2SignedInt, isNegative} +import analysis.solvers.ForwardIDESolver +import analysis.* +import ir.* + +import java.math.BigInteger + +case class SymbolicAddress(accessor: Variable, symbolicBase: MemoryLocation, offset: BigInt) { + override def toString: String = s"SymbolicAddress($accessor, $symbolicBase, $offset)" +} + +trait MemoryLocation { + val regionIdentifier: String + + override def toString: String = s"MemoryRegion($regionIdentifier)" +} + +case class StackLocation(override val regionIdentifier: String, proc: Procedure, size: BigInt) extends MemoryLocation { + override def toString: String = s"Stack($regionIdentifier, $size)" +} + +case class HeapLocation(override val regionIdentifier: String, proc: Procedure, size: BigInt) extends MemoryLocation { + override def toString: String = s"Heap($regionIdentifier, $size)" +} + +case class DataLocation(override val regionIdentifier: String, start: BigInt, size: BigInt) extends MemoryLocation { + override def toString: String = s"Data($regionIdentifier, $start, $size)" +} + +case class UnknownLocation(override val regionIdentifier: String, proc: Procedure) extends MemoryLocation { + override def toString: String = s"Unknown($regionIdentifier)" +} + +/** + * environment transformers for SAA or symbolic access analysis + * Combination of reaching definitions and constant propagation + * elements in D are symbolic accesses of the form (variable, symbolic base, concrete offset) + * lattice L is a binary lattice with top being the definition is valid (alive) and bottom being + * the definition is dead or no longer affects the environment + */ +trait SymbolicAddressFunctions(constProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]]) extends ForwardIDEAnalysis[SymbolicAddress, TwoElement, TwoElementLattice] { + + private val stackPointer = Register("R31", 64) + private val mallocVariable = Register("R0", 64) + + var mallocCount: Int = 0 + private def nextMallocCount = { + mallocCount += 1 + s"malloc_$mallocCount" + } + + var unknownCount: Int = 0 + private def nextunknownCount = { + unknownCount += 1 + s"unknown_$unknownCount" + } + + val valuelattice: TwoElementLattice = TwoElementLattice() + val edgelattice: EdgeFunctionLattice[TwoElement, TwoElementLattice] = EdgeFunctionLattice(valuelattice) + import edgelattice.{ConstEdge, IdEdge} + + def edgesCallToEntry(call: DirectCall, entry: Procedure)(d: DL): Map[DL, EdgeFunction[TwoElement]] = + d match + case Left(value) => + value.symbolicBase match + case _: StackLocation => Map() + case _ => Map(d -> IdEdge()) + case Right(_) => Map(d -> IdEdge()) + + def edgesExitToAfterCall(exit: Return, aftercall: Command)(d: DL): Map[DL, EdgeFunction[TwoElement]] = + d match + case Left(value) => + value.symbolicBase match + case _: StackLocation => Map() + case _ => + if value.accessor.name == "R29" then Map() + else Map(d -> IdEdge()) + case Right(_) => Map(d -> IdEdge()) + + def edgesCallToAfterCall(call: DirectCall, aftercall: Command)(d: DL): Map[DL, EdgeFunction[TwoElement]] = + d match + case Left(value) => + value.symbolicBase match + case _: StackLocation => Map(d -> IdEdge()) + case _ => Map() // maps all variables before the call to bottom + case Right(_) => Map(d -> IdEdge()) + + def edgesOther(n: CFGPosition)(d: DL): Map[DL, EdgeFunction[TwoElement]] = + n match + case LocalAssign(variable, rhs, _) => + val expr = unwrapPaddingAndSlicing(rhs) + expr match + case BinaryExpr(op, arg1: Variable, arg2) if op.equals(BVADD) => + evaluateExpression(arg2, constProp(n)) match + case Some(v) => + if op.equals(BVADD) && arg1.equals(stackPointer) && isNegative(v) then + d match + case Left(value) if value.accessor == variable => Map() + case Left(_) => Map(d -> IdEdge()) + case Right(_) => + val size = bv2SignedInt(v) + val procedure = IRWalk.procedure(n) + Map(d -> IdEdge(), Left(SymbolicAddress(variable, StackLocation(s"Stack_${procedure.name}", procedure, -size), 0)) -> ConstEdge(TwoElementTop)) + else + d match + case Left(value) if value.accessor == arg1 => + val offsetUpdate = evaluateExpression(arg2, constProp(n)).get.value + val result: Map[DL, EdgeFunction[TwoElement]] = Map(Left(SymbolicAddress(variable, value.symbolicBase, value.offset + offsetUpdate)) -> ConstEdge(TwoElementTop)) + if value.accessor != variable then + result + (d -> IdEdge()) + else + result + case Left(value) if value.accessor == variable => Map() + case _ => Map(d -> IdEdge()) + case None => Map(d -> IdEdge()) + case arg: Variable => + d match + case Left(value) if value.accessor == arg => + val result: Map[DL, EdgeFunction[TwoElement]] = Map(Left(SymbolicAddress(variable, value.symbolicBase, value.offset)) -> ConstEdge(TwoElementTop)) + if value.accessor != variable then + result + (d -> IdEdge()) + else + result + case Left(value) if value.accessor == variable => Map() + case _ => Map(d -> IdEdge()) + case _ => + d match + case Left(value) if value.accessor == variable => Map() + case _ => Map(d -> IdEdge()) + case MemoryLoad(lhs, _, _, _, _, _) => + d match + case Left(value) if value.accessor == lhs => Map() + case Left(_) => Map(d -> IdEdge()) + case Right(_) => Map(d -> IdEdge(), Left(SymbolicAddress(lhs, UnknownLocation(nextunknownCount, IRWalk.procedure(n)), 0)) -> ConstEdge(TwoElementTop)) + case DirectCall(target, _, _, _) if target.name == "malloc" => + d match + case Left(value) if value.accessor == mallocVariable => Map() + case Left(_) => Map(d -> IdEdge()) + case Right(_) => + val size: BigInt = evaluateExpression(mallocVariable, constProp(n)) match + case Some(value) => value.value + case None => -1 + Map(d -> IdEdge(), Left(SymbolicAddress(mallocVariable, HeapLocation(nextMallocCount, IRWalk.procedure(n), size), 0)) -> ConstEdge(TwoElementTop)) + case DirectCall(target, _, _, _) if target.returnBlock.isEmpty => // for when calls are non returning, kills the stack dataflow facts + d match + case Left(value) => + value.symbolicBase match + case _: StackLocation => Map() + case _ => Map(d -> IdEdge()) + case Right(_) => Map(d -> IdEdge()) + case _ => Map(d -> IdEdge()) +} + +class SymbolicAddressAnalysis(program: Program, constProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]]) + extends ForwardIDESolver[SymbolicAddress, TwoElement, TwoElementLattice](program), SymbolicAddressFunctions(constProp) diff --git a/src/main/scala/analysis/data_structure_analysis/Utility.scala b/src/main/scala/analysis/data_structure_analysis/Utility.scala new file mode 100644 index 000000000..6ca59f28d --- /dev/null +++ b/src/main/scala/analysis/data_structure_analysis/Utility.scala @@ -0,0 +1,253 @@ +package analysis.data_structure_analysis + +import analysis.solvers.{DSAUniTerm, DSAUnionFindSolver, UnionFindSolver, Var} +import analysis.* +import cfg_visualiser.{DotStruct, DotStructElement, StructArrow, StructDotGraph} +import ir.* +import specification.{ExternalFunction, SymbolTableEntry} +import boogie.SpecGlobal +import util.Logger + +import scala.collection.mutable +import scala.collection.mutable.ArrayBuffer +import scala.util.control.Breaks.{break, breakable} + +object NodeCounter { + private var counter: Int = 0 + + def getCounter: Int = + counter = counter + 1 + counter +} + +class Flags() { + var collapsed = false + var stack = false + var heap = false + var global = false + var unknown = false + var read = false + var modified = false + var incomplete = false + var foreign = false + + def join(other: Flags): Unit = + collapsed = collapsed || other.collapsed + stack = other.stack || stack + heap = other.heap || heap + global = other.global || global + unknown = other.unknown || unknown + read = other.read || read + modified = other.modified || modified + incomplete = other.incomplete || incomplete + foreign = other.foreign && foreign +} + +/** + * a Data structure Node + */ +class Node(val graph: Option[Graph], var size: BigInt = 0, val id: Int = NodeCounter.getCounter) { + + val term: DSAUniTerm = DSAUniTerm(this) + val children: mutable.Map[Node, BigInt] = mutable.Map() +// var collapsed = false + var flags: Flags = Flags() + def collapsed: Boolean = flags.collapsed + + val allocationRegions: mutable.Set[MemoryLocation] = mutable.Set() + + val cells: mutable.Map[BigInt, Cell] = mutable.Map() + this.addCell(0, 0) + + private def updateSize(newSize: BigInt): Unit = { + if newSize > size then + size = newSize + } + + def getCell(offset: BigInt): Cell = { + if (collapsed) { + cells(0) + } else if (!cells.contains(offset)) { + var result: Option[Cell] = None + cells.foreach { (start, cell) => + if (start <= offset && offset < (start + cell.largestAccessedSize)) { + result = Some(cell) + } + } + result match { + case Some(value) => value + case None => ??? + // Logger.warn(s"$this didn't have a cell at offset: $offset. An empty cell was added in") + // addCell(offset, 0) + } + } else { + cells(offset) + } + } + + + def addCell(offset: BigInt, size: Int): Cell = { + this.updateSize(offset + size) + if collapsed then + cells(0) + else if !cells.contains(offset) then + val cell = Cell(Some(this), offset) + cells.update(offset, cell) + cell.growSize(size) + cell + else + cells(offset).growSize(size) + cells(offset) + } + + def cloneSelf(graph: Graph): Node = { + val node = Node(Some(graph), this.size) + node.allocationRegions.addAll(this.allocationRegions) + node.flags.join(this.flags) + cells.foreach { (offset, cell) => + node.addCell(offset, cell.largestAccessedSize) + } + node + } + + def cloneNode(from: Graph, to: Graph): Unit = { +// assert(from.nodes.contains(this)) TODO update nodes after each phase for to check this assertion + if (!to.nodes.contains(this)) { + to.nodes.add(this) + + from.varToCell.foreach { (pos, varMap) => + varMap.foreach { (variable, slice) => + if (from.find(slice).node.equals(this)) { + if (to.varToCell.contains(pos)) { + to.varToCell(pos)(variable) = from.find(slice) + } else { + to.varToCell(pos) = mutable.Map(variable -> from.find(slice)) + } + } + } + } + from.formals.foreach { (variable, slice) => + if (from.find(slice).node.equals(this)) { + if (to.varToCell.contains(from.proc)) { + to.varToCell(from.proc)(variable) = from.find(slice) + } else { + to.varToCell(from.proc) = mutable.Map(variable -> from.find(slice)) + } + } + } + cells.values.foreach { cell => + if (cell.pointee.isDefined) { + val pointee = cell.getPointee + pointee.node.cloneNode(from, to) + // to.pointTo.update(cell, pointee) TODO check this is not necessary + } + } + } + } + + override def equals(obj: Any): Boolean = { + obj match + case node: Node => + this.id == node.id + case _ => false + } + + override def hashCode(): Int = id + + override def toString: String = s"Node($id, $allocationRegions ${if collapsed then ", collapsed" else ""})" + +} + +/** + * a cell in DSA + * @param node the node this cell belongs to + * @param offset the offset of the cell + */ +class Cell(val node: Option[Node], val offset: BigInt) { + var largestAccessedSize: Int = 0 + + // the cell's pointee + var pointee: Option[Slice] = None + + // returns the cell's pointee if it has one. + // if not it will create a placeholder, set it as the pointee of this cell and return it + def getPointee: Slice = + if pointee.isEmpty then + val node = Node(Some(this.node.get.graph.get)) + pointee = Some(Slice(node.cells(0), 0)) + else + val graph = pointee.get.node.graph.get + val resolvedPointee = graph.find(graph.adjust(pointee.get)) + + pointee = Some(graph.deadjust(resolvedPointee)) + pointee.get + + def growSize(size: Int): Boolean = + if size > largestAccessedSize then + largestAccessedSize = size + true + else false + + override def equals(obj: Any): Boolean = + obj match + case cell: Cell => this.node.equals(cell.node) && this.offset.equals(cell.offset) + case _ => false + + override def toString: String = s"Cell(${if node.isDefined then node.get.toString else "NONE"}, $offset)" +} + + +/** + * a slice made from a cell and an internal offset + */ +case class Slice(cell: Cell, internalOffset: BigInt) { + def node: Node = cell.node.get + def offset: BigInt = cell.offset +} + +/** + * represents a direct call in DSA + * @param call instance of the call + * @param graph caller's DSG + */ +class CallSite(val call: DirectCall, val graph: Graph) { + val proc: Procedure = call.target + val paramCells: mutable.Map[Variable, Slice] = graph.params(proc).foldLeft(mutable.Map[Variable, Slice]()) { + (m, reg) => + val node = Node(Some(graph)) + node.flags.incomplete = true + m += (reg -> Slice(node.cells(0), 0)) + } + val returnCells: mutable.Map[Variable, Slice] = graph.writesTo(proc).foldLeft(mutable.Map[Variable, Slice]()) { + (m, reg) => + val node = Node(Some(graph)) + node.flags.incomplete = true + m += (reg -> Slice(node.cells(0), 0)) + } +} + +case class DSAGlobal(addressRange: AddressRange, field: Field) { + lazy val start: BigInt = addressRange.start + lazy val end: BigInt = addressRange.end + lazy val node: Node = field.node + lazy val offset: BigInt = field.offset +} + +// global address range +case class AddressRange(start: BigInt, end: BigInt) + +// a node, offset pair, difference to a cell is that it doesn't represent a DSG construct, +case class Field(node: Node, offset: BigInt) + +// unwraps internal padding and slicing and returns the expression +def unwrapPaddingAndSlicing(expr: Expr): Expr = + expr match + case literal: Literal => literal + case Repeat(repeats, body) => Repeat(repeats, unwrapPaddingAndSlicing(body)) + case SignExtend(extension, body) => SignExtend(extension, unwrapPaddingAndSlicing(body)) + case UnaryExpr(op, arg) => UnaryExpr(op, arg) + case BinaryExpr(op, arg1, arg2) => BinaryExpr(op, unwrapPaddingAndSlicing(arg1), unwrapPaddingAndSlicing(arg2)) + case variable: Variable => variable + case Extract(_, _, body) /*if start == 0 && end == 32*/ => unwrapPaddingAndSlicing(body) // this may make it unsound + case ZeroExtend(_, body) => unwrapPaddingAndSlicing(body) + case _ => expr diff --git a/src/main/scala/analysis/solvers/DSAUnionFindSolver.scala b/src/main/scala/analysis/solvers/DSAUnionFindSolver.scala new file mode 100644 index 000000000..2a52591c9 --- /dev/null +++ b/src/main/scala/analysis/solvers/DSAUnionFindSolver.scala @@ -0,0 +1,61 @@ +package analysis.solvers + +import analysis.data_structure_analysis.Node +import scala.collection.mutable + +class DSAUnionFindSolver extends UnionFindSolver[UniTerm] { + private val parent = mutable.Map[DSAUniTerm, DSAUniTerm]() + private val offsets = mutable.Map[DSAUniTerm, BigInt]() + + override def unify(t1: Term[UniTerm], t2: Term[UniTerm]): Unit = + unify(t1.asInstanceOf[DSAUniTerm], t2.asInstanceOf[DSAUniTerm], 0) + + // offset is the offset at which + def unify(t1: DSAUniTerm, t2: DSAUniTerm, offset: BigInt): Unit = { + mkSet(t1) + mkSet(t2) + val (rep1, _) = findWithOffset(t1) + val (rep2, _) = findWithOffset(t2) + + if (rep1 != rep2) { + /** Perform the union of the equivalence classes of `t1` and `t2`, such that `t2` becomes the new canonical element. + * We assume `t1` and `t2` to be distinct canonical elements. This implementation does not use + * [[https://en.wikipedia.org/wiki/Disjoint-set_data_structure union-by-rank]]. + */ + parent += t1 -> t2 + offsets += t1 -> offset + } + } + + def findWithOffset(t: DSAUniTerm): (DSAUniTerm, BigInt) = { + mkSet(t) + if (parent(t) != t) + val (par, offset) = findWithOffset(parent(t)) + parent += t -> par + offsets += t -> (offsets(t) + offset) + + (parent(t), offsets(t)) + } + + + /** Creates an equivalence class for the term `t`, if it does not exists already. + */ + private def mkSet(t: DSAUniTerm): Unit = { + if (!parent.contains(t)) + parent += (t -> t) + offsets += (t -> 0) + } + +} + +/** Terms used in unification. + */ +sealed trait UniTerm + +/** A term variable in the solver + */ +case class DSAUniTerm(node: Node) extends Var[UniTerm] { + + override def toString: String = s"Term{$node}" +} + diff --git a/src/main/scala/analysis/solvers/FixPointSolver.scala b/src/main/scala/analysis/solvers/FixPointSolver.scala index bae5f8b9d..29186a9eb 100644 --- a/src/main/scala/analysis/solvers/FixPointSolver.scala +++ b/src/main/scala/analysis/solvers/FixPointSolver.scala @@ -249,9 +249,8 @@ trait PushDownWorklistFixpointSolver[N, T, L <: Lattice[T]] extends MapLatticeSo def process(n: N): Unit = val xn = x(n) val y = transfer(n, xn) + // TODO: Only propagate if there's a change for succ <- outdep(n) do propagate(y, succ) - - /** Worklist-based fixpoint solver. * * @tparam N diff --git a/src/main/scala/analysis/solvers/IDESolver.scala b/src/main/scala/analysis/solvers/IDESolver.scala index 5e94726d9..4b60e2e16 100644 --- a/src/main/scala/analysis/solvers/IDESolver.scala +++ b/src/main/scala/analysis/solvers/IDESolver.scala @@ -24,7 +24,8 @@ abstract class IDESolver[E <: Procedure | Command, EE <: Procedure | Command, C protected def isExit(exit: CFGPosition): Boolean protected def getAfterCalls(exit: EE): Set[R] - def phase2Init = valuelattice.top + def phase2Init: T = valuelattice.top + def start: CFGPosition = startNode /** * Phase 1 of the IDE algorithm. @@ -32,10 +33,10 @@ abstract class IDESolver[E <: Procedure | Command, EE <: Procedure | Command, C * The original version of the algorithm uses summary edges from call nodes to after-call nodes * instead of `callJumpCache` and `exitJumpCache`. */ - private class Phase1(val program: Program) extends InitializingPushDownWorklistFixpointSolver[(CFGPosition, DL, DL), EdgeFunction[T], EdgeFunctionLattice[T, L]] { + private class Phase1 extends InitializingPushDownWorklistFixpointSolver[(CFGPosition, DL, DL), EdgeFunction[T], EdgeFunctionLattice[T, L]] { val lattice: MapLattice[(CFGPosition, DL, DL), EdgeFunction[T], EdgeFunctionLattice[T, L]] = MapLattice(edgelattice) - val first: Set[(CFGPosition, DL, DL)] = Set((startNode, Right(Lambda()), Right(Lambda()))) + val first: Set[(CFGPosition, DL, DL)] = Set((start, Right(Lambda()), Right(Lambda()))) /** * callJumpCache(funentry, d1, call)(d3) returns the composition of the edges (call.funentry, d3) -> (call, *) -> (funentry, d1). @@ -77,7 +78,6 @@ abstract class IDESolver[E <: Procedure | Command, EE <: Procedure | Command, C } } - def process(n: (CFGPosition, DL, DL)): Unit = { val (position, d1, d2) = n val e1 = x(n) @@ -142,14 +142,14 @@ abstract class IDESolver[E <: Procedure | Command, EE <: Procedure | Command, C * Performs a forward dataflow analysis using the decomposed lattice and the micro-transformers. * The original RHS version of IDE uses jump functions for all nodes, not only at exits, but the analysis result and complexity is the same. */ - private class Phase2(val program: Program, val phase1: Phase1) extends InitializingPushDownWorklistFixpointSolver[(CFGPosition, DL), T, L]: + private class Phase2(val phase1: Phase1) extends InitializingPushDownWorklistFixpointSolver[(CFGPosition, DL), T, L] { val lattice: MapLattice[(CFGPosition, DL), T, L] = MapLattice(valuelattice) - val first: Set[(CFGPosition, DL)] = Set((startNode, Right(Lambda()))) + val first: Set[(CFGPosition, DL)] = Set((start, Right(Lambda()))) /** - * Function summaries from phase 1. - * Built when first invoked. - */ + * Function summaries from phase 1. + * Built when first invoked. + */ lazy val summaries: mutable.Map[Procedure, mutable.Map[DL, mutable.Map[DL, EdgeFunction[T]]]] = phase1.summaries() def init: T = phase2Init @@ -188,21 +188,28 @@ abstract class IDESolver[E <: Procedure | Command, EE <: Procedure | Command, C val restructuredlattice: MapLattice[CFGPosition, Map[D, T], MapLattice[D, T, L]] = MapLattice(MapLattice(valuelattice)) /** - * Restructures the analysis output to match `restructuredlattice`. - */ - def restructure(y: lattice.Element): restructuredlattice.Element = + * Restructures the analysis output to match `restructuredlattice`. + */ + def restructure(y: lattice.Element): restructuredlattice.Element = { y.foldLeft(Map[CFGPosition, Map[D, valuelattice.Element]]()) { case (acc, ((n, dl), e)) => dl match { case Left(d) => acc + (n -> (acc.getOrElse(n, Map[D, valuelattice.Element]()) + (d -> e))) case _ => acc } } + } + } def analyze(): Map[CFGPosition, Map[D, T]] = { - val phase1 = Phase1(program) - phase1.analyze() - val phase2 = Phase2(program, phase1) - phase2.restructure(phase2.analyze()) + if (program.mainProcedure.blocks.nonEmpty && program.mainProcedure.returnBlock.isDefined && program.mainProcedure.entryBlock.isDefined) { + val phase1 = Phase1() + phase1.analyze() + val phase2 = Phase2(phase1) + phase2.restructure(phase2.analyze()) + } else { + Logger.warn(s"Disabling IDE solver tests due to external main procedure: ${program.mainProcedure.name}") + Map() + } } } @@ -219,7 +226,7 @@ abstract class ForwardIDESolver[D, T, L <: Lattice[T]](program: Program) protected def returnToCall(ret: Command): DirectCall = ret match { case ret: Statement => ret.parent.statements.getPrev(ret).asInstanceOf[DirectCall] - case r: Jump => ret.parent.statements.last.asInstanceOf[DirectCall] + case _: Jump => ret.parent.statements.last.asInstanceOf[DirectCall] } protected def getCallee(call: DirectCall): Procedure = { @@ -227,16 +234,20 @@ abstract class ForwardIDESolver[D, T, L <: Lattice[T]](program: Program) call.target } - protected def isCall(call: CFGPosition): Boolean = - call match - case directCall: DirectCall if (!directCall.successor.isInstanceOf[Unreachable] && directCall.target.returnBlock.isDefined && directCall.target.entryBlock.isDefined) => true + protected def isCall(call: CFGPosition): Boolean = { + call match { + case directCall: DirectCall if !directCall.successor.isInstanceOf[Unreachable] && directCall.target.returnBlock.isDefined && directCall.target.entryBlock.isDefined => true case _ => false + } + } - protected def isExit(exit: CFGPosition): Boolean = - exit match + protected def isExit(exit: CFGPosition): Boolean = { + exit match { // only looking at functions with statements - case command: Return => true + case _: Return => true case _ => false + } + } protected def getAfterCalls(exit: Return): Set[Command] = InterProcIRCursor.succ(exit).filter(_.isInstanceOf[Command]).map(_.asInstanceOf[Command]) @@ -244,7 +255,7 @@ abstract class ForwardIDESolver[D, T, L <: Lattice[T]](program: Program) abstract class BackwardIDESolver[D, T, L <: Lattice[T]](program: Program) - extends IDESolver[Return, Procedure, Command, DirectCall, D, T, L](program, IRWalk.lastInProc(program.mainProcedure).get), + extends IDESolver[Return, Procedure, Command, DirectCall, D, T, L](program, IRWalk.lastInProc(program.mainProcedure).getOrElse(program.mainProcedure)), BackwardIDEAnalysis[D, T, L], IRInterproceduralBackwardDependencies { protected def entryToExit(entry: Return): Procedure = IRWalk.procedure(entry) @@ -253,7 +264,7 @@ abstract class BackwardIDESolver[D, T, L <: Lattice[T]](program: Program) protected def callToReturn(call: Command): DirectCall = { IRWalk.prevCommandInBlock(call) match { - case Some(x : DirectCall) => x + case Some(x: DirectCall) => x case p => throw Exception(s"Not a return/aftercall node $call .... prev = $p") } } @@ -266,22 +277,25 @@ abstract class BackwardIDESolver[D, T, L <: Lattice[T]](program: Program) procCalled.returnBlock.getOrElse(throw Exception(s"No return node for procedure ${procCalled}")).jump.asInstanceOf[Return] } - protected def isCall(call: CFGPosition): Boolean = - call match - case c: Unreachable => false /* don't process non-returning calls */ - case c : Command => { + protected def isCall(call: CFGPosition): Boolean = { + call match { + case _: Unreachable => false /* don't process non-returning calls */ + case c: Command => val call = IRWalk.prevCommandInBlock(c) call match { case Some(d: DirectCall) if d.target.returnBlock.isDefined => true case _ => false } - } case _ => false + } + } - protected def isExit(exit: CFGPosition): Boolean = - exit match + protected def isExit(exit: CFGPosition): Boolean = { + exit match { case procedure: Procedure => procedure.blocks.nonEmpty case _ => false + } + } protected def getAfterCalls(exit: Procedure): Set[DirectCall] = exit.incomingCalls().toSet } diff --git a/src/main/scala/analysis/solvers/UnionFindSolver.scala b/src/main/scala/analysis/solvers/UnionFindSolver.scala index bde8ef4e7..efc09b2a2 100644 --- a/src/main/scala/analysis/solvers/UnionFindSolver.scala +++ b/src/main/scala/analysis/solvers/UnionFindSolver.scala @@ -88,7 +88,7 @@ class UnionFindSolver[A] { /** Produces a string representation of the solution. */ override def toString: String = - solution().map(p => s"${p._1} = ${p._2}").mkString("\n") + solution().map((k, v) => s"$k = $v").mkString("\n") } /** Exception thrown in case of unification failure. diff --git a/src/main/scala/bap/BAPExpr.scala b/src/main/scala/bap/BAPExpr.scala index 7408328dd..0f2591e3d 100644 --- a/src/main/scala/bap/BAPExpr.scala +++ b/src/main/scala/bap/BAPExpr.scala @@ -5,8 +5,6 @@ import ir._ /** Expression */ trait BAPExpr { - def toIR: Expr - /* * The size of output of the given expression. * @@ -18,8 +16,6 @@ trait BAPExpr { /** Concatenation of two bitvectors */ case class BAPConcat(left: BAPExpr, right: BAPExpr) extends BAPExpr { - def toIR: BinaryExpr = BinaryExpr(BVCONCAT, left.toIR, right.toIR) - override val size: Int = left.size + right.size } @@ -28,14 +24,6 @@ case class BAPConcat(left: BAPExpr, right: BAPExpr) extends BAPExpr { case class BAPSignedExtend(width: Int, body: BAPExpr) extends BAPExpr { override val size: Int = width - - override def toIR: Expr = { - if (width > body.size) { - SignExtend(width - body.size, body.toIR) - } else { - BAPExtract(width - 1, 0, body).toIR - } - } } /** Unsigned extend - pad in BIL @@ -43,15 +31,6 @@ case class BAPSignedExtend(width: Int, body: BAPExpr) extends BAPExpr { case class BAPUnsignedExtend(width: Int, body: BAPExpr) extends BAPExpr { override val size: Int = width - - override def toIR: Expr = { - if (width > body.size) { - ZeroExtend(width - body.size, body.toIR) - } else { - BAPExtract(width - 1, 0, body).toIR - } - - } } /** Extracts the bits from firstInt to secondInt (inclusive) from variable. @@ -61,19 +40,6 @@ case class BAPExtract(high: Int, low: Int, body: BAPExpr) extends BAPExpr { // + 1 as extracts are inclusive (e.g. [31:0] has 32 bits) override val size: Int = high - low + 1 - - override def toIR: Expr = { - val bodySize = body.size - if (size > bodySize) { - if (low == 0) { - ZeroExtend(size - bodySize, body.toIR) - } else { - Extract(high + 1, low, ZeroExtend(size - bodySize, body.toIR)) - } - } else { - Extract(high + 1, low, body.toIR) - } - } } case object BAPHighCast { @@ -90,19 +56,12 @@ case class BAPLiteral(value: BigInt, size: Int) extends BAPExpr { /** Value of literal */ override def toString: String = s"${value}bv$size" - - override def toIR: BitVecLiteral = BitVecLiteral(value, size) } /** Unary operator */ case class BAPUnOp(operator: BAPUnOperator, exp: BAPExpr) extends BAPExpr { override val size: Int = exp.size - - override def toIR: UnaryExpr = operator match { - case NOT => UnaryExpr(BVNOT, exp.toIR) - case NEG => UnaryExpr(BVNEG, exp.toIR) - } } sealed trait BAPUnOperator(op: String) { @@ -126,46 +85,6 @@ case class BAPBinOp(operator: BAPBinOperator, lhs: BAPExpr, rhs: BAPExpr) extend case EQ | NEQ | LT | LE | SLT | SLE => 1 case _ => lhs.size } - - override def toIR: Expr = operator match { - case PLUS => BinaryExpr(BVADD, lhs.toIR, rhs.toIR) - case MINUS => BinaryExpr(BVSUB, lhs.toIR, rhs.toIR) - case TIMES => BinaryExpr(BVMUL, lhs.toIR, rhs.toIR) - case DIVIDE => BinaryExpr(BVUDIV, lhs.toIR, rhs.toIR) - case SDIVIDE => BinaryExpr(BVSDIV, lhs.toIR, rhs.toIR) - // counterintuitive but correct according to BAP source - case MOD => BinaryExpr(BVSREM, lhs.toIR, rhs.toIR) - // counterintuitive but correct according to BAP source - case SMOD => BinaryExpr(BVUREM, lhs.toIR, rhs.toIR) - case LSHIFT => // BAP says caring about this case is necessary? - if (lhs.size == rhs.size) { - BinaryExpr(BVSHL, lhs.toIR, rhs.toIR) - } else { - BinaryExpr(BVSHL, lhs.toIR, ZeroExtend(lhs.size - rhs.size, rhs.toIR)) - } - case RSHIFT => - if (lhs.size == rhs.size) { - BinaryExpr(BVLSHR, lhs.toIR, rhs.toIR) - } else { - BinaryExpr(BVLSHR, lhs.toIR, ZeroExtend(lhs.size - rhs.size, rhs.toIR)) - } - case ARSHIFT => - if (lhs.size == rhs.size) { - BinaryExpr(BVASHR, lhs.toIR, rhs.toIR) - } else { - BinaryExpr(BVASHR, lhs.toIR, ZeroExtend(lhs.size - rhs.size, rhs.toIR)) - } - case AND => BinaryExpr(BVAND, lhs.toIR, rhs.toIR) - case OR => BinaryExpr(BVOR, lhs.toIR, rhs.toIR) - case XOR => BinaryExpr(BVXOR, lhs.toIR, rhs.toIR) - case EQ => BinaryExpr(BVCOMP, lhs.toIR, rhs.toIR) - case NEQ => UnaryExpr(BVNOT, BinaryExpr(BVCOMP, lhs.toIR, rhs.toIR)) - case LT => BinaryExpr(BVULT, lhs.toIR, rhs.toIR) - case LE => BinaryExpr(BVULE, lhs.toIR, rhs.toIR) - case SLT => BinaryExpr(BVSLT, lhs.toIR, rhs.toIR) - case SLE => BinaryExpr(BVSLE, lhs.toIR, rhs.toIR) - } - } sealed trait BAPBinOperator(op: String) { @@ -216,39 +135,23 @@ case object LE extends BAPBinOperator("LE") case object SLT extends BAPBinOperator("SLT") case object SLE extends BAPBinOperator("SLE") -trait BAPVariable extends BAPExpr - -trait BAPVar extends BAPVariable { +trait BAPVar extends BAPExpr { val name: String override val size: Int override def toString: String = name - override def toIR: Variable } +case class BAPRegister(override val name: String, override val size: Int) extends BAPVar -case class BAPRegister(override val name: String, override val size: Int) extends BAPVar { - override def toIR: Register = Register(s"$name", size) -} - -case class BAPLocalVar(override val name: String, override val size: Int) extends BAPVar { - override def toIR: LocalVar = LocalVar(s"$name", BitVecType(size)) -} +case class BAPLocalVar(override val name: String, override val size: Int) extends BAPVar /** A load from memory at location exp */ -case class BAPMemAccess(memory: BAPMemory, index: BAPExpr, endian: Endian, override val size: Int) extends BAPVariable { +case class BAPMemAccess(memory: BAPMemory, index: BAPExpr, endian: Endian, override val size: Int) extends BAPExpr { override def toString: String = s"${memory.name}[$index]" - override def toIR: MemoryLoad = { - MemoryLoad(memory.toIRMemory, index.toIR, endian, size) - } } -case class BAPMemory(name: String, addressSize: Int, valueSize: Int) extends BAPVariable { - override val size: Int = valueSize // should reconsider - override def toIR: Expr = ??? // should not encounter - def toIRMemory: Memory = SharedMemory(name, addressSize, valueSize) -} +case class BAPMemory(name: String, addressSize: Int, valueSize: Int) case class BAPStore(memory: BAPMemory, index: BAPExpr, value: BAPExpr, endian: Endian, size: Int) extends BAPExpr { - override def toIR: Expr = ??? // should not encounter override def toString: String = s"${memory.name}[$index] := $value" } diff --git a/src/main/scala/bap/BAPProgram.scala b/src/main/scala/bap/BAPProgram.scala index da8948b13..095d206f4 100644 --- a/src/main/scala/bap/BAPProgram.scala +++ b/src/main/scala/bap/BAPProgram.scala @@ -46,58 +46,7 @@ case class BAPBlock(label: String, address: Option[BigInt], statements: List[BAP } case class BAPParameter(name: String, size: Int, value: BAPVar) { - - def paramRegisterLVal: Variable = value.toIR - def paramVariable = toIR - def toIROutParam = { - paramRegisterLVal match { - case r: Register => { - if (r.size == size) then { - toIR - } else { - LocalVar(name, BitVecType(r.size)) - } - } - case _ => throw Exception(s"subroutine parameter $this refers to non-register variable $value") - } - - } - def paramRegisterRVal: Expr = { - paramRegisterLVal match { - case r: Register => { - if (r.size == size) then { - r - } else if (r.size > size){ - Extract(size, 0, r) - } else { - ZeroExtend(size - r.size, r) - } - } - case _ => throw Exception(s"subroutine parameter $this refers to non-register variable $value") - } - } - def paramVariableRVal: Expr = { - paramRegisterLVal match { - case r: Register => { - if (r.size == size) then { - toIR - } else { - ZeroExtend(r.size - size, toIR) - } - } - case _ => throw Exception(s"subroutine parameter $this refers to non-register variable $value") - } - } - - def toAssignOut : Assign = { - Assign(paramVariable, paramRegisterRVal) - } - - def toAssignIn : Assign = { - Assign(paramRegisterLVal, paramVariableRVal) - } - - def toIR: LocalVar = LocalVar(name, BitVecType(size)) + } case class BAPMemorySection(name: String, address: BigInt, size: Int, bytes: Seq[BAPLiteral]) diff --git a/src/main/scala/bap/BAPStatement.scala b/src/main/scala/bap/BAPStatement.scala index 09b77f60d..2f9afe34d 100644 --- a/src/main/scala/bap/BAPStatement.scala +++ b/src/main/scala/bap/BAPStatement.scala @@ -23,14 +23,12 @@ case class BAPGoTo(target: String, condition: BAPExpr, override val line: String sealed trait BAPStatement -sealed trait BAPAssign(lhs: BAPVariable, rhs: BAPExpr, line: String, instruction: String) extends BAPStatement { - override def toString: String = String.format("%s := %s;", lhs, rhs) -} - /** Memory store */ -case class BAPMemAssign(lhs: BAPMemory, rhs: BAPStore, line: String, instruction: String, address: Option[BigInt] = None) - extends BAPAssign(lhs, rhs, line, instruction) +case class BAPMemAssign(lhs: BAPMemory, rhs: BAPStore, line: String, instruction: String, address: Option[BigInt] = None) extends BAPStatement { + override def toString: String = String.format("%s := %s;", lhs, rhs) +} -case class BAPLocalAssign(lhs: BAPVar, rhs: BAPExpr, line: String, instruction: String, address: Option[BigInt] = None) - extends BAPAssign(lhs, rhs, line, instruction) +case class BAPLocalAssign(lhs: BAPVar, rhs: BAPExpr, line: String, instruction: String, address: Option[BigInt] = None) extends BAPStatement { + override def toString: String = String.format("%s := %s;", lhs, rhs) +} diff --git a/src/main/scala/boogie/BExpr.scala b/src/main/scala/boogie/BExpr.scala index e8eb610a3..7c834d10c 100644 --- a/src/main/scala/boogie/BExpr.scala +++ b/src/main/scala/boogie/BExpr.scala @@ -10,22 +10,15 @@ sealed trait BExpr { def functionOps: Set[FunctionOp] = Set() def locals: Set[BVar] = Set() def globals: Set[BVar] = Set() + def params: Set[BVar] = Set() def specGlobals: Set[SpecGlobalOrAccess] = Set() def oldSpecGlobals: Set[SpecGlobalOrAccess] = Set() - def resolveSpec: BExpr = this - def resolveOld: BExpr = this - def removeOld: BExpr = this - def resolveSpecL: BExpr = this - def resolveInsideOld: BExpr = this - def resolveSpecParam: BExpr = this - def resolveSpecParamOld: BExpr = this - def resolveSpecInv: BExpr = this - def resolveSpecInvOld: BExpr = this def loads: Set[BExpr] = Set() def serialiseBoogie(w: Writer): Unit = w.append(toString) + def acceptVisit(visitor: BVisitor): BExpr = this } -trait BLiteral extends BExpr {} +trait BLiteral extends BExpr sealed trait BoolBLiteral extends BLiteral @@ -39,7 +32,6 @@ case object StarBLiteral extends BoolBLiteral { override def toString: String = "*" } - case object FalseBLiteral extends BoolBLiteral { override val getType: BType = BoolBType override def toString: String = "false" @@ -53,10 +45,6 @@ case class BitVecBLiteral(value: BigInt, size: Int) extends BLiteral { case class IntBLiteral(value: BigInt) extends BLiteral { override val getType: BType = IntBType override def toString: String = value.toString - override def resolveSpecL: BitVecBLiteral = BitVecBLiteral(value, 32) // TODO - override def resolveSpec: BitVecBLiteral = BitVecBLiteral(value, 32) // TODO - override def resolveOld: BitVecBLiteral = BitVecBLiteral(value, 32) // TODO - override def removeOld: BitVecBLiteral = BitVecBLiteral(value, 32) // TODO } case class BVExtract(end: Int, start: Int, body: BExpr) extends BExpr { @@ -65,17 +53,9 @@ case class BVExtract(end: Int, start: Int, body: BExpr) extends BExpr { override def functionOps: Set[FunctionOp] = body.functionOps override def locals: Set[BVar] = body.locals override def globals: Set[BVar] = body.globals + override def params: Set[BVar] = body.params override def specGlobals: Set[SpecGlobalOrAccess] = body.specGlobals override def oldSpecGlobals: Set[SpecGlobalOrAccess] = body.oldSpecGlobals - override def resolveSpec: BVExtract = copy(body = body.resolveSpec) - override def resolveSpecInv: BVExtract = copy(body = body.resolveSpecInv) - override def resolveSpecInvOld: BVExtract = copy(body = body.resolveSpecInvOld) - override def resolveSpecParam: BVExtract = copy(body = body.resolveSpecParam) - override def resolveSpecParamOld: BVExtract = copy(body = body.resolveSpecParamOld) - override def resolveSpecL: BVExtract = copy(body = body.resolveSpecL) - override def resolveOld: BVExtract = copy(body = body.resolveOld) - override def resolveInsideOld: BVExtract = copy(body = body.resolveInsideOld) - override def removeOld: BVExtract = copy(body = body.removeOld) override def loads: Set[BExpr] = body.loads override def serialiseBoogie(w: Writer): Unit = { @@ -83,6 +63,8 @@ case class BVExtract(end: Int, start: Int, body: BExpr) extends BExpr { w.append(s"[$end:$start]") } + override def acceptVisit(visitor: BVisitor): BExpr = visitor.visitBVExtract(this) + } case class BVRepeat(repeats: Int, body: BExpr) extends BExpr { @@ -109,18 +91,11 @@ case class BVRepeat(repeats: Int, body: BExpr) extends BExpr { } override def locals: Set[BVar] = body.locals override def globals: Set[BVar] = body.globals + override def params: Set[BVar] = body.params override def specGlobals: Set[SpecGlobalOrAccess] = body.specGlobals override def oldSpecGlobals: Set[SpecGlobalOrAccess] = body.oldSpecGlobals - override def resolveSpec: BVRepeat = copy(body = body.resolveSpec) - override def resolveSpecInv: BVRepeat = copy(body = body.resolveSpecInv) - override def resolveSpecInvOld: BVRepeat = copy(body = body.resolveSpecInvOld) - override def resolveSpecParam: BVRepeat = copy(body = body.resolveSpecParam) - override def resolveSpecParamOld: BVRepeat = copy(body = body.resolveSpecParamOld) - override def resolveSpecL: BVRepeat = copy(body = body.resolveSpecL) - override def resolveOld: BVRepeat = copy(body = body.resolveOld) - override def resolveInsideOld: BVRepeat = copy(body = body.resolveInsideOld) - override def removeOld: BVRepeat = copy(body = body.removeOld) override def loads: Set[BExpr] = body.loads + override def acceptVisit(visitor: BVisitor): BExpr = visitor.visitBVRepeat(this) } case class BVZeroExtend(extension: Int, body: BExpr) extends BExpr { @@ -148,18 +123,12 @@ case class BVZeroExtend(extension: Int, body: BExpr) extends BExpr { } override def locals: Set[BVar] = body.locals override def globals: Set[BVar] = body.globals + override def params: Set[BVar] = body.params override def specGlobals: Set[SpecGlobalOrAccess] = body.specGlobals override def oldSpecGlobals: Set[SpecGlobalOrAccess] = body.oldSpecGlobals - override def resolveSpec: BVZeroExtend = copy(body = body.resolveSpec) - override def resolveSpecInv: BVZeroExtend = copy(body = body.resolveSpecInv) - override def resolveSpecInvOld: BVZeroExtend = copy(body = body.resolveSpecInvOld) - override def resolveSpecParam: BVZeroExtend = copy(body = body.resolveSpecParam) - override def resolveSpecParamOld: BVZeroExtend = copy(body = body.resolveSpecParamOld) - override def resolveSpecL: BVZeroExtend = copy(body = body.resolveSpecL) - override def resolveOld: BExpr = copy(body = body.resolveOld) - override def resolveInsideOld: BExpr = copy(body = body.resolveInsideOld) - override def removeOld: BExpr = copy(body = body.removeOld) override def loads: Set[BExpr] = body.loads + + override def acceptVisit(visitor: BVisitor): BExpr = visitor.visitBVZeroExtend(this) } case class BVSignExtend(extension: Int, body: BExpr) extends BExpr { @@ -181,25 +150,17 @@ case class BVSignExtend(extension: Int, body: BExpr) extends BExpr { w.append(")") } - override def functionOps: Set[FunctionOp] = { val thisFn = BVFunctionOp(fnName, s"sign_extend $extension", List(BParam(BitVecBType(bodySize))), BParam(getType)) body.functionOps + thisFn } override def locals: Set[BVar] = body.locals override def globals: Set[BVar] = body.globals + override def params: Set[BVar] = body.params override def specGlobals: Set[SpecGlobalOrAccess] = body.specGlobals override def oldSpecGlobals: Set[SpecGlobalOrAccess] = body.oldSpecGlobals - override def resolveSpecL: BVSignExtend = copy(body = body.resolveSpecL) - override def resolveSpec: BVSignExtend = copy(body = body.resolveSpec) - override def resolveSpecInv: BVSignExtend = copy(body = body.resolveSpecInv) - override def resolveSpecInvOld: BVSignExtend = copy(body = body.resolveSpecInvOld) - override def resolveSpecParam: BVSignExtend = copy(body = body.resolveSpecParam) - override def resolveSpecParamOld: BVSignExtend = copy(body = body.resolveSpecParamOld) - override def resolveOld: BExpr = copy(body = body.resolveOld) - override def resolveInsideOld: BExpr = copy(body = body.resolveInsideOld) - override def removeOld: BExpr = copy(body = body.removeOld) override def loads: Set[BExpr] = body.loads + override def acceptVisit(visitor: BVisitor): BExpr = visitor.visitBVSignExtend(this) } abstract class BVar(val name: String, val bType: BType, val scope: Scope) extends BExpr with Ordered[BVar] { @@ -220,6 +181,10 @@ abstract class BVar(val name: String, val bType: BType, val scope: Scope) extend case Scope.Global => Set(this) case _ => Set() } + override def params: Set[BVar] = scope match { + case Scope.Parameter => Set(this) + case _ => Set() + } } case class BVariable(override val name: String, override val bType: BType, override val scope: Scope) @@ -255,17 +220,11 @@ case class BFunctionCall(name: String, args: List[BExpr], outType: BType, uninte } override def locals: Set[BVar] = args.flatMap(a => a.locals).toSet override def globals: Set[BVar] = args.flatMap(a => a.globals).toSet + override def params: Set[BVar] = args.flatMap(a => a.params).toSet override def specGlobals: Set[SpecGlobalOrAccess] = args.flatMap(a => a.specGlobals).toSet override def oldSpecGlobals: Set[SpecGlobalOrAccess] = args.flatMap(a => a.oldSpecGlobals).toSet - override def resolveSpec: BFunctionCall = copy(args = args.map(a => a.resolveSpec)) - override def resolveSpecInv: BFunctionCall = copy(args = args.map(a => a.resolveSpecInv)) - override def resolveSpecInvOld: BFunctionCall = copy(args = args.map(a => a.resolveSpecInvOld)) - override def resolveSpecParam: BFunctionCall = copy(args = args.map(a => a.resolveSpecParam)) - override def resolveSpecParamOld: BFunctionCall = copy(args = args.map(a => a.resolveSpecParamOld)) - override def resolveSpecL: BFunctionCall = copy(args = args.map(a => a.resolveSpecL)) - override def resolveOld: BExpr = copy(args = args.map(a => a.resolveOld)) - override def removeOld: BExpr = copy(args = args.map(a => a.removeOld)) override def loads: Set[BExpr] = args.flatMap(a => a.loads).toSet + override def acceptVisit(visitor: BVisitor): BExpr = visitor.visitBFunctionCall(this) } case class UnaryBExpr(op: UnOp, arg: BExpr) extends BExpr { @@ -301,45 +260,12 @@ case class UnaryBExpr(op: UnOp, arg: BExpr) extends BExpr { override def locals: Set[BVar] = arg.locals override def globals: Set[BVar] = arg.globals + override def params: Set[BVar] = arg.params override def specGlobals: Set[SpecGlobalOrAccess] = arg.specGlobals override def oldSpecGlobals: Set[SpecGlobalOrAccess] = arg.oldSpecGlobals - override def resolveSpec: UnaryBExpr = op match { - case i: IntUnOp => copy(op = i.toBV, arg = arg.resolveSpec) - case _ => copy(arg = arg.resolveSpec) - } - override def resolveSpecInv: UnaryBExpr = op match { - case i: IntUnOp => copy(op = i.toBV, arg = arg.resolveSpecInv) - case _ => copy(arg = arg.resolveSpecInv) - } - override def resolveSpecInvOld: UnaryBExpr = op match { - case i: IntUnOp => copy(op = i.toBV, arg = arg.resolveSpecInvOld) - case _ => copy(arg = arg.resolveSpecInvOld) - } - override def resolveSpecParam: UnaryBExpr = op match { - case i: IntUnOp => copy(op = i.toBV, arg = arg.resolveSpecParam) - case _ => copy(arg = arg.resolveSpecParam) - } - override def resolveSpecParamOld: UnaryBExpr = op match { - case i: IntUnOp => copy(op = i.toBV, arg = arg.resolveSpecParamOld) - case _ => copy(arg = arg.resolveSpecParamOld) - } - override def resolveSpecL: UnaryBExpr = op match { - case i: IntUnOp => copy(op = i.toBV, arg = arg.resolveSpecL) - case _ => copy(arg = arg.resolveSpecL) - } - override def resolveOld: BExpr = op match { - case i: IntUnOp => copy(op = i.toBV, arg = arg.resolveOld) - case _ => copy(arg = arg.resolveOld) - } - override def resolveInsideOld: BExpr = op match { - case i: IntUnOp => copy(op = i.toBV, arg = arg.resolveInsideOld) - case _ => copy(arg = arg.resolveInsideOld) - } - override def removeOld: BExpr = op match { - case i: IntUnOp => copy(op = i.toBV, arg = arg.removeOld) - case _ => copy(arg = arg.removeOld) - } override def loads: Set[BExpr] = arg.loads + + override def acceptVisit(visitor: BVisitor): BExpr = visitor.visitUnaryBExpr(this) } case class BinaryBExpr(op: BinOp, arg1: BExpr, arg2: BExpr) extends BExpr { @@ -423,8 +349,6 @@ case class BinaryBExpr(op: BinOp, arg1: BExpr, arg2: BExpr) extends BExpr { case bOp: IntBinOp => s"($arg1 $bOp $arg2)" } - - override def functionOps: Set[FunctionOp] = { val thisFn = op match { case b: BVBinOp => @@ -442,54 +366,12 @@ case class BinaryBExpr(op: BinOp, arg1: BExpr, arg2: BExpr) extends BExpr { override def locals: Set[BVar] = arg1.locals ++ arg2.locals override def globals: Set[BVar] = arg1.globals ++ arg2.globals + override def params: Set[BVar] = arg1.params ++ arg2.params override def specGlobals: Set[SpecGlobalOrAccess] = arg1.specGlobals ++ arg2.specGlobals override def oldSpecGlobals: Set[SpecGlobalOrAccess] = arg1.oldSpecGlobals ++ arg2.oldSpecGlobals - - override def resolveSpec: BinaryBExpr = op match { - case i: IntBinOp => copy(op = i.toBV, arg1 = arg1.resolveSpec, arg2 = arg2.resolveSpec) - case _ => copy(arg1 = arg1.resolveSpec, arg2 = arg2.resolveSpec) - } - - override def resolveSpecInv: BinaryBExpr = op match { - case i: IntBinOp => copy(op = i.toBV, arg1 = arg1.resolveSpecInv, arg2 = arg2.resolveSpecInv) - case _ => copy(arg1 = arg1.resolveSpecInv, arg2 = arg2.resolveSpecInv) - } - - override def resolveSpecInvOld: BinaryBExpr = op match { - case i: IntBinOp => copy(op = i.toBV, arg1 = arg1.resolveSpecInvOld, arg2 = arg2.resolveSpecInvOld) - case _ => copy(arg1 = arg1.resolveSpecInvOld, arg2 = arg2.resolveSpecInvOld) - } - - override def resolveSpecParamOld: BinaryBExpr = op match { - case i: IntBinOp => copy(op = i.toBV, arg1 = arg1.resolveSpec, arg2 = arg2.resolveSpecParamOld) - case _ => copy(arg1 = arg1.resolveSpecParamOld, arg2 = arg2.resolveSpecParamOld) - } - - override def resolveSpecParam: BinaryBExpr = op match { - case i: IntBinOp => copy(op = i.toBV, arg1 = arg1.resolveSpecParam, arg2 = arg2.resolveSpecParam) - case _ => copy(arg1 = arg1.resolveSpecParam, arg2 = arg2.resolveSpecParam) - } - - override def resolveSpecL: BinaryBExpr = op match { - case i: IntBinOp => copy(op = i.toBV, arg1 = arg1.resolveSpecL, arg2 = arg2.resolveSpecL) - case _ => copy(arg1 = arg1.resolveSpecL, arg2 = arg2.resolveSpecL) - } - - override def resolveOld: BinaryBExpr = op match { - case i: IntBinOp => copy(op = i.toBV, arg1 = arg1.resolveOld, arg2 = arg2.resolveOld) - case _ => copy(arg1 = arg1.resolveOld, arg2 = arg2.resolveOld) - } - - override def resolveInsideOld: BinaryBExpr = op match { - case i: IntBinOp => copy(op = i.toBV, arg1 = arg1.resolveInsideOld, arg2 = arg2.resolveInsideOld) - case _ => copy(arg1 = arg1.resolveInsideOld, arg2 = arg2.resolveInsideOld) - } - - override def removeOld: BinaryBExpr = op match { - case i: IntBinOp => copy(op = i.toBV, arg1 = arg1.removeOld, arg2 = arg2.removeOld) - case _ => copy(arg1 = arg1.removeOld, arg2 = arg2.removeOld) - } override def loads: Set[BExpr] = arg1.loads ++ arg2.loads + + override def acceptVisit(visitor: BVisitor): BExpr = visitor.visitBinaryBExpr(this) } case class IfThenElse(guard: BExpr, thenExpr: BExpr, elseExpr: BExpr) extends BExpr { @@ -505,28 +387,13 @@ case class IfThenElse(guard: BExpr, thenExpr: BExpr, elseExpr: BExpr) extends BE override def functionOps: Set[FunctionOp] = guard.functionOps ++ thenExpr.functionOps ++ elseExpr.functionOps override def locals: Set[BVar] = guard.locals ++ thenExpr.locals ++ elseExpr.locals override def globals: Set[BVar] = guard.globals ++ thenExpr.globals ++ elseExpr.globals + override def params: Set[BVar] = guard.params ++ thenExpr.params ++ elseExpr.params override def specGlobals: Set[SpecGlobalOrAccess] = guard.specGlobals ++ thenExpr.specGlobals ++ elseExpr.specGlobals override def oldSpecGlobals: Set[SpecGlobalOrAccess] = guard.oldSpecGlobals ++ thenExpr.oldSpecGlobals ++ elseExpr.oldSpecGlobals - override def resolveSpec: IfThenElse = - copy(guard = guard.resolveSpec, thenExpr = thenExpr.resolveSpec, elseExpr = elseExpr.resolveSpec) - override def resolveSpecInv: IfThenElse = - copy(guard = guard.resolveSpecInv, thenExpr = thenExpr.resolveSpecInv, elseExpr = elseExpr.resolveSpecInv) - override def resolveSpecInvOld: IfThenElse = - copy(guard = guard.resolveSpecInvOld, thenExpr = thenExpr.resolveSpecInvOld, elseExpr = elseExpr.resolveSpecInvOld) - override def resolveSpecParam: IfThenElse = - copy(guard = guard.resolveSpecParam, thenExpr = thenExpr.resolveSpecParam, elseExpr = elseExpr.resolveSpecParam) - override def resolveSpecParamOld: IfThenElse = - copy(guard = guard.resolveSpecParamOld, thenExpr = thenExpr.resolveSpecParamOld, elseExpr = elseExpr.resolveSpecParamOld) - override def resolveSpecL: IfThenElse = - copy(guard = guard.resolveSpecL, thenExpr = thenExpr.resolveSpecL, elseExpr = elseExpr.resolveSpecL) - override def resolveOld: IfThenElse = - copy(guard = guard.resolveOld, thenExpr = thenExpr.resolveOld, elseExpr = elseExpr.resolveOld) - override def resolveInsideOld: IfThenElse = - copy(guard = guard.resolveInsideOld, thenExpr = thenExpr.resolveInsideOld, elseExpr = elseExpr.resolveInsideOld) - override def removeOld: IfThenElse = - copy(guard = guard.removeOld, thenExpr = thenExpr.removeOld, elseExpr = elseExpr.removeOld) override def loads: Set[BExpr] = guard.loads ++ thenExpr.loads ++ elseExpr.loads + + override def acceptVisit(visitor: BVisitor): BExpr = visitor.visitIfThenElse(this) } trait QuantifierExpr(sort: Quantifier, bound: List[BVar], body: BExpr) extends BExpr { @@ -538,6 +405,7 @@ trait QuantifierExpr(sort: Quantifier, bound: List[BVar], body: BExpr) extends B override def functionOps: Set[FunctionOp] = body.functionOps override def locals: Set[BVar] = body.locals -- bound.toSet override def globals: Set[BVar] = body.globals -- bound.toSet + override def params: Set[BVar] = body.params -- bound.toSet override def specGlobals: Set[SpecGlobalOrAccess] = body.specGlobals override def oldSpecGlobals: Set[SpecGlobalOrAccess] = body.oldSpecGlobals override def loads: Set[BExpr] = body.loads @@ -561,14 +429,10 @@ case class Old(body: BExpr) extends BExpr { override def functionOps: Set[FunctionOp] = body.functionOps override def locals: Set[BVar] = body.locals override def globals: Set[BVar] = body.globals + override def params: Set[BVar] = body.params override def oldSpecGlobals: Set[SpecGlobalOrAccess] = body.specGlobals - override def resolveSpecParam: BExpr = body.resolveSpecParamOld - override def resolveSpecInv: BExpr = body.resolveSpecInvOld - override def resolveSpec: BExpr = copy(body = body.resolveSpec) - override def resolveSpecL: BExpr = copy(body = body.resolveSpecL) - override def resolveOld: BExpr = body.resolveInsideOld - override def removeOld: BExpr = body.resolveSpec override def loads: Set[BExpr] = body.loads + override def acceptVisit(visitor: BVisitor): BExpr = visitor.visitOld(this) } case class MapAccess(mapVar: BMapVar, index: BExpr) extends BExpr { @@ -577,6 +441,7 @@ case class MapAccess(mapVar: BMapVar, index: BExpr) extends BExpr { override def functionOps: Set[FunctionOp] = index.functionOps override def locals: Set[BVar] = index.locals override def globals: Set[BVar] = index.globals ++ mapVar.globals + override def params: Set[BVar] = index.params ++ mapVar.params override def loads: Set[BExpr] = index.loads } @@ -586,6 +451,7 @@ case class MapUpdate(map: BExpr, index: BExpr, value: BExpr) extends BExpr { override def functionOps: Set[FunctionOp] = map.functionOps ++ index.functionOps ++ value.functionOps override def locals: Set[BVar] = map.locals ++ index.locals ++ value.locals override def globals: Set[BVar] = index.globals ++ map.globals ++ value.globals + override def params: Set[BVar] = index.params ++ map.params ++ value.params override def loads: Set[BExpr] = index.loads ++ value.loads ++ map.loads } @@ -617,7 +483,7 @@ case class GammaLoadOp(addressSize: Int, bits: Int, accesses: Int) extends Funct case class GammaStoreOp(addressSize: Int, bits: Int, accesses: Int) extends FunctionOp { val fnName: String = s"gamma_store$bits" } -case class LOp(memoryType: BType, indexType: BType) extends FunctionOp +case class LOp(indexType: BType) extends FunctionOp /** * Utility to extract a particular byte from a bitvector. @@ -646,6 +512,7 @@ case class BByteExtract(value: BExpr, offset: BExpr) extends BExpr { value.functionOps ++ offset.functionOps + ByteExtract(valueSize, offsetSize) override def locals: Set[BVar] = value.locals ++ offset.locals override def globals: Set[BVar] = value.globals ++ offset.globals + override def params: Set[BVar] = value.params ++ offset.params override def loads: Set[BExpr] = value.loads ++ offset.loads } @@ -679,7 +546,8 @@ case class BInBounds(base: BExpr, len: BExpr, endian: Endian, i: BExpr) extends override def functionOps: Set[FunctionOp] = base.functionOps ++ len.functionOps ++ i.functionOps + InBounds(baseSize, endian) override def locals: Set[BVar] = base.locals ++ len.locals ++ i.locals - override def globals: Set[BVar] = base.globals ++ len.globals ++ i.globals + override def globals: Set[BVar] = base.globals ++ len.globals ++ i.globals + override def params: Set[BVar] = base.params ++ len.params ++ i.params override def loads: Set[BExpr] = base.loads ++ len.loads ++ i.loads } @@ -711,6 +579,7 @@ case class BMemoryLoad(memory: BMapVar, index: BExpr, endian: Endian, bits: Int) memory.functionOps ++ index.functionOps + MemoryLoadOp(addressSize, valueSize, endian, bits) override def locals: Set[BVar] = memory.locals ++ index.locals override def globals: Set[BVar] = index.globals ++ memory.globals + override def params: Set[BVar] = index.params ++ memory.params override def loads: Set[BExpr] = Set(this) ++ index.loads } @@ -737,6 +606,7 @@ case class BMemoryStore(memory: BMapVar, index: BExpr, value: BExpr, endian: End memory.functionOps ++ index.functionOps ++ value.functionOps + MemoryStoreOp(addressSize, valueSize, endian, bits) override def locals: Set[BVar] = memory.locals ++ index.locals ++ value.locals override def globals: Set[BVar] = index.globals ++ memory.globals ++ value.globals + override def params: Set[BVar] = index.params ++ memory.params ++ value.params override def loads: Set[BExpr] = index.loads ++ value.loads } @@ -761,6 +631,7 @@ case class GammaLoad(gammaMap: BMapVar, index: BExpr, bits: Int, accesses: Int) gammaMap.functionOps ++ index.functionOps + GammaLoadOp(addressSize, bits, accesses) override def locals: Set[BVar] = gammaMap.locals ++ index.locals override def globals: Set[BVar] = index.globals ++ gammaMap.globals + override def params: Set[BVar] = index.params ++ gammaMap.params override def loads: Set[BExpr] = Set(this) ++ index.loads } @@ -780,165 +651,66 @@ case class GammaStore(gammaMap: BMapVar, index: BExpr, value: BExpr, bits: Int, gammaMap.functionOps ++ index.functionOps ++ value.functionOps + GammaStoreOp(addressSize, bits, accesses) override def locals: Set[BVar] = gammaMap.locals ++ index.locals ++ value.locals override def globals: Set[BVar] = index.globals ++ gammaMap.globals ++ value.globals + override def params: Set[BVar] = index.params ++ gammaMap.params ++ value.params override def loads: Set[BExpr] = index.loads ++ value.loads } -case class L(memory: BMapVar, index: BExpr) extends BExpr { - override def toString: String = s"L($memory, $index)" +case class L(memories: List[BMapVar], index: BExpr) extends BExpr { + override def toString: String = if (memories.isEmpty) { + s"L($index)" + } else { + s"L(${memories.mkString(", ")}, $index)" + } override val getType: BType = BoolBType - override def functionOps: Set[FunctionOp] = index.functionOps + LOp(memory.getType, index.getType) - override def locals: Set[BVar] = index.locals - override def globals: Set[BVar] = index.globals + override def functionOps: Set[FunctionOp] = index.functionOps + LOp(index.getType) + override def locals: Set[BVar] = index.locals ++ memories.flatMap(_.locals) + override def globals: Set[BVar] = index.globals ++ memories.flatMap(_.globals) + override def params: Set[BVar] = index.params ++ memories.flatMap(_.params) override def loads: Set[BExpr] = index.loads } /** spec **/ trait SpecVar extends BExpr { + val address: BigInt override def getType: BType = { throw new Exception("getType called on SpecVar") } } -trait SpecGlobalOrAccess extends SpecVar { +trait SpecGlobalOrAccess extends SpecVar with Ordered[SpecGlobalOrAccess] { val toAddrVar: BExpr val toOldVar: BVar val toOldGamma: BVar val size: Int + + def compare(that: SpecGlobalOrAccess): Int = address.compare(that.address) } -case class SpecGlobal(name: String, override val size: Int, arraySize: Option[Int], address: BigInt) - extends SpecGlobalOrAccess { +case class FuncEntry(override val name: String, override val size: Int, override val address: BigInt) extends SymbolTableEntry + +case class SpecGlobal(override val name: String, override val size: Int, arraySize: Option[Int], override val address: BigInt) + extends SymbolTableEntry, SpecGlobalOrAccess { override def specGlobals: Set[SpecGlobalOrAccess] = Set(this) override val toAddrVar: BVar = BVariable("$" + s"${name}_addr", BitVecBType(64), Scope.Const) override val toOldVar: BVar = BVariable(s"${name}_old", BitVecBType(size), Scope.Local) override val toOldGamma: BVar = BVariable(s"Gamma_${name}_old", BoolBType, Scope.Local) val toAxiom: BAxiom = BAxiom(BinaryBExpr(BoolEQ, toAddrVar, BitVecBLiteral(address, 64)), List.empty) - override def resolveSpec: BMemoryLoad = BMemoryLoad( - BMapVar("mem", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Global), - toAddrVar, - Endian.LittleEndian, - size - ) - override def resolveSpecParam: BMemoryLoad = BMemoryLoad( - BMapVar("mem$out", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter), - toAddrVar, - Endian.LittleEndian, - size - ) - override def resolveSpecParamOld: BMemoryLoad = BMemoryLoad( - BMapVar("mem$in", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter), - toAddrVar, - Endian.LittleEndian, - size - ) - override def resolveSpecInv: BMemoryLoad = BMemoryLoad( - BMapVar("mem$inv2", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Local), - toAddrVar, - Endian.LittleEndian, - size - ) - override def resolveSpecInvOld: BMemoryLoad = BMemoryLoad( - BMapVar("mem$inv1", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Local), - toAddrVar, - Endian.LittleEndian, - size - ) - override def resolveOld: BMemoryLoad = resolveSpec - override def resolveInsideOld: BExpr = toOldVar - override def removeOld: BMemoryLoad = resolveSpec - override def resolveSpecL: BMemoryLoad = BMemoryLoad( - BMapVar("memory", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter), - toAddrVar, - Endian.LittleEndian, - size - ) + override def acceptVisit(visitor: BVisitor): BExpr = visitor.visitSpecGlobal(this) } case class SpecGamma(global: SpecGlobal) extends SpecVar { - // TODO don't hardcode this - override def resolveSpec: GammaLoad = GammaLoad( - BMapVar("Gamma_mem", MapBType(BitVecBType(64), BoolBType), Scope.Global), - global.toAddrVar, - global.size, - global.size / 8 - ) - override def resolveSpecParam: GammaLoad = GammaLoad( - BMapVar("Gamma_mem$out", MapBType(BitVecBType(64), BoolBType), Scope.Parameter), - global.toAddrVar, - global.size, - global.size / 8 - ) - override def resolveSpecParamOld: GammaLoad = GammaLoad( - BMapVar("Gamma_mem$in", MapBType(BitVecBType(64), BoolBType), Scope.Parameter), - global.toAddrVar, - global.size, - global.size / 8 - ) - override def resolveSpecInv: GammaLoad = GammaLoad( - BMapVar("Gamma_mem$inv2", MapBType(BitVecBType(64), BoolBType), Scope.Local), - global.toAddrVar, - global.size, - global.size / 8 - ) - override def resolveSpecInvOld: GammaLoad = GammaLoad( - BMapVar("Gamma_mem$inv1", MapBType(BitVecBType(64), BoolBType), Scope.Local), - global.toAddrVar, - global.size, - global.size / 8 - ) - override def resolveOld: GammaLoad = resolveSpec - override def resolveInsideOld: BExpr = global.toOldGamma - override def removeOld: GammaLoad = resolveSpec - override def resolveSpecL: GammaLoad = resolveSpec + override val address = global.address + override def acceptVisit(visitor: BVisitor): BExpr = visitor.visitSpecGamma(this) } case class ArrayAccess(global: SpecGlobal, index: Int) extends SpecGlobalOrAccess { + val offset = index * (global.size / 8) + override val address = global.address + offset override val size: Int = global.size - private val accessIndex = BitVecBLiteral(index * (global.size / 8), 64) override val toOldVar: BVar = BVariable(s"${global.name}$$${index}_old", BitVecBType(global.size), Scope.Local) - override val toAddrVar: BExpr = BinaryBExpr(BVADD, global.toAddrVar, accessIndex) + override val toAddrVar: BExpr = BinaryBExpr(BVADD, global.toAddrVar, BitVecBLiteral(offset, 64)) override val toOldGamma: BVar = BVariable(s"Gamma_${global.name}$$${index}_old", BoolBType, Scope.Local) override def specGlobals: Set[SpecGlobalOrAccess] = Set(this) - override def resolveSpec: BMemoryLoad = BMemoryLoad( - BMapVar("mem", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Global), - toAddrVar, - Endian.LittleEndian, - global.size - ) - override def resolveSpecParam: BMemoryLoad = BMemoryLoad( - BMapVar("mem$out", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter), - toAddrVar, - Endian.LittleEndian, - global.size - ) - override def resolveSpecParamOld: BMemoryLoad = BMemoryLoad( - BMapVar("mem$in", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter), - toAddrVar, - Endian.LittleEndian, - global.size - ) - - override def resolveSpecInv: BMemoryLoad = BMemoryLoad( - BMapVar("mem$inv2", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Local), - toAddrVar, - Endian.LittleEndian, - global.size - ) - override def resolveSpecInvOld: BMemoryLoad = BMemoryLoad( - BMapVar("mem$inv1", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Local), - toAddrVar, - Endian.LittleEndian, - global.size - ) - override def resolveOld: BMemoryLoad = resolveSpec - override def resolveInsideOld: BExpr = toOldVar - override def removeOld: BMemoryLoad = resolveSpec - override def resolveSpecL: BMemoryLoad = BMemoryLoad( - BMapVar("memory", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter), - toAddrVar, - Endian.LittleEndian, - global.size - ) + override def acceptVisit(visitor: BVisitor): BExpr = visitor.visitArrayAccess(this) } - diff --git a/src/main/scala/boogie/BProgram.scala b/src/main/scala/boogie/BProgram.scala index cfb142699..2ca25e54c 100644 --- a/src/main/scala/boogie/BProgram.scala +++ b/src/main/scala/boogie/BProgram.scala @@ -75,12 +75,19 @@ case class BProcedure( procList ++ implList ++ List("") } override def toString: String = toBoogie.mkString("\n") - def functionOps: Set[FunctionOp] = - body.flatMap(c => c.functionOps).toSet ++ ensures.flatMap(c => c.functionOps).toSet ++ requires - .flatMap(c => c.functionOps) - .toSet ++ freeEnsures.flatMap(c => c.functionOps).toSet ++ freeRequires.flatMap(c => c.functionOps).toSet + def functionOps: Set[FunctionOp] = { + val bodyOps = body.flatMap(_.functionOps) + val ensuresOps = ensures.flatMap(_.functionOps) ++ freeEnsures.flatMap(_.functionOps) + val requiresOps = requires.flatMap(_.functionOps) ++ freeRequires.flatMap(_.functionOps) + (bodyOps ++ ensuresOps ++ requiresOps).toSet + } - def globals: Set[BVar] = body.flatMap(c => c.globals).toSet ++ modifies + def globals: Set[BVar] = { + val bodyGlobals = body.flatMap(_.globals) + val ensuresGlobals = ensures.flatMap(_.globals) ++ freeEnsures.flatMap(_.globals) + val requiresGlobals = requires.flatMap(_.globals) ++ freeRequires.flatMap(_.globals) + (bodyGlobals ++ ensuresGlobals ++ requiresGlobals).toSet ++ modifies + } } case class BAxiom(body: BExpr, override val attributes: List[BAttribute] = List()) extends BDeclaration { diff --git a/src/main/scala/boogie/BVisitor.scala b/src/main/scala/boogie/BVisitor.scala new file mode 100644 index 000000000..02d63b4cb --- /dev/null +++ b/src/main/scala/boogie/BVisitor.scala @@ -0,0 +1,263 @@ +package boogie + +import analysis.RegionInjector +import ir.{Endian, IntBinOp, IntUnOp} +import boogie.{ArrayAccess, SpecGamma, SpecGlobal} + +trait BVisitor { + def visitBExpr(node: BExpr): BExpr = node.acceptVisit(this) + + def visitBVExtract(node: BVExtract): BExpr = node.copy(body = visitBExpr(node.body)) + + def visitBVRepeat(node: BVRepeat): BExpr = node.copy(body = visitBExpr(node.body)) + + def visitBVZeroExtend(node: BVZeroExtend): BExpr = node.copy(body = visitBExpr(node.body)) + + def visitBVSignExtend(node: BVSignExtend): BExpr = node.copy(body = visitBExpr(node.body)) + + def visitBFunctionCall(node: BFunctionCall): BExpr = node.copy(args = node.args.map(visitBExpr)) + + def visitUnaryBExpr(node: UnaryBExpr): BExpr = node.copy(arg = visitBExpr(node.arg)) + + def visitBinaryBExpr(node: BinaryBExpr): BExpr = { + node.copy(arg1 = visitBExpr(node.arg1), arg2 = visitBExpr(node.arg2)) + } + + def visitIfThenElse(node: IfThenElse): BExpr = { + node.copy(guard = visitBExpr(node.guard), thenExpr = visitBExpr(node.thenExpr), elseExpr = visitBExpr(node.elseExpr)) + } + + def visitOld(node: Old): BExpr = node.copy(body = visitBExpr(node.body)) + + def visitSpecGlobal(node: SpecGlobal): BExpr = node + + def visitSpecGamma(node: SpecGamma): BExpr = node + + def visitArrayAccess(node: ArrayAccess): BExpr = node +} + +trait SpecResolutionVisitor extends BVisitor { + override def visitUnaryBExpr(node: UnaryBExpr): BExpr = { + node.op match { + case i: IntUnOp => node.copy(op = i.toBV, arg = visitBExpr(node.arg)) + case _ => node.copy(arg = visitBExpr(node.arg)) + } + } + + override def visitBinaryBExpr(node: BinaryBExpr): BExpr = { + node.op match { + case i: IntBinOp => node.copy(op = i.toBV, arg1 = visitBExpr(node.arg1), arg2 = visitBExpr(node.arg2)) + case _ => node.copy(arg1 = visitBExpr(node.arg1), arg2 = visitBExpr(node.arg2)) + } + } +} + +class ResolveSpec(regionInjector: Option[RegionInjector]) extends SpecResolutionVisitor { + private val mem = BMapVar("mem", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Global) + private val gammaMem = BMapVar("Gamma_mem", MapBType(BitVecBType(64), BoolBType), Scope.Global) + + override def visitSpecGlobal(node: SpecGlobal): BMemoryLoad = { + val memory = if (regionInjector.isDefined) { + regionInjector.get.getMergedRegion(node.address) match { + case Some(region) => BMapVar(region.name, MapBType(BitVecBType(64), BitVecBType(8)), Scope.Global) + case None => mem + } + } else { + mem + } + BMemoryLoad(memory, node.toAddrVar, Endian.LittleEndian, node.size) + } + + override def visitSpecGamma(node: SpecGamma): GammaLoad = { + val gammaMemory = if (regionInjector.isDefined) { + regionInjector.get.getMergedRegion(node.address) match { + case Some(region) => BMapVar(s"Gamma_${region.name}", MapBType(BitVecBType(64), BoolBType), Scope.Global) + case None => gammaMem + } + } else { + gammaMem + } + GammaLoad(gammaMemory, node.global.toAddrVar, node.global.size, node.global.size / 8) + } + + override def visitArrayAccess(node: ArrayAccess): BMemoryLoad = { + val memory = if (regionInjector.isDefined) { + regionInjector.get.getMergedRegion(node.address) match { + case Some(region) => BMapVar(region.name, MapBType(BitVecBType(64), BitVecBType(8)), Scope.Global) + case None => mem + } + } else { + mem + } + BMemoryLoad(memory, node.toAddrVar, Endian.LittleEndian, node.size) + } + +} + +class ResolveOld(resolveSpec: ResolveSpec) extends SpecResolutionVisitor { + override def visitOld(node: Old): BExpr = ResolveInsideOld.visitBExpr(node.body) + override def visitSpecGlobal(node: SpecGlobal): BMemoryLoad = resolveSpec.visitSpecGlobal(node) + override def visitSpecGamma(node: SpecGamma): GammaLoad = resolveSpec.visitSpecGamma(node) + override def visitArrayAccess(node: ArrayAccess): BMemoryLoad = resolveSpec.visitArrayAccess(node) +} + +class RemoveOld(resolveSpec: ResolveSpec) extends SpecResolutionVisitor { + override def visitOld(node: Old): BExpr = resolveSpec.visitBExpr(node.body) + override def visitSpecGlobal(node: SpecGlobal): BMemoryLoad = resolveSpec.visitSpecGlobal(node) + override def visitSpecGamma(node: SpecGamma): GammaLoad = resolveSpec.visitSpecGamma(node) + override def visitArrayAccess(node: ArrayAccess): BMemoryLoad = resolveSpec.visitArrayAccess(node) +} + +class ResolveSpecL(regionInjector: Option[RegionInjector]) extends SpecResolutionVisitor { + private val mem_in = BMapVar("mem$in", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter) + override def visitSpecGlobal(node: SpecGlobal): BMemoryLoad = { + val memory = if (regionInjector.isDefined) { + regionInjector.get.getMergedRegion(node.address) match { + case Some(region) => BMapVar(s"${region.name}$$in", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter) + case None => mem_in + } + } else { + mem_in + } + BMemoryLoad(memory, node.toAddrVar, Endian.LittleEndian, node.size) + } + + override def visitArrayAccess(node: ArrayAccess): BMemoryLoad = { + val memory = if (regionInjector.isDefined) { + regionInjector.get.getMergedRegion(node.address) match { + case Some(region) => BMapVar(s"${region.name}$$in", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter) + case None => mem_in + } + } else { + mem_in + } + BMemoryLoad(memory, node.toAddrVar, Endian.LittleEndian, node.size) + } +} + +object ResolveInsideOld extends SpecResolutionVisitor { + override def visitSpecGlobal(node: SpecGlobal): BExpr = node.toOldVar + override def visitSpecGamma(node: SpecGamma): BExpr = node.global.toOldGamma + override def visitArrayAccess(node: ArrayAccess): BExpr = node.toOldVar +} + +object ResolveSpecParam extends SpecResolutionVisitor { + override def visitOld(node: Old): BExpr = ResolveSpecParamOld.visitBExpr(node.body) + + override def visitSpecGlobal(node: SpecGlobal): BMemoryLoad = { + BMemoryLoad( + BMapVar("mem$out", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter), + node.toAddrVar, + Endian.LittleEndian, + node.size + ) + } + + override def visitSpecGamma(node: SpecGamma): GammaLoad = { + GammaLoad( + BMapVar("Gamma_mem$out", MapBType(BitVecBType(64), BoolBType), Scope.Parameter), + node.global.toAddrVar, + node.global.size, + node.global.size / 8 + ) + } + + override def visitArrayAccess(node: ArrayAccess): BMemoryLoad = { + BMemoryLoad( + BMapVar("mem$out", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter), + node.toAddrVar, + Endian.LittleEndian, + node.global.size + ) + } +} + +object ResolveSpecParamOld extends SpecResolutionVisitor { + override def visitSpecGlobal(node: SpecGlobal): BMemoryLoad = { + BMemoryLoad( + BMapVar("mem$in", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter), + node.toAddrVar, + Endian.LittleEndian, + node.size + ) + } + + override def visitSpecGamma(node: SpecGamma): GammaLoad = { + GammaLoad( + BMapVar("Gamma_mem$in", MapBType(BitVecBType(64), BoolBType), Scope.Parameter), + node.global.toAddrVar, + node.global.size, + node.global.size / 8 + ) + } + + override def visitArrayAccess(node: ArrayAccess): BMemoryLoad = { + BMemoryLoad( + BMapVar("mem$in", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter), + node.toAddrVar, + Endian.LittleEndian, + node.global.size + ) + } +} + +object ResolveSpecInv extends SpecResolutionVisitor { + override def visitOld(node: Old): BExpr = ResolveSpecInvOld.visitBExpr(node.body) + + override def visitSpecGlobal(node: SpecGlobal): BMemoryLoad = { + BMemoryLoad( + BMapVar("mem$inv2", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Local), + node.toAddrVar, + Endian.LittleEndian, + node.size + ) + } + + override def visitSpecGamma(node: SpecGamma): GammaLoad = { + GammaLoad( + BMapVar("Gamma_mem$inv2", MapBType(BitVecBType(64), BoolBType), Scope.Local), + node.global.toAddrVar, + node.global.size, + node.global.size / 8 + ) + } + + override def visitArrayAccess(node: ArrayAccess): BMemoryLoad = { + BMemoryLoad( + BMapVar("mem$inv2", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Local), + node.toAddrVar, + Endian.LittleEndian, + node.global.size + ) + } +} + +object ResolveSpecInvOld extends SpecResolutionVisitor { + override def visitSpecGlobal(node: SpecGlobal): BMemoryLoad = { + BMemoryLoad( + BMapVar("mem$inv1", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Local), + node.toAddrVar, + Endian.LittleEndian, + node.size + ) + } + + override def visitSpecGamma(node: SpecGamma): GammaLoad = { + GammaLoad( + BMapVar("Gamma_mem$inv1", MapBType(BitVecBType(64), BoolBType), Scope.Local), + node.global.toAddrVar, + node.global.size, + node.global.size / 8 + ) + } + + override def visitArrayAccess(node: ArrayAccess): BMemoryLoad = { + BMemoryLoad( + BMapVar("mem$inv1", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Local), + node.toAddrVar, + Endian.LittleEndian, + node.global.size + ) + } + +} diff --git a/src/main/scala/cfg_visualiser/DotTools.scala b/src/main/scala/cfg_visualiser/DotTools.scala index 9162325b8..d4542f04d 100644 --- a/src/main/scala/cfg_visualiser/DotTools.scala +++ b/src/main/scala/cfg_visualiser/DotTools.scala @@ -150,3 +150,68 @@ class DotGraph(val title: String, val nodes: Iterable[DotNode], val edges: Itera val graph = "graph [ fontsize=18 ];" def toDotString: String = "digraph " + title + " {\n" + graph + "\n" + (nodes ++ edges).foldLeft("")((str, elm) => str + elm.toDotString + "\n") + "}" } + + + +class DotStruct(val id: String, val details: String, val fields: Option[Iterable[String]], val verbose: Boolean = true) extends DotElement { + def equals(other: DotStruct): Boolean = toDotString.equals(other.toDotString) + + + val label = s"\"{<$id> ${if verbose then wrap(details, 80) else id} ${if fields.isDefined then s" | {${fields.get.map(f => s"<$f> $f").mkString("|")}}" else "" }}\"" + override def toString: String = toDotString + + override def toDotString: String = + s"$id " + "[label=" + label + "]" +} + +class DotStructElement(val id: String, val field: Option[String]) extends DotElement { + def equals(other: DotStruct): Boolean = toDotString.equals(other.toDotString) + override def toString: String = toDotString + + override def toDotString: String = + s"$id${if field.isDefined then ":" + field.get else ""}" +} + +case class StructArrow( + from: DotStructElement, + to: DotStructElement, + label: String = "", + arrow: String = "->", + style: String = "solid", + colour: String = "black") extends DotElement { + + def equals(other: DotArrow): Boolean = toDotString.equals(other.toDotString) + + def toDotString: String = + s"${from.toString} $arrow ${to.toString} [label=\"$label\", style=\"$style\", color=\"$colour\"]" +} + + +/** Represents a Graphviz dot graph. + */ +class StructDotGraph(val title: String, val nodes: Iterable[DotStruct], val edges: Iterable[StructArrow]) extends DotElement { + + def this(nodes: List[DotStruct], edges: List[StructArrow]) = this("", nodes, edges) + + def this(title: String) = this(title, List(), List()) + + def this() = this(List(), List()) + + def addGraph(g: StructDotGraph): StructDotGraph = { + val ng = g.nodes.foldLeft(this)((g, n) => g.addNode(n)) + g.edges.foldLeft(ng)((g, e) => g.addEdge(e)) + } + + def addNode(n: DotStruct): StructDotGraph = + if (nodes.exists(a => n.equals(a))) this + else new StructDotGraph(title, nodes ++ List(n), edges) + + def addEdge(e: StructArrow): StructDotGraph = + if (edges.exists(a => e.equals(a))) this + else new StructDotGraph(title, nodes, edges ++ List(e)) + + override def toString: String = toDotString + + def toDotString: String = "digraph " + title + " {\nrankdir=\"LR\"\nnode [shape=record];\n" + (nodes ++ edges).foldLeft("")((str, elm) => str + elm.toDotString + "\n") + "}" +} + diff --git a/src/main/scala/ir/Expr.scala b/src/main/scala/ir/Expr.scala index 15d601ec2..447ed82a6 100644 --- a/src/main/scala/ir/Expr.scala +++ b/src/main/scala/ir/Expr.scala @@ -4,21 +4,8 @@ import scala.collection.mutable sealed trait Expr { def toBoogie: BExpr - def toGamma: BExpr = { - val gammaVars: Set[BExpr] = gammas.map(_.toGamma) - if (gammaVars.isEmpty) { - TrueBLiteral - } else if (gammaVars.size == 1) { - gammaVars.head - } else { - gammaVars.tail.foldLeft(gammaVars.head) { (join: BExpr, next: BExpr) => - BinaryBExpr(BoolAND, next, join) - } - } - } - def loads: Set[MemoryLoad] = Set() def getType: IRType - def gammas: Set[Expr] = Set() + def gammas: Set[Variable] = Set() // variables not including those inside a load's index def variables: Set[Variable] = Set() def acceptVisit(visitor: Visitor): Expr = throw new Exception("visitor " + visitor + " unimplemented for: " + this) @@ -75,17 +62,16 @@ case class IntLiteral(value: BigInt) extends Literal { */ case class Extract(end: Int, start: Int, body: Expr) extends Expr { override def toBoogie: BExpr = BVExtract(end, start, body.toBoogie) - override def gammas: Set[Expr] = body.gammas + override def gammas: Set[Variable] = body.gammas override def variables: Set[Variable] = body.variables override def getType: BitVecType = BitVecType(end - start) override def toString: String = s"$body[$end:$start]" override def acceptVisit(visitor: Visitor): Expr = visitor.visitExtract(this) - override def loads: Set[MemoryLoad] = body.loads } case class Repeat(repeats: Int, body: Expr) extends Expr { override def toBoogie: BExpr = BVRepeat(repeats, body.toBoogie) - override def gammas: Set[Expr] = body.gammas + override def gammas: Set[Variable] = body.gammas override def variables: Set[Variable] = body.variables override def getType: BitVecType = BitVecType(bodySize * repeats) private def bodySize: Int = body.getType match { @@ -94,12 +80,11 @@ case class Repeat(repeats: Int, body: Expr) extends Expr { } override def toString: String = s"Repeat($repeats, $body)" override def acceptVisit(visitor: Visitor): Expr = visitor.visitRepeat(this) - override def loads: Set[MemoryLoad] = body.loads } case class ZeroExtend(extension: Int, body: Expr) extends Expr { override def toBoogie: BExpr = BVZeroExtend(extension, body.toBoogie) - override def gammas: Set[Expr] = body.gammas + override def gammas: Set[Variable] = body.gammas override def variables: Set[Variable] = body.variables override def getType: BitVecType = BitVecType(bodySize + extension) private def bodySize: Int = body.getType match { @@ -108,12 +93,11 @@ case class ZeroExtend(extension: Int, body: Expr) extends Expr { } override def toString: String = s"ZeroExtend($extension, $body)" override def acceptVisit(visitor: Visitor): Expr = visitor.visitZeroExtend(this) - override def loads: Set[MemoryLoad] = body.loads } case class SignExtend(extension: Int, body: Expr) extends Expr { override def toBoogie: BExpr = BVSignExtend(extension, body.toBoogie) - override def gammas: Set[Expr] = body.gammas + override def gammas: Set[Variable] = body.gammas override def variables: Set[Variable] = body.variables override def getType: BitVecType = BitVecType(bodySize + extension) private def bodySize: Int = body.getType match { @@ -122,14 +106,12 @@ case class SignExtend(extension: Int, body: Expr) extends Expr { } override def toString: String = s"SignExtend($extension, $body)" override def acceptVisit(visitor: Visitor): Expr = visitor.visitSignExtend(this) - override def loads: Set[MemoryLoad] = body.loads } case class UnaryExpr(op: UnOp, arg: Expr) extends Expr { override def toBoogie: BExpr = UnaryBExpr(op, arg.toBoogie) - override def gammas: Set[Expr] = arg.gammas + override def gammas: Set[Variable] = arg.gammas override def variables: Set[Variable] = arg.variables - override def loads: Set[MemoryLoad] = arg.loads override def getType: IRType = (op, arg.getType) match { case (BoolToBV1, BoolType) => BitVecType(1) case (_: BoolUnOp, BoolType) => BoolType @@ -177,9 +159,8 @@ case object BVNEG extends BVUnOp("neg") case class BinaryExpr(op: BinOp, arg1: Expr, arg2: Expr) extends Expr { override def toBoogie: BExpr = BinaryBExpr(op, arg1.toBoogie, arg2.toBoogie) - override def gammas: Set[Expr] = arg1.gammas ++ arg2.gammas + override def gammas: Set[Variable] = arg1.gammas ++ arg2.gammas override def variables: Set[Variable] = arg1.variables ++ arg2.variables - override def loads: Set[MemoryLoad] = arg1.loads ++ arg2.loads override def getType: IRType = (op, arg1.getType, arg2.getType) match { case (_: BoolBinOp, BoolType, BoolType) => BoolType case (binOp: BVBinOp, bv1: BitVecType, bv2: BitVecType) => @@ -327,27 +308,10 @@ enum Endian { case BigEndian } -case class MemoryLoad(mem: Memory, index: Expr, endian: Endian, size: Int) extends Expr { - override def toBoogie: BMemoryLoad = BMemoryLoad(mem.toBoogie, index.toBoogie, endian, size) - override def toGamma: BExpr = mem match { - case m: StackMemory => - GammaLoad(m.toGamma, index.toBoogie, size, size / m.valueSize) - case m: SharedMemory => - BinaryBExpr(BoolOR, GammaLoad(m.toGamma, index.toBoogie, size, size / m.valueSize), L(m.toBoogie, index.toBoogie)) - } - override def variables: Set[Variable] = index.variables - override def gammas: Set[Expr] = Set(this) - override def loads: Set[MemoryLoad] = Set(this) - override def getType: IRType = BitVecType(size) - override def toString: String = s"MemoryLoad($mem, $index, $endian, $size)" - override def acceptVisit(visitor: Visitor): Expr = visitor.visitMemoryLoad(this) -} - case class UninterpretedFunction(name: String, params: Seq[Expr], returnType: IRType) extends Expr { override def getType: IRType = returnType override def toBoogie: BFunctionCall = BFunctionCall(name, params.map(_.toBoogie).toList, returnType.toBoogie, true) override def acceptVisit(visitor: Visitor): Expr = visitor.visitUninterpretedFunction(this) - override def gammas: Set[Expr] = params.flatMap(_.gammas).toSet override def variables: Set[Variable] = params.flatMap(_.variables).toSet override def toString = s"$name(${params.mkString(", ")})" } @@ -360,14 +324,12 @@ sealed trait Global sealed trait Variable extends Expr { val name: String val irType: IRType - var sharedVariable: Boolean = false override def getType: IRType = irType override def variables: Set[Variable] = Set(this) - override def gammas: Set[Expr] = Set(this) + override def gammas: Set[Variable] = Set(this) override def toBoogie: BVar - // placeholder definition not actually used - override def toGamma: BVar = BVariable(s"$name", irType.toBoogie, Scope.Global) + def toGamma: BVar override def toString: String = s"Variable($name, $irType)" @@ -394,7 +356,7 @@ case class LocalVar(varName: String, override val irType: IRType, val index: Int override val name = varName + (if (index > 0) then s"_$index" else "") override def toGamma: BVar = BVariable(s"Gamma_$name", BoolBType, Scope.Local) override def toBoogie: BVar = BVariable(s"$name", irType.toBoogie, Scope.Local) - override def toString: String = s"LocalVar(${name}, ${if sharedVariable then "shared" else "unshared"}, $irType)" + override def toString: String = s"LocalVar(${name}, $irType)" override def acceptVisit(visitor: Visitor): Variable = visitor.visitLocalVar(this) } diff --git a/src/main/scala/ir/IRCursor.scala b/src/main/scala/ir/IRCursor.scala index ddcf83faa..b61f7a9d1 100644 --- a/src/main/scala/ir/IRCursor.scala +++ b/src/main/scala/ir/IRCursor.scala @@ -148,27 +148,21 @@ object IntraProcBlockIRCursor extends IntraProcBlockIRCursor trait InterProcIRCursor extends IRWalk[CFGPosition, CFGPosition] { final def succ(pos: CFGPosition): Set[CFGPosition] = { - IntraProcIRCursor.succ(pos) ++ - (pos match + pos match case c: DirectCall if c.target.blocks.nonEmpty => Set(c.target) case c: Return => c.parent.parent.incomingCalls().map(_.successor).toSet - case _ => Set.empty - ) + case _ => IntraProcIRCursor.succ(pos) } final def pred(pos: CFGPosition): Set[CFGPosition] = { - IntraProcIRCursor.pred(pos) ++ - (pos match - case c: Command => { + pos match + case c: Command => IRWalk.prevCommandInBlock(c) match { case Some(d: DirectCall) if d.target.blocks.nonEmpty => d.target.returnBlock.toSet - case o => o.toSet + case o => o.toSet ++ IntraProcIRCursor.pred(pos) } - - } - case c: Procedure => c.incomingCalls().toSet.asInstanceOf[Set[CFGPosition]] - case _ => Set.empty - ) + case c: Procedure => c.incomingCalls().toSet.asInstanceOf[Set[CFGPosition]] + case _ => IntraProcIRCursor.pred(pos) } } @@ -177,7 +171,7 @@ object InterProcIRCursor extends InterProcIRCursor trait CallGraph extends IRWalk[Procedure, Procedure] { final def succ(b: Procedure): Set[Procedure] = b.calls - final def pred(b: Procedure): Set[Procedure] = b.incomingCalls().map(_.target).toSet + final def pred(b: Procedure): Set[Procedure] = b.incomingCalls().map(_.parent.parent).toSet } object CallGraph extends CallGraph @@ -251,11 +245,17 @@ def stronglyConnectedComponents[T <: CFGPosition, O <: T](walker: IRWalk[T, O], out } -def toDot(program: Program, labels: Map[CFGPosition, String] = Map.empty): String = { - val domain = computeDomain[CFGPosition, CFGPosition](IntraProcIRCursor, program.procedures) - toDot[CFGPosition](domain.toSet, IntraProcIRCursor, labels) +def toDot(program: Program, labels: Map[CFGPosition, String] = Map.empty, inter: Boolean = false): String = { + if (inter) { + val domain = computeDomain[CFGPosition, CFGPosition](InterProcIRCursor, program.procedures).toSet + toDot[CFGPosition](domain, InterProcIRCursor, labels) + } else { + val domain = computeDomain[CFGPosition, CFGPosition](IntraProcIRCursor, program.procedures).toSet + toDot[CFGPosition](domain, IntraProcIRCursor, labels) + } } + def dotCallGraph(program: Program, labels: Map[CFGPosition, String] = Map.empty): String = { val domain = computeDomain[Procedure, Procedure](CallGraph, program.procedures) toDot[Procedure](domain.toSet, CallGraph, labels) @@ -322,7 +322,7 @@ def toDot[T <: CFGPosition]( case s => s.toString } if (labels.contains(node)) { - text += "\n" ++ labels(node) + text = text + "\n\n" + labels(node) } text } diff --git a/src/main/scala/ir/Program.scala b/src/main/scala/ir/Program.scala index 37fb98f19..bf69019a0 100644 --- a/src/main/scala/ir/Program.scala +++ b/src/main/scala/ir/Program.scala @@ -3,6 +3,7 @@ package ir import scala.collection.mutable.ArrayBuffer import scala.collection.{IterableOnceExtensionMethods, View, immutable, mutable} import boogie.* +import analysis.{MergedRegion} import util.intrusive_list.* import translating.serialiseIL import eval.BitVectorEval @@ -35,11 +36,10 @@ class ILUnorderedIterator(private val begin: Iterable[CFGPosition]) extends Iter class Program(val procedures: ArrayBuffer[Procedure], var mainProcedure: Procedure, - var initialMemory: ArrayBuffer[MemorySection], - var readOnlyMemory: ArrayBuffer[MemorySection]) extends Iterable[CFGPosition] { + val initialMemory: mutable.TreeMap[BigInt, MemorySection]) extends Iterable[CFGPosition] { val threads: ArrayBuffer[ProgramThread] = ArrayBuffer() - + val usedMemory: mutable.Map[BigInt, MemorySection] = mutable.TreeMap() def removeProcedure(i: Int) : Unit = { val p = procedures(i) @@ -60,6 +60,7 @@ class Program(val procedures: ArrayBuffer[Procedure], procedures += p } + override def toString(): String = { serialiseIL(this) } @@ -118,14 +119,12 @@ class Program(val procedures: ArrayBuffer[Procedure], * section in readOnlyMemory. It also takes the .rela.dyn entries taken from the readelf output and adds them to the * .rodata section, as they are the global offset table entries that we can assume are constant. */ - def determineRelevantMemory(rela_dyn: Map[BigInt, BigInt]): Unit = { - val initialMemoryNew = ArrayBuffer[MemorySection]() - - val rodata = initialMemory.collect { case s if s.name == ".rodata" => s } - readOnlyMemory.addAll(rodata) - val data = initialMemory.collect { case s if s.name == ".data" => s } - initialMemoryNew.addAll(data) + def determineRelevantMemory(rela_dyn: Map[BigInt, BigInt]): Unit = { + val rodata = initialMemory.values.collect { case s if s.name == ".rodata" => s } + rodata.foreach { r => usedMemory.addOne(r.address, r) } + val data = initialMemory.values.collect { case s if s.name == ".data" => s } + data.foreach { d => usedMemory.addOne(d.address, d) } // assuming little endian, adding the rela_dyn offset/address pairs like this is crude but is simplest for now for ((offset, address) <- rela_dyn) { @@ -135,10 +134,9 @@ class Program(val procedures: ArrayBuffer[Procedure], val high = low + 8 BitVectorEval.boogie_extract(high, low, addressBV) } - readOnlyMemory.append(MemorySection(s".got_$offset", offset.intValue, 8, bytes)) + usedMemory.addOne(offset, MemorySection(s".got_$offset", offset, 8, bytes, true, None)) } - initialMemory = initialMemoryNew } @@ -150,6 +148,20 @@ class Program(val procedures: ArrayBuffer[Procedure], ILUnorderedIterator(this.procedures) } + private def memoryLookup(memory: mutable.TreeMap[BigInt, MemorySection], address: BigInt) = { + memory.maxBefore(address + 1) match { + case Some(_, section) => + if (section.address + section.size > address) { + Some(section) + } else { + None + } + case _ => None + } + } + + def initialMemoryLookup(address: BigInt): Option[MemorySection] = memoryLookup(initialMemory, address) + def nameToProcedure: Map[String, Procedure] = { procedures.view.map(p => p.name -> p).toMap } @@ -237,7 +249,7 @@ class Procedure private ( def returnBlock_=(value: Block): Unit = { if (!returnBlock.contains(value)) { - _returnBlock.foreach(removeBlocks(_)) + _returnBlock.foreach(removeBlocks) _returnBlock = Some(addBlocks(value)) } } @@ -246,7 +258,7 @@ class Procedure private ( def entryBlock_=(value: Block): Unit = { if (!entryBlock.contains(value)) { - _entryBlock.foreach(removeBlocks(_)) + _entryBlock.foreach(removeBlocks) _entryBlock = Some(addBlocks(value)) } } @@ -504,4 +516,17 @@ object Block { * @param size number of bytes * @param bytes sequence of bytes represented by BitVecLiterals of size 8 */ -case class MemorySection(name: String, address: BigInt, size: Int, bytes: Seq[BitVecLiteral]) +case class MemorySection(name: String, address: BigInt, size: Int, bytes: Seq[BitVecLiteral], readOnly: Boolean, region: Option[MergedRegion] = None) { + + def getBytes(addr: BigInt, num: Int): Seq[BitVecLiteral] = { + val startIndex = (addr - address).toInt + for (i <- 0 until num) yield { + val index = startIndex + i + if (index >= bytes.size || index < 0) { + throw Exception(s"can't get $num bytes from section $name with size $size starting at index $startIndex (access address $addr)") + } + bytes(index) + } + } + +} diff --git a/src/main/scala/ir/Statement.scala b/src/main/scala/ir/Statement.scala index 4fd94fac0..e6fac78fa 100644 --- a/src/main/scala/ir/Statement.scala +++ b/src/main/scala/ir/Statement.scala @@ -25,33 +25,52 @@ sealed trait Statement extends Command, IntrusiveListElement[Statement] { def acceptVisit(visitor: Visitor): Statement = throw new Exception( "visitor " + visitor + " unimplemented for: " + this ) - def successor: Command = parent.statements.nextOption(this).getOrElse(parent.jump) +} +sealed trait Assign extends Statement { + def assignees: Set[Variable] } -// invariant: rhs contains at most one MemoryLoad -class Assign(var lhs: Variable, var rhs: Expr, override val label: Option[String] = None) extends Statement { +sealed trait SingleAssign extends Assign { + def lhs: Variable + override def assignees = Set(lhs) +} + +class LocalAssign(var lhs: Variable, var rhs: Expr, override val label: Option[String] = None) extends SingleAssign { override def modifies: Set[Global] = lhs match { case r: Register => Set(r) case _ => Set() } override def toString: String = s"$labelStr$lhs := $rhs" - override def acceptVisit(visitor: Visitor): Statement = visitor.visitAssign(this) + override def acceptVisit(visitor: Visitor): Statement = visitor.visitLocalAssign(this) } -object Assign: - def unapply(l: Assign): Option[(Variable, Expr, Option[String])] = Some(l.lhs, l.rhs, l.label) +object LocalAssign: + def unapply(l: LocalAssign): Option[(Variable, Expr, Option[String])] = Some(l.lhs, l.rhs, l.label) -// invariant: index and value do not contain MemoryLoads -class MemoryAssign(var mem: Memory, var index: Expr, var value: Expr, var endian: Endian, var size: Int, override val label: Option[String] = None) extends Statement { +class MemoryStore(var mem: Memory, var index: Expr, var value: Expr, var endian: Endian, var size: Int, override val label: Option[String] = None) extends Statement { override def modifies: Set[Global] = Set(mem) override def toString: String = s"$labelStr$mem[$index] := MemoryStore($value, $endian, $size)" - override def acceptVisit(visitor: Visitor): Statement = visitor.visitMemoryAssign(this) + override def acceptVisit(visitor: Visitor): Statement = visitor.visitMemoryStore(this) +} + +object MemoryStore { + def unapply(m: MemoryStore): Option[(Memory, Expr, Expr, Endian, Int, Option[String])] = Some(m.mem, m.index, m.value, m.endian, m.size, m.label) +} + +class MemoryLoad(var lhs: Variable, var mem: Memory, var index: Expr, var endian: Endian, var size: Int, override val label: Option[String] = None) extends SingleAssign { + override def modifies: Set[Global] = lhs match { + case r: Register => Set(r) + case _ => Set() + } + override def toString: String = s"$labelStr$lhs := MemoryLoad($mem, $index, $endian, $size)" + override def acceptVisit(visitor: Visitor): Statement = visitor.visitMemoryLoad(this) } -object MemoryAssign: - def unapply(m: MemoryAssign): Option[(Memory, Expr, Expr, Endian, Int, Option[String])] = Some(m.mem, m.index, m.value, m.endian, m.size, m.label) +object MemoryLoad { + def unapply(m: MemoryLoad): Option[(Variable, Memory, Expr, Endian, Int, Option[String])] = Some(m.lhs, m.mem, m.index, m.endian, m.size, m.label) +} class NOP(override val label: Option[String] = None) extends Statement { override def toString: String = s"NOP $labelStr" @@ -89,11 +108,20 @@ class Unreachable(override val label: Option[String] = None) extends Jump { override def acceptVisit(visitor: Visitor): Jump = this } -class Return(override val label: Option[String] = None, var outParams : SortedMap[LocalVar, Expr] = SortedMap()) extends Jump { +class Return(override val label: Option[String] = None, var outParams : SortedMap[LocalVar, Expr] = SortedMap()) extends Jump { override def acceptVisit(visitor: Visitor): Jump = this override def toString = s"Return(${outParams.mkString(",")})" } + +object Unreachable { + def unapply(u: Unreachable): Option[Option[String]] = Some(u.label) +} + +object Return { + def unapply(r: Return): Option[(Option[String], SortedMap[LocalVar, Expr])] = Some((r.label, r.outParams)) +} + class GoTo private (private val _targets: mutable.LinkedHashSet[Block], override val label: Option[String]) extends Jump { def this(targets: Iterable[Block], label: Option[String] = None) = this(mutable.LinkedHashSet.from(targets), label) @@ -150,7 +178,7 @@ class DirectCall(val target: Procedure, override val label: Option[String] = None, var outParams: SortedMap[LocalVar, Variable] = SortedMap(), // out := formal var actualParams: SortedMap[LocalVar, Expr] = SortedMap(), // formal := actual - ) extends Call { + ) extends Call with Assign { /* override def locals: Set[Variable] = condition match { case Some(c) => c.locals case None => Set() @@ -159,6 +187,8 @@ class DirectCall(val target: Procedure, override def toString: String = s"${labelStr}${outParams.map(_._2.name).mkString(",")} := DirectCall(${target.name})(${actualParams.map(_._2).mkString(",")})" override def acceptVisit(visitor: Visitor): Statement = visitor.visitDirectCall(this) + def assignees = outParams.map(_._2).toSet + override def linkParent(p: Block): Unit = { super.linkParent(p) target.addCaller(this) diff --git a/src/main/scala/ir/Visitor.scala b/src/main/scala/ir/Visitor.scala index fd350c543..490e0ea13 100644 --- a/src/main/scala/ir/Visitor.scala +++ b/src/main/scala/ir/Visitor.scala @@ -10,19 +10,27 @@ abstract class Visitor { def visitStatement(node: Statement): Statement = node.acceptVisit(this) - def visitAssign(node: Assign): Statement = { + def visitLocalAssign(node: LocalAssign): Statement = { node.lhs = visitVariable(node.lhs) node.rhs = visitExpr(node.rhs) node } - def visitMemoryAssign(node: MemoryAssign): Statement = { + def visitMemoryStore(node: MemoryStore): Statement = { node.mem = visitMemory(node.mem) node.index = visitExpr(node.index) node.value = visitExpr(node.value) node } + def visitMemoryLoad(node: MemoryLoad): Statement = { + node.lhs = visitVariable(node.lhs) + node.mem = visitMemory(node.mem) + node.index = visitExpr(node.index) + node + } + + def visitAssume(node: Assume): Statement = { node.body = visitExpr(node.body) node @@ -103,10 +111,6 @@ abstract class Visitor { node.copy(arg1 = visitExpr(node.arg1), arg2 = visitExpr(node.arg2)) } - def visitMemoryLoad(node: MemoryLoad): Expr = { - node.copy(mem = visitMemory(node.mem), index = visitExpr(node.index)) - } - def visitMemory(node: Memory): Memory = node.acceptVisit(this) def visitStackMemory(node: StackMemory): Memory = node @@ -159,25 +163,26 @@ abstract class ReadOnlyVisitor extends Visitor { node } - override def visitMemoryLoad(node: MemoryLoad): Expr = { - visitMemory(node.mem) - visitExpr(node.index) - node - } - - override def visitAssign(node: Assign): Statement = { + override def visitLocalAssign(node: LocalAssign): Statement = { visitVariable(node.lhs) visitExpr(node.rhs) node } - override def visitMemoryAssign(node: MemoryAssign): Statement = { + override def visitMemoryStore(node: MemoryStore): Statement = { visitMemory(node.mem) visitExpr(node.index) visitExpr(node.value) node } + override def visitMemoryLoad(node: MemoryLoad): Statement = { + visitVariable(node.lhs) + visitMemory(node.mem) + visitExpr(node.index) + node + } + override def visitAssume(node: Assume): Statement = { visitExpr(node.body) node @@ -308,16 +313,17 @@ class StackSubstituter extends IntraproceduralControlFlowVisitor { override def visitMemoryLoad(node: MemoryLoad): MemoryLoad = { // replace mem with stack in load if index contains stack references if (node.index.variables.exists(isStackPtr)) { - node.copy(mem = stackMemory) - } else { - node + node.mem = stackMemory + } + + if (stackRefs.contains(node.lhs) && node.lhs != stackPointer) { + stackRefs.remove(node.lhs) } - } - override def visitAssign(node: Assign): Statement = { - node.lhs = visitVariable(node.lhs) - node.rhs = visitExpr(node.rhs) + node + } + override def visitLocalAssign(node: LocalAssign): Statement = { // update stack references val variableVisitor = VariablesWithoutStoresLoads() variableVisitor.visitExpr(node.rhs) @@ -330,7 +336,7 @@ class StackSubstituter extends IntraproceduralControlFlowVisitor { node } - override def visitMemoryAssign(node: MemoryAssign): Statement = { + override def visitMemoryStore(node: MemoryStore): Statement = { if (node.index.variables.exists(isStackPtr)) { node.mem = stackMemory } @@ -356,6 +362,18 @@ class Substituter(variables: Map[Variable, Variable] = Map(), memories: Map[Memo * Useful for avoiding Boogie's reserved keywords. */ class Renamer(reserved: Set[String]) extends Visitor { + override def visitProgram(node: Program): Program = { + for (section <- node.usedMemory.values) { + section.region match { + case Some(region) if reserved.contains(region.name) => + region.name = s"#${region.name}" + case _ => + } + } + + super.visitProgram(node) + } + override def visitLocalVar(node: LocalVar): LocalVar = { if (reserved.contains(node.varName)) { node.copy(varName = s"#${node.varName}") @@ -400,7 +418,7 @@ class ExternalRemover(external: Set[String]) extends Visitor { } } -/** Gives variables that are not contained within a MemoryStore or MemoryLoad +/** Gives variables that are not contained within a MemoryStore or the rhs of a MemoryLoad * */ class VariablesWithoutStoresLoads extends ReadOnlyVisitor { val variables: mutable.Set[Variable] = mutable.Set() @@ -416,6 +434,7 @@ class VariablesWithoutStoresLoads extends ReadOnlyVisitor { } override def visitMemoryLoad(node: MemoryLoad): MemoryLoad = { + visitVariable(node.lhs) node } diff --git a/src/main/scala/ir/cilvisitor/CILVisitor.scala b/src/main/scala/ir/cilvisitor/CILVisitor.scala index a44672324..714a2d9d3 100644 --- a/src/main/scala/ir/cilvisitor/CILVisitor.scala +++ b/src/main/scala/ir/cilvisitor/CILVisitor.scala @@ -32,7 +32,7 @@ trait CILVisitor: def enter_scope(params: Map[LocalVar, Expr]): Unit = () def leave_scope(): Unit = () -def doVisitList[T](v: CILVisitor, a: VisitAction[List[T]], n: T, continue: (T) => T): List[T] = { +def doVisitList[T](v: CILVisitor, a: VisitAction[List[T]], n: T, continue: T => T): List[T] = { a match { case SkipChildren() => List(n) case ChangeTo(z) => z @@ -41,7 +41,7 @@ def doVisitList[T](v: CILVisitor, a: VisitAction[List[T]], n: T, continue: (T) = } } -def doVisit[T](v: CILVisitor, a: VisitAction[T], n: T, continue: (T) => T): T = { +def doVisit[T](v: CILVisitor, a: VisitAction[T], n: T, continue: T => T): T = { a match { case SkipChildren() => n case DoChildren() => continue(n) @@ -63,7 +63,7 @@ class CILVisitorImpl(val v: CILVisitor) { } def visit_mem(n: Memory): Memory = { - doVisit(v, v.vmem(n), n, (n) => n) + doVisit(v, v.vmem(n), n, n => n) } def visit_jump(j: Jump): Jump = { @@ -84,11 +84,6 @@ class CILVisitorImpl(val v: CILVisitor) { def visit_expr(n: Expr): Expr = { def continue(n: Expr): Expr = n match { case n: Literal => n - case MemoryLoad(mem, index, endian, size) => { - val nmem = visit_mem(mem) - val nind = visit_expr(index) - if ((nmem ne mem) || (nind ne index)) MemoryLoad(visit_mem(mem), visit_expr(index), endian, size) else n - } case Extract(end, start, arg) => { val narg = visit_expr(arg) if (narg ne arg) Extract(end, start, narg) else n @@ -126,37 +121,36 @@ class CILVisitorImpl(val v: CILVisitor) { def visit_stmt(s: Statement): List[Statement] = { def continue(n: Statement) = n match { - case d: DirectCall => { + case d: DirectCall => val actuals = d.actualParams.map(i => i._1 -> visit_expr(i._2)) val outs = d.outParams.map(i => i._1 -> visit_lvar(i._2)) v.enter_scope(actuals) d.outParams = outs d.actualParams = actuals d - } - case i: IndirectCall => { + case i: IndirectCall => i.target = visit_rvar(i.target) i - } - case m: MemoryAssign => { + case m: MemoryStore => + m.value = visit_expr(m.value) + m.index = visit_expr(m.index) m.mem = visit_mem(m.mem) + m + case m: MemoryLoad => m.index = visit_expr(m.index) - m.value = visit_expr(m.value) + m.mem = visit_mem(m.mem) + m.lhs = visit_lvar(m.lhs) m - } - case m: Assign => { + case m: LocalAssign => m.rhs = visit_expr(m.rhs) m.lhs = visit_lvar(m.lhs) m - } - case s: Assert => { + case s: Assert => s.body = visit_expr(s.body) s - } - case s: Assume => { + case s: Assume => s.body = visit_expr(s.body) s - } case n: NOP => n } doVisitList(v, v.vstmt(s), s, continue) @@ -164,7 +158,7 @@ class CILVisitorImpl(val v: CILVisitor) { def visit_block(b: Block): Block = { def continue(b: Block) = { - b.statements.foreach(s => { + b.statements.foreach { s => val r = visit_stmt(s) r match { case Nil => b.statements.remove(s) @@ -172,7 +166,7 @@ class CILVisitorImpl(val v: CILVisitor) { b.statements.replace(s, n) b.statements.insertAllAfter(Some(n), tl) } - }) + } b.replaceJump(visit_jump(b.jump)) b } diff --git a/src/main/scala/ir/dsl/DSL.scala b/src/main/scala/ir/dsl/DSL.scala index 3be809b2f..03688084e 100644 --- a/src/main/scala/ir/dsl/DSL.scala +++ b/src/main/scala/ir/dsl/DSL.scala @@ -1,6 +1,7 @@ package ir.dsl import ir.* import scala.collection.mutable +import scala.collection.mutable.ArrayBuffer import scala.collection.immutable.* val R0: Register = Register("R0", 64) @@ -157,9 +158,8 @@ def stack: SharedMemory = SharedMemory("stack", 64, 8) def prog(procedures: EventuallyProcedure*): Program = { require(procedures.nonEmpty) - val initialMemory = mutable.ArrayBuffer.empty[MemorySection] - val readOnlyMemory = mutable.ArrayBuffer.empty[MemorySection] - val p = Program(mutable.ArrayBuffer.from(procedures.map(_.tempProc)), procedures.map(_.tempProc).head, initialMemory, readOnlyMemory) + val initialMemory = mutable.TreeMap[BigInt, MemorySection]() + val p = Program(ArrayBuffer.from(procedures.map(_.tempProc)), procedures.map(_.tempProc).head, initialMemory) procedures.foreach(_.resolve(p)) p diff --git a/src/main/scala/ir/eval/BitVectorEval.scala b/src/main/scala/ir/eval/BitVectorEval.scala index b3e426010..89cee4af0 100644 --- a/src/main/scala/ir/eval/BitVectorEval.scala +++ b/src/main/scala/ir/eval/BitVectorEval.scala @@ -1,7 +1,6 @@ package ir.eval - -import ir._ - +import ir.* +import scala.annotation.tailrec import scala.math.pow object BitVectorEval { @@ -24,6 +23,16 @@ object BitVectorEval { */ def bv2nat(b: BitVecLiteral): BigInt = b.value + /** + * Converts a bitvector value to its corresponding signed integer + */ + def bv2SignedInt(b: BitVecLiteral): BigInt = + if isNegative(b) then + b.value - BigInt(2).pow(b.size) + else + b.value + + /** (bvadd (_ BitVec m) (_ BitVec m) (_ BitVec m)) * - addition modulo 2^m * @@ -327,5 +336,4 @@ object BitVectorEval { smt_zero_extend(i, s) } } - } diff --git a/src/main/scala/ir/eval/ExprEval.scala b/src/main/scala/ir/eval/ExprEval.scala index b6f23ab16..45a90a671 100644 --- a/src/main/scala/ir/eval/ExprEval.scala +++ b/src/main/scala/ir/eval/ExprEval.scala @@ -271,11 +271,6 @@ def statePartialEvalExpr[S](l: Loader[S, InterpreterError])(exp: Expr): State[S, for { v: Option[Literal] <- l.getVariable(variable) } yield (v.getOrElse(variable)) - case ml: MemoryLoad => - for { - addr <- eval(ml.index) - mem <- l.loadMemory(ml.mem, addr, ml.endian, ml.size) - } yield (mem.getOrElse(ml)) case b: BitVecLiteral => State.pure(b) case b: IntLiteral => State.pure(b) case b: BoolLit => State.pure(b) diff --git a/src/main/scala/ir/eval/InterpretBasilIR.scala b/src/main/scala/ir/eval/InterpretBasilIR.scala index 98f1a9f25..2c0697e77 100644 --- a/src/main/scala/ir/eval/InterpretBasilIR.scala +++ b/src/main/scala/ir/eval/InterpretBasilIR.scala @@ -304,14 +304,22 @@ class BASILInterpreter[S](f: Effects[S, InterpreterError]) extends Interpreter[S def interpretStatement[S, T <: Effects[S, InterpreterError]](f: T)(s: Statement): State[S, Unit, InterpreterError] = { s match { - case assign: Assign => { + case assign: LocalAssign => { for { rhs <- Eval.evalBV(f)(assign.rhs) st <- f.storeVar(assign.lhs.name, assign.lhs.toBoogie.scope, Scalar(rhs)) n <- f.setNext(Run(s.successor)) } yield (st) } - case assign: MemoryAssign => + case assign: MemoryLoad => { + for { + index <- Eval.evalBV(f)(assign.index) + loaded <- Eval.loadBV(f)(assign.mem.name, Scalar(index), assign.endian, assign.size) + st <- f.storeVar(assign.lhs.name, assign.lhs.toBoogie.scope, Scalar(loaded)) + n <- f.setNext(Run(s.successor)) + } yield (st) + } + case assign: MemoryStore => for { index: BitVecLiteral <- Eval.evalBV(f)(assign.index) value: BitVecLiteral <- Eval.evalBV(f)(assign.value) @@ -460,7 +468,7 @@ object InterpFuns { } def initialiseProgram[S, T <: Effects[S, InterpreterError]](f: T)(p: Program): State[S, Unit, InterpreterError] = { - def initMemory(mem: String, mems: ArrayBuffer[MemorySection]) = { + def initMemory(mem: String, mems: Iterable[MemorySection]) = { for { m <- State.sequence( State.pure(()), @@ -493,10 +501,8 @@ object InterpFuns { ) ) _ <- State.pure(Logger.debug("INITIALISE MEMORY SECTIONS")) - mem <- initMemory("mem", p.initialMemory) - mem <- initMemory("stack", p.initialMemory) - mem <- initMemory("mem", p.readOnlyMemory) - mem <- initMemory("stack", p.readOnlyMemory) + mem <- initMemory("mem", p.initialMemory.values) + mem <- initMemory("stack", p.initialMemory.values) mainfun = { p.mainProcedure } diff --git a/src/main/scala/ir/eval/SimplifyExpr.scala b/src/main/scala/ir/eval/SimplifyExpr.scala index 0baf1abbb..22156ccc6 100644 --- a/src/main/scala/ir/eval/SimplifyExpr.scala +++ b/src/main/scala/ir/eval/SimplifyExpr.scala @@ -1110,7 +1110,7 @@ def simplifyExpr(e: Expr): (Expr, Boolean) = { case UnaryExpr(BoolNOT, UnaryExpr(BoolNOT, body)) => logSimp(e, body) // syntactic equality - case BinaryExpr(BVEQ, a, b) if a.loads.isEmpty && b.loads.isEmpty && a == b => logSimp(e, TrueLiteral) + case BinaryExpr(BVEQ, a, b) if a == b => logSimp(e, TrueLiteral) case BinaryExpr(BVADD, BinaryExpr(BVADD, y, UnaryExpr(BVNOT, x)), BitVecLiteral(1, _)) if !(y.isInstanceOf[BitVecLiteral]) => diff --git a/src/main/scala/ir/transforms/DynamicSingleAssignment.scala b/src/main/scala/ir/transforms/DynamicSingleAssignment.scala index c3483af19..9f33ac2d9 100644 --- a/src/main/scala/ir/transforms/DynamicSingleAssignment.scala +++ b/src/main/scala/ir/transforms/DynamicSingleAssignment.scala @@ -9,14 +9,15 @@ import analysis._ val phiAssignLabel = Some("phi") -/** This transforms the program by adding no-op copies and renaming local variable indices to establish the property that +/** This transforms the program by adding no-op copies and renaming local variable indices to establish the property + * that * * \forall variables v, forall uses of v : u, No subset of definitions of v defines the use u. */ class OnePassDSA( - /** Check our (faster) live var result against the TIP sovler solution - */ + /** Check our (faster) live var result against the TIP sovler solution + */ ) { val liveVarsDom = transforms.IntraLiveVarsDomain() @@ -44,7 +45,7 @@ class OnePassDSA( } } - def appendAssign(b: Block, s: Assign) = { + def appendAssign(b: Block, s: LocalAssign) = { // maintain call end of lock invariant if (b.statements.size > 0 && b.statements.last.isInstanceOf[Call]) { b.statements.insertBefore(b.statements.last, s) @@ -73,14 +74,8 @@ class OnePassDSA( for (s <- block.statements) { visit_stmt(StmtRenamer(Map(), renames.toMap), s) s match { - case a @ Assign(lhs: LocalVar, _, _) => { - count(lhs) = count(lhs) + 1 - renameLHS(a, lhs, count(lhs)) - renames = renames + (lhs -> count(lhs)) - - } - case d: DirectCall => { - val vars = d.outParams.map(_._2).toList + case d: Assign => { + val vars = d.assignees for (lhs <- vars) { count(lhs) = count(lhs) + 1 renameLHS(d, lhs, count(lhs)) @@ -141,7 +136,7 @@ class OnePassDSA( // if there is no renaming such that all the incoming renames agree // then we create a new copy case h :: tl => - tl.foldLeft(Some(h): Option[Int])((acc : Option[Int], rn: Int) => + tl.foldLeft(Some(h): Option[Int])((acc: Option[Int], rn: Int) => acc match { case Some(v) if v == rn => Some(v) case _ => None @@ -161,7 +156,7 @@ class OnePassDSA( assert(state(b).filled) state(nb).renamesBefore.addAll(state(b).renamesAfter) - val assign = Assign(v, v, Some("phiback")) + val assign = LocalAssign(v, v, Some("phiback")) state(nb).renamesAfter(v) = count(v) appendAssign(nb, assign) renameLHS(assign, v, state(nb).renamesAfter(v)) @@ -216,7 +211,7 @@ class OnePassDSA( state(nb).renamesAfter(v) = count(v) } if (state(nb).renamesBefore(v) != state(nb).renamesAfter(v)) { - val assign = Assign(v, v, phiAssignLabel) + val assign = LocalAssign(v, v, phiAssignLabel) appendAssign(nb, assign) renameLHS(assign, v, state(nb).renamesAfter(v)) renameRHS(assign, v, state(nb).renamesBefore(v)) @@ -238,19 +233,19 @@ class OnePassDSA( block: Block ) = { - /** VisitBlock: - * - * 1. for all complete incoming - * - if there is an incoming rename that is not equal across the predecessors - * - add back phi block to each incoming edge - * - create a fresh copy of each non-uniform renamed variable - * - add copies to each phi block unify the incoming rename with the nominated new rename 2. add local value - * numbering to this block 3. if all predecessors are filled, mark this complete, otherwise mark this - * filled. 4. for all successors - * - if marked filled, add phi block to unify our outgoing with its incoming - * - if > 1 total predecessors for each unmarked , add phi block to nominate a new copy 5. for all successors, if - * all predecessors are now filled, mark complete - */ + /** VisitBlock: + * + * 1. for all complete incoming + * - if there is an incoming rename that is not equal across the predecessors + * - add back phi block to each incoming edge + * - create a fresh copy of each non-uniform renamed variable + * - add copies to each phi block unify the incoming rename with the nominated new rename 2. add local value + * numbering to this block 3. if all predecessors are filled, mark this complete, otherwise mark this + * filled. 4. for all successors + * - if marked filled, add phi block to unify our outgoing with its incoming + * - if > 1 total predecessors for each unmarked , add phi block to nominate a new copy 5. for all successors, if + * all predecessors are now filled, mark complete + */ def state(b: Block) = withDefault(_st)(b) @@ -294,7 +289,6 @@ class OnePassDSA( liveAfter(b) = liveVarsDom.bot } - val worklist = mutable.PriorityQueue[Block]()(Ordering.by(b => b.rpoOrder)) worklist.addAll(p.blocks) var seen = Set[Block]() @@ -345,10 +339,10 @@ def rdDSAProperty(p: Procedure): Boolean = { * DSA Property: Every use of a variable v has every definition of v as a reaching definition * / no strict subset of defintions of v defines any use of v, forall v. */ - val defs: Map[Variable, Set[Assign | DirectCall]] = p + val defs: Map[Variable, Set[Assign]] = p .flatMap { - case a: Assign => Seq((a.lhs, (a: Assign | DirectCall))) - case a: DirectCall => a.outParams.map(_._2).map((l: Variable) => (l, (a: Assign | DirectCall))).toSeq + case a: SingleAssign => Seq((a.lhs, (a: Assign))) + case a: DirectCall => a.outParams.map(_._2).map((l: Variable) => (l, (a: Assign))).toSeq case _ => Seq() } .groupBy(_._1) @@ -359,8 +353,8 @@ def rdDSAProperty(p: Procedure): Boolean = { Logger.debug(s"Reaching defs ${p.name} DONE") class CheckDSAProperty( - defs: Map[Variable, Set[Assign | DirectCall]], - reaching: Map[Command, Map[Variable, Set[Assign | DirectCall]]] + defs: Map[Variable, Set[Assign]], + reaching: Map[Command, Map[Variable, Set[Assign]]] ) extends CILVisitor { var passed = true var stmt: Command = null @@ -412,7 +406,9 @@ object DSAPropCheck { def getUses(s: CFGPosition): Set[Variable] = { s match { - case a: Assign => a.rhs.variables + case a: LocalAssign => a.rhs.variables + case a: MemoryStore => a.index.variables ++ a.value.variables + case a: MemoryLoad => a.index.variables case a: DirectCall => a.actualParams.flatMap(_._2.variables).toSet case a: Return => a.outParams.flatMap(_._2.variables).toSet case a: IndirectCall => Set(a.target) @@ -424,9 +420,8 @@ object DSAPropCheck { def getDefinitions(s: CFGPosition): Set[Variable] = { s match { - case a: Assign => Set(a.lhs) - case a: DirectCall => a.outParams.map(_._2).toSet - case _ => Set() + case a: Assign => a.assignees + case _ => Set() } } diff --git a/src/main/scala/ir/transforms/IndirectCallResolution.scala b/src/main/scala/ir/transforms/IndirectCallResolution.scala index 15320319f..cbd3a4c57 100644 --- a/src/main/scala/ir/transforms/IndirectCallResolution.scala +++ b/src/main/scala/ir/transforms/IndirectCallResolution.scala @@ -1,96 +1,141 @@ package ir.transforms -import scala.collection.mutable.ListBuffer -import scala.collection.mutable.ArrayBuffer -import analysis.solvers.* -import analysis.* -import bap.* +import scala.collection.mutable +import scala.collection.mutable.{ArrayBuffer, ListBuffer} + +import analysis.{AddressValue, DataRegion, Lift, LiftedElement, LiteralValue, MemoryModelMap, MemoryRegion, RegisterWrapperEqualSets, StackRegion, Value, getUse} import ir.* -import translating.* import util.Logger -import util.intrusive_list.IntrusiveList -import scala.collection.mutable import cilvisitor.* -def resolveIndirectCallsUsingPointsTo( - pointsTos: Map[RegisterVariableWrapper, Set[RegisterVariableWrapper | MemoryRegion]], - regionContents: Map[MemoryRegion, Set[BitVecLiteral | MemoryRegion]], - reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])], - IRProgram: Program -): Boolean = { - var modified: Boolean = false - val worklist = ListBuffer[CFGPosition]() - - worklist.addAll(IRProgram) - - val visited = mutable.Set[CFGPosition]() - while (worklist.nonEmpty) { - val node = worklist.remove(0) - if (!visited.contains(node)) { - // add to worklist before we delete the node and can no longer find its successors - InterProcIRCursor.succ(node).foreach(node => worklist.addOne(node)) - process(node) - visited.add(node) - } - } - def searchRegion(region: MemoryRegion): mutable.Set[String] = { - val result = mutable.Set[String]() +class SteensgaardIndirectCallResolution( + override val program: Program, + val pointsTos: Map[RegisterWrapperEqualSets | MemoryRegion, Set[RegisterWrapperEqualSets | MemoryRegion]], + val reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])] +) extends IndirectCallResolution { + + private def searchRegion(region: MemoryRegion): Set[String] = { region match { case stackRegion: StackRegion => - if (regionContents.contains(stackRegion)) { - for (c <- regionContents(stackRegion)) { - c match { - case bitVecLiteral: BitVecLiteral => Logger.debug("hi: " + bitVecLiteral) //??? - case memoryRegion: MemoryRegion => - result.addAll(searchRegion(memoryRegion)) - } + if (pointsTos.contains(stackRegion)) { + pointsTos(stackRegion).flatMap { + case registerWrapperEqualSets: RegisterWrapperEqualSets => + pointsTos(registerWrapperEqualSets).flatMap { + case memoryRegion: MemoryRegion => + searchRegion(memoryRegion) + case registerWrapperEqualSets: RegisterWrapperEqualSets => + throw Exception(s"possibly recursive points-to relation? should I handle this? $registerWrapperEqualSets") + } + case memoryRegion: MemoryRegion => + //searchRegion(memoryRegion) + Set(memoryRegion.regionIdentifier) // TODO: fix me } + } else { + Set() } - result case dataRegion: DataRegion => - if (!regionContents.contains(dataRegion) || regionContents(dataRegion).isEmpty) { - result.add(dataRegion.regionIdentifier) + if (!pointsTos.contains(dataRegion) || pointsTos(dataRegion).isEmpty) { + Set(dataRegion.regionIdentifier) } else { - result.add(dataRegion.regionIdentifier) // TODO: may need to investigate if we should add the parent region - for (c <- regionContents(dataRegion)) { - c match { - case bitVecLiteral: BitVecLiteral => Logger.debug("hi: " + bitVecLiteral) //??? - case memoryRegion: MemoryRegion => - result.addAll(searchRegion(memoryRegion)) - } + val names: Set[String] = pointsTos(dataRegion).flatMap { + case registerWrapperEqualSets: RegisterWrapperEqualSets => + pointsTos(registerWrapperEqualSets).flatMap { + case memoryRegion: MemoryRegion => + searchRegion(memoryRegion) + case registerWrapperEqualSets: RegisterWrapperEqualSets => + throw Exception(s"possibly recursive points-to relation? should I handle this? $registerWrapperEqualSets") + } + case memoryRegion: MemoryRegion => + //searchRegion(memoryRegion)) + Set(memoryRegion.regionIdentifier) // TODO: fix me } + names + dataRegion.regionIdentifier // TODO: may need to investigate if we should add the parent region } - result } } - def addFakeProcedure(name: String): Procedure = { - val newProcedure = Procedure(name) - IRProgram.procedures += newProcedure - newProcedure - } - - def resolveAddresses(variable: Variable, i: IndirectCall): mutable.Set[String] = { - val names = mutable.Set[String]() - val variableWrapper = RegisterVariableWrapper(variable, getUse(variable, i, reachingDefs)) + override def resolveAddresses(variable: Variable, i: IndirectCall): Set[String] = { + val variableWrapper = RegisterWrapperEqualSets(variable, getUse(variable, i, reachingDefs)) pointsTos.get(variableWrapper) match { - case Some(value) => - value.map { - case v: RegisterVariableWrapper => names.addAll(resolveAddresses(v.variable, i)) - case m: MemoryRegion => names.addAll(searchRegion(m)) + case Some(values) => + values.flatMap { + case v: RegisterWrapperEqualSets => resolveAddresses(v.variable, i) + case m: MemoryRegion => searchRegion(m) } + case None => Set() + } + } + +} + +class VSAIndirectCallResolution( + override val program: Program, + val vsaResult: Map[CFGPosition, LiftedElement[Map[Variable | MemoryRegion, Set[Value]]]], + val mmm: MemoryModelMap +) extends IndirectCallResolution { + + private def searchRegion(memoryRegion: MemoryRegion, n: CFGPosition): Set[String] = { + val names = vsaResult.get(n) match { + case Some(Lift(el)) => el.get(memoryRegion) match { + case Some(values) => + values.flatMap { + case addressValue: AddressValue => searchRegion(addressValue.region, n) + case _ => Set() + } + case _ => Set() + } + case _ => Set() + } + memoryRegion match { + case _: StackRegion => names - case None => names + case dataRegion: DataRegion => + names ++ mmm.relfContent.getOrElse(dataRegion, Set()) + case _ => + Set() + } + } + + override def resolveAddresses(variable: Variable, i: IndirectCall): Set[String] = { + vsaResult.get(i) match { + case Some(Lift(el)) => el.get(variable) match { + case Some(values) => + values.flatMap { + case addressValue: AddressValue => searchRegion(addressValue.region, i) + case _: LiteralValue => Set() + } + case _ => Set() + } + case _ => Set() } } +} - def process(n: CFGPosition): Unit = n match { - case indirectCall: IndirectCall if indirectCall.target != Register("R30", 64) => - if (!indirectCall.hasParent) { - // skip if we have already processesd this call - return +trait IndirectCallResolution { + val program: Program + + def resolveIndirectCalls(): Boolean = { + var modified = false + val worklist = ListBuffer[CFGPosition]() + worklist.addAll(program) + + val visited = mutable.Set[CFGPosition]() + while (worklist.nonEmpty) { + val node = worklist.remove(0) + if (!visited.contains(node)) { + // add to worklist before we delete the node and can no longer find its successors + InterProcIRCursor.succ(node).foreach(node => worklist.addOne(node)) + modified = process(node) || modified + visited.add(node) } + } + modified + } + + // returns whether or not the program was modified + def process(n: CFGPosition): Boolean = n match { + case indirectCall: IndirectCall if indirectCall.target != Register("R30", 64) && indirectCall.hasParent => // we need the single-call-at-end-of-block invariant assert(indirectCall.parent.statements.lastOption.contains(indirectCall)) @@ -98,25 +143,22 @@ def resolveIndirectCallsUsingPointsTo( val procedure = block.parent val targetNames = resolveAddresses(indirectCall.target, indirectCall) - Logger.debug(s"Points-To approximated call ${indirectCall.target} with $targetNames") - Logger.debug(IRProgram.procedures) - val targets: mutable.Set[Procedure] = - targetNames.map(name => IRProgram.procedures.find(_.name == name).getOrElse(addFakeProcedure(name))) + Logger.debug(s"approximated call ${indirectCall.target} with $targetNames") + Logger.debug(program.procedures) + val targets: Set[Procedure] = + targetNames.map(name => program.procedures.find(_.name == name).getOrElse(addFakeProcedure(name))) - if (targets.size > 1) { + if (targets.nonEmpty) { Logger.debug(s"Resolved indirect call $indirectCall") } if (targets.size == 1) { - modified = true - val newCall = targets.head.makeCall(indirectCall.label) block.statements.replace(indirectCall, newCall) + true } else if (targets.size > 1) { val oft = indirectCall.parent.jump - - modified = true val newBlocks = ArrayBuffer[Block]() for (t <- targets) { Logger.debug(targets) @@ -131,9 +173,9 @@ def resolveIndirectCallsUsingPointsTo( /* copy the goto node resulting */ val fallthrough = oft match { - case g: GoTo => GoTo(g.targets, g.label) - case h: Unreachable => Unreachable() - case r: Return => Return() + case g: GoTo => GoTo(g.targets, g.label) + case _: Unreachable => Unreachable() + case _: Return => Return() } newBlocks.append(Block(newLabel, None, ArrayBuffer(assume, directCall), fallthrough)) } @@ -141,9 +183,20 @@ def resolveIndirectCallsUsingPointsTo( procedure.addBlocks(newBlocks) val newCall = GoTo(newBlocks, indirectCall.label) block.replaceJump(newCall) + true + } else { + false } case _ => + false } - modified + def addFakeProcedure(name: String): Procedure = { + val newProcedure = Procedure(name) + program.procedures += newProcedure + newProcedure + } + + def resolveAddresses(variable: Variable, i: IndirectCall): Set[String] + } diff --git a/src/main/scala/ir/transforms/ProcedureParameters.scala b/src/main/scala/ir/transforms/ProcedureParameters.scala index fa64f7c26..9c3e9958d 100644 --- a/src/main/scala/ir/transforms/ProcedureParameters.scala +++ b/src/main/scala/ir/transforms/ProcedureParameters.scala @@ -78,7 +78,7 @@ def clearParams(p: Program) = { def collectVariables(p: Procedure): (Set[Variable], Set[Variable]) = { val lvars = p.blocks.toSet.flatMap(_.statements.flatMap(s => { s match { - case Assign(l, _, _) => Set(l) + case LocalAssign(l, _, _) => Set(l) case DirectCall(t, o, _, _) => o.toSet.map(_._2) case _ => Set() } @@ -90,10 +90,11 @@ def collectVariables(p: Procedure): (Set[Variable], Set[Variable]) = { .flatten val rvars = p.blocks.toSet.flatMap(_.statements.flatMap(s => { s match { - case Assign(l, r, _) => r.variables + case LocalAssign(l, r, _) => r.variables case Assume(l, _, _, _) => l.variables case Assert(l, _, _) => l.variables - case MemoryAssign(m, i, v, _, _, _) => i.variables ++ v.variables + case MemoryStore(m, i, v, _, _, _) => i.variables ++ v.variables + case MemoryLoad(lhs, m, index, endian, size, label) => index.variables ++ Seq(lhs) case IndirectCall(l, _) => Set(l) case DirectCall(t, o, l, _) => l.toSet.flatMap(_._2.variables) case _ => Set() @@ -194,14 +195,18 @@ object ReadWriteAnalysis { def processProc(state: st, p: Procedure): RW = { p.foldLeft(state(p))((ir, s) => { s match { - case s: Assign => { + case s: LocalAssign => { ir.map(addWrites(Seq(s.lhs))) .map(addReads(s.rhs.variables)) } + case s: MemoryLoad => { + ir.map(addWrites(Seq(s.lhs))) + .map(addReads(s.index.variables)) + } case s: Return => { ir.map(addReads(s.outParams.flatMap(_._2.variables))) } - case s: MemoryAssign => { + case s: MemoryStore => { ir.map(addReads(s.index.variables ++ s.value.variables)) } case s: DirectCall => { @@ -306,7 +311,7 @@ class SetActualParams( override def vproc(p: Procedure) = { val incoming = - p.formalInParam.toList.flatMap(param => inBinding.get(p).flatMap(_.get(param)).map(p => Assign(p, param)).toList) + p.formalInParam.toList.flatMap(param => inBinding.get(p).flatMap(_.get(param)).map(p => LocalAssign(p, param)).toList) p.entryBlock.foreach(b => b.statements.prependAll(incoming)) DoChildren() } @@ -365,8 +370,8 @@ def specToProcForm( def toNameMapping(v: Map[LocalVar, Variable]): Map[String, String] = { v.map(v => (v._2.name, v._1.name)) ++ v.map(v => ("Gamma_" + v._2.name, "Gamma_" + v._1.name)) } - val varToInVar: Map[String, Map[String, String]] = mappingInparam.map(p => (p._1.name -> toNameMapping(p._2))) - val varToOutVar: Map[String, Map[String, String]] = mappingOutparam.map(p => (p._1.name -> toNameMapping(p._2))) + val varToInVar: Map[String, Map[String, String]] = mappingInparam.map(p => (p._1.procName -> toNameMapping(p._2))) + val varToOutVar: Map[String, Map[String, String]] = mappingOutparam.map(p => (p._1.procName -> toNameMapping(p._2))) def convVarToOld(varInPre: Map[String, String], varInPost: Map[String, String], isPost: Boolean = false)( b: BExpr diff --git a/src/main/scala/ir/transforms/Simp.scala b/src/main/scala/ir/transforms/Simp.scala index cd1f448ad..686f66f39 100644 --- a/src/main/scala/ir/transforms/Simp.scala +++ b/src/main/scala/ir/transforms/Simp.scala @@ -65,23 +65,23 @@ def basicReachingDefs(p: Procedure): Map[Command, Map[Variable, Set[Assign | Dir merged } -case class DefUse(defined: Map[Variable, Assign | DirectCall]) +case class DefUse(defined: Map[Variable, Assign]) // map v -> definitions reached here class DefUseDomain(liveBefore: Map[Block, Set[Variable]]) - extends AbstractDomain[Map[Variable, Set[Assign | DirectCall]]] { - // TODO: cull values using liveness + extends AbstractDomain[Map[Variable, Set[Assign]]] { - override def transfer(s: Map[Variable, Set[Assign | DirectCall]], b: Command) = { + override def transfer(s: Map[Variable, Set[Assign]], b: Command) = { b match { - case a: Assign => s.updated(a.lhs, Set(a)) - case d: DirectCall => d.outParams.map(_._2).foldLeft(s)((s, r) => s.updated(r, Set(d))) - case _ => s + case a: LocalAssign => s.updated(a.lhs, Set(a)) + case a: MemoryLoad => s.updated(a.lhs, Set(a)) + case d: DirectCall => d.outParams.map(_._2).foldLeft(s)((s, r) => s.updated(r, Set(d))) + case _ => s } } override def top = ??? - def bot = Map[Variable, Set[Assign | DirectCall]]() - def join(l: Map[Variable, Set[Assign | DirectCall]], r: Map[Variable, Set[Assign | DirectCall]], pos: Block) = { + def bot = Map[Variable, Set[Assign]]() + def join(l: Map[Variable, Set[Assign]], r: Map[Variable, Set[Assign]], pos: Block) = { l.keySet .union(r.keySet) .filter(k => liveBefore(pos).contains(k)) @@ -98,8 +98,9 @@ class IntraLiveVarsDomain extends PowerSetDomain[Variable] { def transfer(s: Set[Variable], a: Command): Set[Variable] = { a match { - case a: Assign => (s - a.lhs) ++ a.rhs.variables - case m: MemoryAssign => s ++ m.index.variables ++ m.value.variables + case a: LocalAssign => (s - a.lhs) ++ a.rhs.variables + case a: MemoryLoad => (s - a.lhs) ++ a.index.variables + case m: MemoryStore => s ++ m.index.variables ++ m.value.variables case a: Assume => s ++ a.body.variables case a: Assert => s ++ a.body.variables case i: IndirectCall => s + i.target @@ -107,6 +108,7 @@ class IntraLiveVarsDomain extends PowerSetDomain[Variable] { case g: GoTo => s case r: Return => s ++ r.outParams.flatMap(_._2.variables) case r: Unreachable => s + case n: NOP => s } } } @@ -123,10 +125,13 @@ def removeSlices(p: Procedure): Unit = { * We check this flow-insensitively and recover precision using DSA form. */ val assignments: Map[LocalVar, Iterable[Assign]] = p - .collect { case a: Assign => - a + .collect { + case a: SingleAssign => Seq(a.lhs -> a) + case a: DirectCall => a.assignees.map(e => e -> a) } - .groupBy(_.lhs) + .flatten + .groupBy(_._1) + .map((k,v) => (k, v.map(_._2).toSet)) .collect { case (k: LocalVar, v) => (k, v) } @@ -144,20 +149,24 @@ def removeSlices(p: Procedure): Unit = { // unify variable uses across direct assignments val ufsolver = analysis.solvers.UnionFindSolver[LVTerm]() val unioned = assignments.foreach { - case (lv, Assign(lhs: LocalVar, rhs: LocalVar, _)) => ufsolver.unify(LVTerm(lhs), LVTerm(rhs)) - case _ => () + case (lv, LocalAssign(lhs: LocalVar, rhs: LocalVar, _)) => ufsolver.unify(LVTerm(lhs), LVTerm(rhs)) + case _ => () } val unifiedAssignments = ufsolver .unifications() - .map { case (v: LVTerm, rvs) => - v.v -> (rvs.map { case LVTerm(rv) => - rv - }).toSet + .map { + case (v @ LVTerm(_), rvs) => + v.v -> (rvs.map { + case LVTerm(rv) => + rv + case _ => ??? /* unreachable */ + }).toSet + case _ => ??? /* unreachable */ } .map((repr: LocalVar, elems: Set[LocalVar]) => repr -> elems.flatMap(assignments(_).filter(_ match { // filter out the direct assignments we used to build the unif class - case Assign(lhs: LocalVar, rhs: LocalVar, _) if elems.contains(lhs) && elems.contains(rhs) => false + case LocalAssign(lhs: LocalVar, rhs: LocalVar, _) if elems.contains(lhs) && elems.contains(rhs) => false case _ => true })) ) @@ -165,10 +174,12 @@ def removeSlices(p: Procedure): Unit = { val varHighZeroBits: Map[LocalVar, HighZeroBits] = assignments.map((v, assigns) => // note: this overapproximates on x := y when x and y may both be smaller than their declared size val allRHSExtended = assigns.foldLeft(HighZeroBits.Bot: HighZeroBits)((e, assign) => - (e, assign.rhs) match { - case (HighZeroBits.Bot, ZeroExtend(i, lhs)) => HighZeroBits.Bits(i) - case (b @ HighZeroBits.Bits(ei), ZeroExtend(i, _)) if i == ei => b - case (b @ HighZeroBits.Bits(ei), ZeroExtend(i, _)) if i != ei => HighZeroBits.False + (e, assign) match { + case (HighZeroBits.Bot, LocalAssign(_, ZeroExtend(i, lhs), _)) => HighZeroBits.Bits(i) + case (b @ HighZeroBits.Bits(ei), LocalAssign(_, ZeroExtend(i, _), _)) if i == ei => b + case (b @ HighZeroBits.Bits(ei), LocalAssign(_, ZeroExtend(i, _), _)) if i != ei => HighZeroBits.False + case (b @ HighZeroBits.Bits(ei), m: MemoryLoad) => HighZeroBits.False + case (b @ HighZeroBits.Bits(ei), m: DirectCall) => HighZeroBits.False case (HighZeroBits.False, _) => HighZeroBits.False case (_, other) => HighZeroBits.False } @@ -180,6 +191,7 @@ def removeSlices(p: Procedure): Unit = { // map all lhs to the result for their representative val rep = ufsolver.find(LVTerm(lhs)) match { case LVTerm(r) => r + case _ => ??? /* unreachable */ } lhs -> varHighZeroBits.get(rep) }) @@ -222,7 +234,7 @@ def removeSlices(p: Procedure): Unit = { } override def vstmt(s: Statement) = { s match { - case a @ Assign(lhs: LocalVar, ZeroExtend(sz, rhs), _) + case a @ LocalAssign(lhs: LocalVar, ZeroExtend(sz, rhs), _) if size(lhs).isDefined && varHighZeroBits.contains(lhs) => { assert(varHighZeroBits(lhs) == sz) a.lhs = LocalVar(lhs.name, BitVecType(size(lhs).get - varHighZeroBits(lhs))) @@ -262,13 +274,19 @@ def getRedundantAssignments(procedure: Procedure): Set[Assign] = { for (c <- procedure) { c match { - case a: Assign => { + case a: LocalAssign => { assignedNotRead(a.lhs) = joinVS(assignedNotRead(a.lhs), VS.Assigned(Set(a))) a.rhs.variables.foreach(v => { assignedNotRead(v) = joinVS(assignedNotRead(v), VS.Read(Set(), Set(a))) }) } - case m: MemoryAssign => { + case a: MemoryLoad => { + assignedNotRead(a.lhs) = joinVS(assignedNotRead(a.lhs), VS.Assigned(Set(a))) + a.index.variables.foreach(v => { + assignedNotRead(v) = joinVS(assignedNotRead(v), VS.Read(Set(), Set(a))) + }) + } + case m: MemoryStore => { m.index.variables.foreach(v => { assignedNotRead(v) = joinVS(assignedNotRead(v), VS.Read(Set(), Set(m))) }) @@ -326,7 +344,7 @@ def getRedundantAssignments(procedure: Procedure): Set[Assign] = { class CleanupAssignments() extends CILVisitor { var redundantAssignments = Set[Assign]() - def isRedundant(a: Assign) = { + def isRedundant(a: LocalAssign) = { a.lhs == a.rhs || redundantAssignments.contains(a) } @@ -336,7 +354,7 @@ class CleanupAssignments() extends CILVisitor { } override def vstmt(s: Statement) = s match { - case a: Assign if isRedundant(a) => ChangeTo(List()) + case a: LocalAssign if isRedundant(a) => ChangeTo(List()) case _ => SkipChildren() } @@ -493,19 +511,18 @@ def doCopyPropTransform(p: Program) = { } - -def reversePostOrder(p: Procedure) : Unit = { +def reversePostOrder(p: Procedure): Unit = { /* Procedures may contain disconnected sets of blocks so we arbitrarily order these with respect to eachother. */ for (b <- p.blocks) { b.rpoOrder = -1 } var left = p.entryBlock.map(reversePostOrder(_)).getOrElse(0) + 1 for (b <- p.blocks.filter(_.rpoOrder == -1)) { - left = reversePostOrder(b, true, left) + 1 + left = reversePostOrder(b, true, left) + 1 } } -def reversePostOrder(startBlock: Block, fixup: Boolean = false, begin : Int = 0): Int = { +def reversePostOrder(startBlock: Block, fixup: Boolean = false, begin: Int = 0): Int = { var count = begin val seen = mutable.HashSet[Block]() val vcs = mutable.HashMap[Block, Int]() @@ -578,7 +595,6 @@ object CopyProp { val (beforeLive, afterLive) = getLiveVars(p) val dom = DefUseDomain(beforeLive) val solver = worklistSolver(dom) - // type rtype = Map[Block, Map[Variable, Set[Assign | DirectCall]]] val (beforeRes, afterRes) = solver.solveProc(p) } @@ -612,15 +628,15 @@ object CopyProp { def transfer(s: Statement) = { s match { - case a: Assign if a.rhs.loads.size > 0 => clobberFull(state, a.lhs) - case a: Assign if !state.contains(a.lhs) && flagDeps.contains(a.lhs) => { + case a: MemoryLoad => clobberFull(state, a.lhs) + case a: LocalAssign if !state.contains(a.lhs) && flagDeps.contains(a.lhs) => { val r = canPropTo(state, a.rhs, true).get state(a.lhs) = PropState(r, mutable.Set.from(r.variables), false, 0, true) } - case a: Assign if state.contains(a.lhs) && state(a.lhs).clobbered => { + case a: LocalAssign if state.contains(a.lhs) && state(a.lhs).clobbered => { () } - case a: Assign + case a: LocalAssign if state.contains(a.lhs) && (a.rhs != state(a.lhs).e) && (canPropTo(state, a.rhs, true) != canPropTo( state, state(a.lhs).e, @@ -628,7 +644,7 @@ object CopyProp { )) => { clobberFull(state, a.lhs) } - case a: Assign if state.contains(a.lhs) => { + case a: LocalAssign if state.contains(a.lhs) => { state(a.lhs) = state(a.lhs).copy(e = canPropTo(state, a.rhs, true).get) } case i: IndirectCall => { @@ -661,12 +677,6 @@ object CopyProp { } } - def clobberDeps(c: mutable.HashMap[Variable, PropState], l: Variable): Unit = { - val toclobber = c.filter(_.isInstanceOf[CopyProp.Prop]).filter(_.asInstanceOf[CopyProp.Prop].deps.contains(l)) - for ((v, e) <- toclobber) { - c(v).clobbered = true - } - } def isTrivial(e: Expr): Boolean = e match { case l: Literal => true @@ -727,43 +737,38 @@ object CopyProp { def transfer(c: mutable.HashMap[Variable, PropState], s: Statement): Unit = { // val callClobbers = ((0 to 7) ++ (19 to 30)).map("R" + _).map(c => Register(c, 64)) s match { - case Assign(l, r, lb) => { - if (r.loads.size > 0) { - // c.copy(state = c.state + (l -> CopyProp.Clobbered)) - clobberFull(c, l) - } else { - - val isFlag = isFlagVar(l) || r.variables.exists(isFlagVar) - val isFlagDep = isFlag || c.get(l).map(v => v.isFlagDep).getOrElse(false) - + case l: MemoryLoad => + clobberFull(c, l.lhs) + case LocalAssign(l, r, lb) => { + val isFlag = isFlagVar(l) || r.variables.exists(isFlagVar) + val isFlagDep = isFlag || c.get(l).map(v => v.isFlagDep).getOrElse(false) + + c.get(l).foreach(v => v.isFlagDep = v.isFlagDep || isFlagDep) + for (l <- r.variables) { c.get(l).foreach(v => v.isFlagDep = v.isFlagDep || isFlagDep) - for (l <- r.variables) { - c.get(l).foreach(v => v.isFlagDep = v.isFlagDep || isFlagDep) - } + } - var prop = canPropTo(c, r, isFlagDep) - val existing = c.get(l) + var prop = canPropTo(c, r, isFlagDep) + val existing = c.get(l) - (prop, existing) match { - case (Some(evaled), None) => { - c(l) = PropState(evaled, mutable.Set.from(evaled.variables), false, 0, isFlagDep) - } - case (_, Some(ps)) if ps.clobbered => { - () - } - case (Some(evaled), Some(ps)) - if ps.e == r || ps.e == evaled || (canPropTo(c, ps.e, isFlagDep).contains(evaled)) => { - c(l) = c(l).copy(e = evaled) - } - case (Some(evaled), Some(ps)) => { - clobberFull(c, l) - } - case _ => { - // ps.e != evaled and have prop - clobberFull(c, l) - } + (prop, existing) match { + case (Some(evaled), None) => { + c(l) = PropState(evaled, mutable.Set.from(evaled.variables), false, 0, isFlagDep) + } + case (_, Some(ps)) if ps.clobbered => { + () + } + case (Some(evaled), Some(ps)) + if ps.e == r || ps.e == evaled || (canPropTo(c, ps.e, isFlagDep).contains(evaled)) => { + c(l) = c(l).copy(e = evaled) + } + case (Some(evaled), Some(ps)) => { + clobberFull(c, l) + } + case _ => { + // ps.e != evaled and have prop + clobberFull(c, l) } - } } case x: DirectCall => { @@ -809,77 +814,6 @@ object CopyProp { } -class ConstCopyProp() extends AbstractDomain[CCP] { - private final val callClobbers = ((0 to 7) ++ (19 to 30)).map("R" + _).map(c => Register(c, 64)) - - def top: CCP = CCP(Map().withDefaultValue(CopyProp.Clobbered)) - def bot: CCP = CCP(Map().withDefaultValue(CopyProp.Bot)) - - override def join(l: CCP, r: CCP, pos: Block): CCP = { - // val ks = l.state.keySet.intersect(r.state.keySet) - val ks = l.state.keySet ++ (r.state.keySet) - - val merged = ks.map(v => - (v -> - ((l.state.get(v).getOrElse(CopyProp.Clobbered), r.state.get(v).getOrElse(CopyProp.Clobbered)) match { - case (l, CopyProp.Bot) => l - case (CopyProp.Bot, r) => r - case (c @ CopyProp.Clobbered, _) => c - case (_, c @ CopyProp.Clobbered) => c - case (p1 @ CopyProp.Prop(e1, deps1), p2 @ CopyProp.Prop(e2, deps2)) if (p1 == p2) => p1 - case (_, _) => CopyProp.Clobbered - })) - ) - CCP(merged.toMap) - } - - override def transfer(c: CCP, s: Command): CCP = { - s match { - case Assign(l, r, lb) => { - if (r.loads.size > 0) { - CCP.clobberFull(c, l) - } else { - val evaled = ir.eval.partialEvalExpr( - Substitute( - v => { - c.state.get(v) match { - case Some(CopyProp.Prop(c, deps)) if deps.isEmpty => Some(c) - case _ => None - } - }, - false - )(r).getOrElse(r), - e => None - ) - val rhsDeps = evaled.variables.toSet - val existing = c.state.get(l).getOrElse(CopyProp.Bot) - - existing match { - case CopyProp.Bot => { - c.copy(state = c.state + (l -> CopyProp.Prop(evaled, rhsDeps))) // not seen yet - } - case CopyProp.Prop(e, _) => { - val p = CCP.clobber(c, l) - p.copy(state = p.state + (l -> CopyProp.Prop(evaled, rhsDeps))) // not seen yet - } - case _ => { - CCP.clobberFull(c, l) - } - } - } - } - case x: DirectCall => { - val lhs = x.outParams.map(_._2) - lhs.foldLeft(c)(CCP.clobberFull) - } - case x: IndirectCall => { - val toClob = callClobbers - toClob.foldLeft(c)(CCP.clobberFull) - } - case _ => c - } - } -} class ExprComplexity extends CILVisitor { // count the nodes in the expression AST @@ -902,15 +836,15 @@ class ExprComplexity extends CILVisitor { } } -/** - * Use this as a partially applied function. - * Substitute(Map.from(substs).get, recurse = false) - * - * @res: defines the substitutions to make - * @recurse: continue substituting with `res` into each substituted expression - * @complexityThreshold: Stop substituting after the AST node count has increased by this much - * - */ +/** Use this as a partially applied function. Substitute(Map.from(substs).get, recurse = false) + * + * @res: + * defines the substitutions to make + * @recurse: + * continue substituting with `res` into each substituted expression + * @complexityThreshold: + * Stop substituting after the AST node count has increased by this much + */ class Substitute( val res: Variable => Option[Expr], val recurse: Boolean = true, @@ -957,7 +891,6 @@ class Substitute( class Simplify( val res: Variable => Option[Expr], val initialBlock: Block = null, - val absdom: Option[ConstCopyProp] = None /* flow sensitive */ ) extends CILVisitor { var madeAnyChange = false diff --git a/src/main/scala/ir/transforms/SplitThreads.scala b/src/main/scala/ir/transforms/SplitThreads.scala index 8678720e7..8123c0ae1 100644 --- a/src/main/scala/ir/transforms/SplitThreads.scala +++ b/src/main/scala/ir/transforms/SplitThreads.scala @@ -1,65 +1,46 @@ package ir.transforms -import scala.collection.mutable.ListBuffer -import scala.collection.mutable.ArrayBuffer -import analysis.solvers.* -import analysis.* -import bap.* +import analysis.{DataRegion, MemoryRegion, RegisterWrapperEqualSets, getDefinition} import ir.* -import translating.* -import util.Logger -import java.util.Base64 -import spray.json.DefaultJsonProtocol.* -import util.intrusive_list.IntrusiveList + import scala.collection.mutable -import cilvisitor._ -// identify calls to pthread_create -// use analysis result to determine the third parameter's value (the function pointer) -// split off that procedure into new thread -// do reachability analysis -// also need a bit in the IR where it creates separate files + def splitThreads(program: Program, - pointsTo: Map[RegisterVariableWrapper, Set[RegisterVariableWrapper | MemoryRegion]], - regionContents: Map[MemoryRegion, Set[BitVecLiteral | MemoryRegion]], + pointsTo: Map[RegisterWrapperEqualSets, Set[RegisterWrapperEqualSets | MemoryRegion]], reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])] ): Unit = { - // iterate over all commands - if call is to pthread_create, look up? - program.foreach(c => - c match { - case d: DirectCall if d.target.name == "pthread_create" => - - // R2 should hold the function pointer of the function that begins the thread - // look up R2 value using points to results - val R2 = Register("R2", 64) - val b = reachingDefs(d) - val R2Wrapper = RegisterVariableWrapper(R2, getDefinition(R2, d, reachingDefs)) - val threadTargets = pointsTo(R2Wrapper) - - if (threadTargets.size > 1) { - // currently can't handle case where the thread created is ambiguous - throw Exception("can't handle thread creation with more than one possible target") - } + // iterate over all commands - if call is to pthread_create, look up + program.foreach { + case d: DirectCall if d.target.name == "pthread_create" => + // R2 should hold the function pointer of the function that begins the thread + // look up R2 value using points to results + val R2 = Register("R2", 64) + val R2Wrapper = RegisterWrapperEqualSets(R2, getDefinition(R2, d, reachingDefs)) + val threadTargets = pointsTo(R2Wrapper) - if (threadTargets.size == 1) { + if (threadTargets.size > 1) { + // currently can't handle case where the thread created is ambiguous + throw Exception("can't handle thread creation with more than one possible target") + } - // not trying to untangle the very messy region resolution at present, just dealing with simplest case - threadTargets.head match { - case data: DataRegion => - val threadEntrance = program.procedures.find(_.name == data.regionIdentifier) match { - case Some(proc) => proc - case None => throw Exception("could not find procedure with name " + data.regionIdentifier) - } - val thread = ProgramThread(threadEntrance, mutable.LinkedHashSet(threadEntrance), Some(d)) - program.threads.addOne(thread) - case _ => - throw Exception("unexpected non-data region " + threadTargets.head + " as PointsTo result for R2 at " + d) - } + if (threadTargets.size == 1) { + // not trying to untangle the very messy region resolution at present, just dealing with simplest case + threadTargets.head match { + case data: DataRegion => + val threadEntrance = program.procedures.find(_.name == data.regionIdentifier) match { + case Some(proc) => proc + case None => throw Exception("could not find procedure with name " + data.regionIdentifier) + } + val thread = ProgramThread(threadEntrance, mutable.LinkedHashSet(threadEntrance), Some(d)) + program.threads.addOne(thread) + case _ => + throw Exception("unexpected non-data region " + threadTargets.head + " as PointsTo result for R2 at " + d) } - case _ => - }) - + } + case _ => + } if (program.threads.nonEmpty) { val mainThread = ProgramThread(program.mainProcedure, mutable.LinkedHashSet(program.mainProcedure), None) diff --git a/src/main/scala/specification/Specification.scala b/src/main/scala/specification/Specification.scala index 127bb528f..0674682a2 100644 --- a/src/main/scala/specification/Specification.scala +++ b/src/main/scala/specification/Specification.scala @@ -1,10 +1,12 @@ package specification -import boogie._ -import ir._ +import boogie.* +import ir.* import util.Logger + case class Specification( + funcs: Set[FuncEntry], globals: Set[SpecGlobal], LPreds: Map[SpecGlobal, BExpr], relies: List[BExpr], @@ -12,15 +14,20 @@ case class Specification( subroutines: List[SubroutineSpec], directFunctions: Set[FunctionOp] ) { - val guaranteeOldVars: List[SpecGlobalOrAccess] = guarantees.flatMap(g => g.oldSpecGlobals) - val controls: Map[SpecGlobalOrAccess, Set[SpecGlobal]] = { val controlledBy = LPreds.map((k, v) => k -> v.specGlobals).collect { case (k, v) if v.nonEmpty => (k, v) } - controlledBy.toSet.flatMap((k, v) => v.map(_ -> k)).groupMap(_._1)(_._2) + controlledBy.toSet.flatMap((k, v) => v.map(_ -> k)).groupMap(_(0))(_(1)) } val controlled: Set[SpecGlobal] = controls.values.flatten.toSet } + +trait SymbolTableEntry{ + val name: String + val size: Int + val address: BigInt +} + case class SubroutineSpec( name: String, requires: List[BExpr], diff --git a/src/main/scala/translating/BAPToIR.scala b/src/main/scala/translating/BAPToIR.scala index dc54426b1..1d2750f6b 100644 --- a/src/main/scala/translating/BAPToIR.scala +++ b/src/main/scala/translating/BAPToIR.scala @@ -10,6 +10,7 @@ import scala.collection.mutable import scala.collection.immutable import scala.collection.mutable.Map import scala.collection.mutable.ArrayBuffer +import scala.collection.mutable.TreeMap import util.intrusive_list.* class BAPToIR(var program: BAPProgram, mainAddress: BigInt) { @@ -17,6 +18,8 @@ class BAPToIR(var program: BAPProgram, mainAddress: BigInt) { private val nameToProcedure: mutable.Map[String, Procedure] = mutable.Map() private val labelToBlock: mutable.Map[String, Block] = mutable.Map() + private var loadCounter: Int = 0 + def translate: Program = { var mainProcedure: Option[Procedure] = None val procedures: ArrayBuffer[Procedure] = ArrayBuffer() @@ -30,10 +33,10 @@ class BAPToIR(var program: BAPProgram, mainAddress: BigInt) { } labelToBlock.addOne(b.label, block) } - procedure.formalInParam = mutable.SortedSet.from(s.in.map(_.toIR)) - procedure.formalOutParam = mutable.SortedSet.from(s.out.filterNot(_.name.endsWith("_result")).map(_.toIR)) - procedure.inParamDefaultBinding = immutable.SortedMap.from(s.in.map(s => s.toIR -> s.paramRegisterRVal)) - procedure.outParamDefaultBinding = immutable.SortedMap.from(s.out.filterNot(_.name.endsWith("_result")).map(s => s.toIR -> s.paramRegisterLVal)) + procedure.formalInParam = mutable.SortedSet.from(s.in.map(translateParam)) + procedure.formalOutParam = mutable.SortedSet.from(s.out.filterNot(_.name.endsWith("_result")).map(translateParam)) + procedure.inParamDefaultBinding = immutable.SortedMap.from(s.in.map(s => translateParam(s)-> paramRegisterRVal(s))) + procedure.outParamDefaultBinding = immutable.SortedMap.from(s.out.filterNot(_.name.endsWith("_result")).map(s => translateParam(s) -> paramRegisterLVal(s))) if (s.address.get == mainAddress) { mainProcedure = Some(procedure) @@ -47,7 +50,10 @@ class BAPToIR(var program: BAPProgram, mainAddress: BigInt) { for (b <- s.blocks) { val block = labelToBlock(b.label) for (st <- b.statements) { - block.statements.append(translate(st)) + val statements = translateStatement(st) + for (s <- statements) { + block.statements.append(s) + } } val (call, jump, newBlocks) = translate(b.jumps, block) procedure.addBlocks(newBlocks) @@ -63,10 +69,15 @@ class BAPToIR(var program: BAPProgram, mainAddress: BigInt) { } - val memorySections: ArrayBuffer[MemorySection] = ArrayBuffer() + val memorySections: mutable.TreeMap[BigInt, MemorySection] = mutable.TreeMap() for (m <- program.memorySections) { - val bytes = m.bytes.map(_.toIR) - memorySections.append(MemorySection(m.name, m.address, m.size, bytes)) + val bytes = if (m.name == ".bss" && m.bytes.isEmpty) { + for (_ <- 0 until m.size) yield BitVecLiteral(0, 8) + } else { + m.bytes.map(translateLiteral) + } + val readOnly = m.name == ".rodata" || m.name == ".got" // crude heuristic + memorySections.addOne(m.address, MemorySection(m.name, m.address, m.size, bytes, readOnly, None)) } class FixCallParams(subroutines: immutable.Map[String, BAPSubroutine]) extends CILVisitor { @@ -85,21 +96,198 @@ class BAPToIR(var program: BAPProgram, mainAddress: BigInt) { } } - var prog = Program(procedures, mainProcedure.get, memorySections, ArrayBuffer()) + var prog = Program(procedures, mainProcedure.get, memorySections) visit_prog(FixCallParams(program.subroutines.map(s => s.name -> s).toMap), prog) + prog } - private def translate(s: BAPStatement) = s match { + private def translateStatement(s: BAPStatement): Seq[Statement] = s match { case b: BAPMemAssign => - val mem = b.lhs.toIRMemory - if (mem != b.rhs.memory.toIRMemory) { + val mem = translateMemory(b.lhs) + if (mem != translateMemory(b.rhs.memory)) { throw Exception(s"$b has conflicting lhs ${b.lhs} and rhs ${b.rhs.memory}") } - MemoryAssign(mem, b.rhs.index.toIR, b.rhs.value.toIR, b.rhs.endian, b.rhs.size, Some(b.line)) + Seq(MemoryStore(mem, translateExprOnly(b.rhs.index), translateExprOnly(b.rhs.value), b.rhs.endian, b.rhs.size, Some(b.line))) case b: BAPLocalAssign => - Assign(b.lhs.toIR, b.rhs.toIR, Some(b.line)) + val lhs = translateVar(b.lhs) + val (rhs, load) = translateExpr(b.rhs) + if (load.isDefined) { + val loadWithLabel = MemoryLoad(load.get.lhs, load.get.mem, load.get.index, load.get.endian, load.get.size, Some(b.line + "$0")) + val assign = LocalAssign(lhs, rhs, Some(b.line + "$1")) + Seq(loadWithLabel, assign) + } else { + val assign = LocalAssign(lhs, rhs, Some(b.line)) + Seq(assign) + } + } + + private def translateExpr(e: BAPExpr): (Expr, Option[MemoryLoad]) = e match { + case b @ BAPConcat(left, right) => + val (arg0, load0) = translateExpr(left) + val (arg1, load1) = translateExpr(right) + (load0, load1) match { + case (Some(load), None) => (BinaryExpr(BVCONCAT, arg0, arg1), Some(load)) + case (None, Some(load)) => (BinaryExpr(BVCONCAT, arg0, arg1), Some(load)) + case (None, None) => (BinaryExpr(BVCONCAT, arg0, arg1), None) + case (Some(_), Some(_)) => throw Exception(s"$b contains multiple loads") + } + case BAPSignedExtend(width, body) => + if (width > body.size) { + val (irBody, load) = translateExpr(body) + val se = SignExtend(width - body.size, irBody) + (se, load) + } else { + translateExpr(BAPExtract(width - 1, 0, body)) + } + case BAPUnsignedExtend(width, body) => + if (width > body.size) { + val (irBody, load) = translateExpr(body) + val ze = ZeroExtend(width - body.size, irBody) + (ze, load) + } else { + translateExpr(BAPExtract(width - 1, 0, body)) + } + case b @ BAPExtract(high, low, body) => + val bodySize = body.size + val (irBody, load) = translateExpr(body) + val extract = if (b.size > bodySize) { + if (low == 0) { + ZeroExtend(b.size - bodySize, irBody) + } else { + Extract(high + 1, low, ZeroExtend(b.size - bodySize, irBody)) + } + } else { + Extract(high + 1, low, irBody) + } + (extract, load) + case literal: BAPLiteral => (translateLiteral(literal), None) + case BAPUnOp(operator, exp) => operator match { + case NOT => (UnaryExpr(BVNOT, translateExprOnly(exp)), None) + case NEG => (UnaryExpr(BVNEG, translateExprOnly(exp)), None) + } + case BAPBinOp(operator, lhs, rhs) => operator match { + case PLUS => (BinaryExpr(BVADD, translateExprOnly(lhs), translateExprOnly(rhs)), None) + case MINUS => (BinaryExpr(BVSUB, translateExprOnly(lhs), translateExprOnly(rhs)), None) + case TIMES => (BinaryExpr(BVMUL, translateExprOnly(lhs), translateExprOnly(rhs)), None) + case DIVIDE => (BinaryExpr(BVUDIV, translateExprOnly(lhs), translateExprOnly(rhs)), None) + case SDIVIDE => (BinaryExpr(BVSDIV, translateExprOnly(lhs), translateExprOnly(rhs)), None) + // counterintuitive but correct according to BAP source + case MOD => (BinaryExpr(BVSREM, translateExprOnly(lhs), translateExprOnly(rhs)), None) + // counterintuitive but correct according to BAP source + case SMOD => (BinaryExpr(BVUREM, translateExprOnly(lhs), translateExprOnly(rhs)), None) + case LSHIFT => // BAP says caring about this case is necessary? + if (lhs.size == rhs.size) { + (BinaryExpr(BVSHL, translateExprOnly(lhs), translateExprOnly(rhs)), None) + } else { + (BinaryExpr(BVSHL, translateExprOnly(lhs), ZeroExtend(lhs.size - rhs.size, translateExprOnly(rhs))), None) + } + case RSHIFT => + if (lhs.size == rhs.size) { + (BinaryExpr(BVLSHR, translateExprOnly(lhs), translateExprOnly(rhs)), None) + } else { + (BinaryExpr(BVLSHR, translateExprOnly(lhs), ZeroExtend(lhs.size - rhs.size, translateExprOnly(rhs))), None) + } + case ARSHIFT => + if (lhs.size == rhs.size) { + (BinaryExpr(BVASHR, translateExprOnly(lhs), translateExprOnly(rhs)), None) + } else { + (BinaryExpr(BVASHR, translateExprOnly(lhs), ZeroExtend(lhs.size - rhs.size, translateExprOnly(rhs))), None) + } + case AND => (BinaryExpr(BVAND, translateExprOnly(lhs), translateExprOnly(rhs)), None) + case OR => (BinaryExpr(BVOR, translateExprOnly(lhs), translateExprOnly(rhs)), None) + case XOR => (BinaryExpr(BVXOR, translateExprOnly(lhs), translateExprOnly(rhs)), None) + case EQ => (BinaryExpr(BVCOMP, translateExprOnly(lhs), translateExprOnly(rhs)), None) + case NEQ => (UnaryExpr(BVNOT, BinaryExpr(BVCOMP, translateExprOnly(lhs), translateExprOnly(rhs))), None) + case LT => (BinaryExpr(BVULT, translateExprOnly(lhs), translateExprOnly(rhs)), None) + case LE => (BinaryExpr(BVULE, translateExprOnly(lhs), translateExprOnly(rhs)), None) + case SLT => (BinaryExpr(BVSLT, translateExprOnly(lhs), translateExprOnly(rhs)), None) + case SLE => (BinaryExpr(BVSLE, translateExprOnly(lhs), translateExprOnly(rhs)), None) + } + case b: BAPVar => (translateVar(b), None) + case BAPMemAccess(memory, index, endian, size) => + val temp = LocalVar("load" + loadCounter, BitVecType(size)) + loadCounter += 1 + val load = MemoryLoad(temp, translateMemory(memory), translateExprOnly(index), endian, size, None) + (temp, Some(load)) + } + + private def translateExprOnly(e: BAPExpr) = { + val (expr, load) = translateExpr(e) + if (load.isDefined) { + throw Exception(s"unexpected load in $e") + } + expr } + private def paramRegisterLVal(param: BAPParameter): Variable = translateVar(param.value) + private def toIROutParam(param: BAPParameter) = { + paramRegisterLVal(param) match { + case r: Register => { + if (r.size == param.size) then { + translateParam(param) + } else { + LocalVar(param.name, BitVecType(r.size)) + } + } + case _ => throw Exception(s"subroutine parameter $this refers to non-register variable ${param.value}") + } + + } + + private def paramRegisterRVal(p: BAPParameter): Expr = { + paramRegisterLVal(p) match { + case r: Register => { + if (r.size == p.size) then { + r + } else if (r.size > p.size){ + Extract(p.size, 0, r) + } else { + ZeroExtend(p.size - r.size, r) + } + } + case _ => throw Exception(s"subroutine parameter $this refers to non-register variable ${p.value}") + } + } + def paramVariableRVal(p: BAPParameter): Expr = { + paramRegisterLVal(p) match { + case r: Register => { + if (r.size == p.size) then { + translateParam(p) + } else { + ZeroExtend(r.size - p.size, translateParam(p)) + } + } + case _ => throw Exception(s"subroutine parameter $this refers to non-register variable ${p.value}") + } + } + + def toAssignOut(p: BAPParameter) : LocalAssign = { + LocalAssign(translateParam(p), paramRegisterRVal(p)) + } + + def toAssignIn(p: BAPParameter) : LocalAssign = { + LocalAssign(paramRegisterLVal(p), paramVariableRVal(p)) + } + + def translateParam(p: BAPParameter): LocalVar = LocalVar(p.name, BitVecType(p.size)) + + private def translateVar(variable: BAPVar): Variable = variable match { + case BAPRegister(name, size) => Register(name, size) + case BAPLocalVar(name, size) => LocalVar(name, BitVecType(size)) + } + + private def translateMemory(memory: BAPMemory): Memory = { + SharedMemory(memory.name, memory.addressSize, memory.valueSize) + } + + + + + private def translateLiteral(literal: BAPLiteral) = { + BitVecLiteral(literal.value, literal.size) + } + + /** * Translates a list of jumps from BAP into a single Jump at the IR level by moving any conditions on jumps to * Assume statements in new blocks @@ -124,7 +312,9 @@ class BAPToIR(var program: BAPProgram, mainAddress: BigInt) { // condition is true and previous conditions existing means this condition // is actually that all previous conditions are false val conditionsIR = conditions.map(c => convertConditionBool(c, true)) - val condition = conditionsIR.tail.foldLeft(conditionsIR.head)((ands: Expr, next: Expr) => BinaryExpr(BoolAND, next, ands)) + val condition = conditionsIR.tail.foldLeft(conditionsIR.head) { + (ands: Expr, next: Expr) => BinaryExpr(BoolAND, next, ands) + } val newBlock = newBlockCondition(block, target, condition) newBlocks.append(newBlock) targets.append(newBlock) @@ -139,7 +329,9 @@ class BAPToIR(var program: BAPProgram, mainAddress: BigInt) { // if this is not the first condition, then we need to need to add // that all previous conditions are false val conditionsIR = conditions.map(c => convertConditionBool(c, true)) - conditionsIR.tail.foldLeft(currentCondition)((ands: Expr, next: Expr) => BinaryExpr(BoolAND, next, ands)) + conditionsIR.tail.foldLeft(currentCondition) { + (ands: Expr, next: Expr) => BinaryExpr(BoolAND, next, ands) + } } val newBlock = newBlockCondition(block, target, condition) newBlocks.append(newBlock) @@ -154,11 +346,11 @@ class BAPToIR(var program: BAPProgram, mainAddress: BigInt) { jumps.head match { case b: BAPDirectCall => val call = Some(DirectCall(nameToProcedure(b.target), Some(b.line))) - val ft = (b.returnTarget.map(t => labelToBlock(t))).map(x => GoTo(Set(x))).getOrElse(Unreachable()) + val ft = b.returnTarget.map(t => labelToBlock(t)).map(x => GoTo(Set(x))).getOrElse(Unreachable()) (call, ft, ArrayBuffer()) case b: BAPIndirectCall => - val call = IndirectCall(b.target.toIR, Some(b.line)) - val ft = (b.returnTarget.map(t => labelToBlock(t))).map(x => GoTo(Set(x))).getOrElse(Unreachable()) + val call = IndirectCall(translateVar(b.target), Some(b.line)) + val ft = b.returnTarget.map(t => labelToBlock(t)).map(x => GoTo(Set(x))).getOrElse(Unreachable()) (Some(call), ft, ArrayBuffer()) case b: BAPGoTo => val target = labelToBlock(b.target) @@ -185,7 +377,7 @@ class BAPToIR(var program: BAPProgram, mainAddress: BigInt) { * if necessary. * */ private def convertConditionBool(expr: BAPExpr, negative: Boolean): Expr = { - val e = expr.toIR + val e = translateExprOnly(expr) e.getType match { case BitVecType(s) => if (negative) { diff --git a/src/main/scala/translating/SemanticsLoader.scala b/src/main/scala/translating/GTIRBLoader.scala similarity index 67% rename from src/main/scala/translating/SemanticsLoader.scala rename to src/main/scala/translating/GTIRBLoader.scala index c79c4ba09..445fe655b 100644 --- a/src/main/scala/translating/SemanticsLoader.scala +++ b/src/main/scala/translating/GTIRBLoader.scala @@ -1,5 +1,5 @@ package translating -import Parsers.SemanticsParser.* +import Parsers.ASLpParser.* import com.google.protobuf.ByteString import Parsers.* @@ -13,14 +13,15 @@ import scala.collection.mutable.ArrayBuffer import com.grammatech.gtirb.proto.Module.ByteOrder.LittleEndian import util.Logger -class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]]]) { +class GTIRBLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]]]) { private val constMap = mutable.Map[String, IRType]() private val varMap = mutable.Map[String, IRType]() private var instructionCount = 0 private var blockCount = 0 + private var loadCounter = 0 - val opcodeSize = 4 + private val opcodeSize = 4 def visitBlock(blockUUID: ByteString, blockCountIn: Int, blockAddress: Option[BigInt]): ArrayBuffer[Statement] = { blockCount = blockCountIn @@ -39,34 +40,31 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] val instructionAddress = a + (opcodeSize * instructionCount) instructionAddress.toString + "$" + i } - - val statement = visitStmt(s, label) - if (statement.isDefined) { - statements.append(statement.get) - } + + statements.appendAll(visitStmt(s, label)) } instructionCount += 1 } statements } - private def visitStmt(ctx: StmtContext, label: Option[String] = None): Option[Statement] = { + private def visitStmt(ctx: StmtContext, label: Option[String] = None): Seq[Statement] = { ctx match { case a: AssignContext => visitAssign(a, label) case c: ConstDeclContext => visitConstDecl(c, label) case v: VarDeclContext => visitVarDecl(v, label) case v: VarDeclsNoInitContext => visitVarDeclsNoInit(v) - None - case a: AssertContext => visitAssert(a, label) - case t: TCallContext => visitTCall(t, label) - case i: IfContext => visitIf(i, label) - case t: ThrowContext => Some(visitThrow(t, label)) + Seq() + case a: AssertContext => visitAssert(a, label).toSeq + case t: TCallContext => visitTCall(t, label).toSeq + case i: IfContext => visitIf(i, label).toSeq + case t: ThrowContext => Seq(visitThrow(t, label)) } } - private def visitAssert(ctx: AssertContext, label: Option[String] = None): Option[Assert] = { - val expr = visitExpr(ctx.expr) + private def visitAssert(ctx: AssertContext, label: Option[String] = None): Option[Statement] = { + val expr = visitExprOnly(ctx.expr) if (expr.isDefined) { Some(Assert(expr.get, None, label)) } else { @@ -90,8 +88,8 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] checkArgs(function, 1, 4, typeArgs.size, args.size, ctx.getText) val mem = SharedMemory("mem", 64, 8) // yanked from BAP val size = parseInt(typeArgs.head) * 8 - val index = visitExpr(args.head) - val value = visitExpr(args(3)) + val index = visitExprOnly(args.head) + val value = visitExprOnly(args(3)) val otherSize = parseInt(args(1)) * 8 val accessType = parseInt(args(2)) // AccType enum in ASLi, not very relevant to us if (size != otherSize) { @@ -100,12 +98,12 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] // LittleEndian is an assumption if (index.isDefined && value.isDefined) { - Some(MemoryAssign(mem, index.get, value.get, Endian.LittleEndian, size.toInt, label)) + Some(MemoryStore(mem, index.get, value.get, Endian.LittleEndian, size.toInt, label)) } else { None } case "unsupported_opcode.0" => { - val op = args.headOption.flatMap(visitExpr) match { + val op = args.headOption.flatMap(visitExprOnly) match { case Some(IntLiteral(s)) => Some("%08x".format(s)) case c => c.map(_.toString) } @@ -130,7 +128,7 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] } private def visitIf(ctx: IfContext, label: Option[String] = None): Option[TempIf] = { - val condition = visitExpr(ctx.cond) + val condition = visitExprOnly(ctx.cond) val thenStmts = ctx.thenStmts.stmt.asScala.flatMap(visitStmt(_, label)) val elseStmts = Option(ctx.elseStmts) match { @@ -151,35 +149,64 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] varMap ++= newVars } - private def visitVarDecl(ctx: VarDeclContext, label: Option[String] = None): Option[Assign] = { + private def visitVarDecl(ctx: VarDeclContext, label: Option[String] = None): Seq[Statement] = { val ty = visitType(ctx.`type`()) val name = visitIdent(ctx.lvar) varMap += (name -> ty) - val expr = visitExpr(ctx.expr()) - expr.map(Assign(LocalVar(name, ty), _, label)) + val (expr, load) = visitExpr(ctx.expr) + if (expr.isDefined) { + if (load.isDefined) { + val loadWithLabel = MemoryLoad(load.get.lhs, load.get.mem, load.get.index, load.get.endian, load.get.size, label.map(_ + "$0")) + val assign = LocalAssign(LocalVar(name, ty), expr.get, label.map(_ + "$1")) + Seq(loadWithLabel, assign) + } else { + val assign = LocalAssign(LocalVar(name, ty), expr.get, label) + Seq(assign) + } + } else { + Seq() + } } - private def visitAssign(ctx: AssignContext, label: Option[String] = None): Option[Assign] = { + private def visitAssign(ctx: AssignContext, label: Option[String] = None): Seq[Statement] = { val lhs = visitLexpr(ctx.lexpr) - val rhs = visitExpr(ctx.expr) - lhs.zip(rhs).map((lhs, rhs) => Assign(lhs, rhs, label)) + val (rhs, load) = visitExpr(ctx.expr) + if (lhs.isDefined && rhs.isDefined) { + if (load.isDefined) { + val loadWithLabel = MemoryLoad(load.get.lhs, load.get.mem, load.get.index, load.get.endian, load.get.size, label.map(_ + "$0")) + val assign = LocalAssign(lhs.get, rhs.get, label.map(_ + "$1")) + Seq(loadWithLabel, assign) + } else { + val assign = LocalAssign(lhs.get, rhs.get, label) + Seq(assign) + } + } else { + Seq() + } } - private def visitConstDecl(ctx: ConstDeclContext, label: Option[String] = None): Option[Assign] = { + private def visitConstDecl(ctx: ConstDeclContext, label: Option[String] = None): Seq[Statement] = { val ty = visitType(ctx.`type`()) val name = visitIdent(ctx.lvar) constMap += (name -> ty) - val expr = visitExpr(ctx.expr) + val (expr, load) = visitExpr(ctx.expr) if (expr.isDefined) { - Some(Assign(LocalVar(name + "$" + blockCount + "$" + instructionCount, ty), expr.get, label)) + if (load.isDefined) { + val loadWithLabel = MemoryLoad(load.get.lhs, load.get.mem, load.get.index, load.get.endian, load.get.size, label.map(_ + "$0")) + val assign = LocalAssign(LocalVar(name + "$" + blockCount + "$" + instructionCount, ty), expr.get, label.map(_ + "$1")) + Seq(loadWithLabel, assign) + } else { + val assign = LocalAssign(LocalVar(name + "$" + blockCount + "$" + instructionCount, ty), expr.get, label) + Seq(assign) + } } else { - None + Seq() } } private def visitType(ctx: TypeContext): IRType = { - ctx match + ctx match { case e: TypeBitsContext => BitVecType(parseInt(e.size).toInt) case r: TypeRegisterContext => // this is a special register - not the same as a register in the IR @@ -191,21 +218,31 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] case _ => throw Exception(s"unknown type ${ctx.getText}") } case _ => throw Exception(s"unknown type ${ctx.getText}") + } } - private def visitExpr(ctx: ExprContext): Option[Expr] = { + private def visitExpr(ctx: ExprContext): (Option[Expr], Option[MemoryLoad]) = { ctx match { - case e: ExprVarContext => visitExprVar(e) + case e: ExprVarContext => (visitExprVar(e), None) case e: ExprTApplyContext => visitExprTApply(e) case e: ExprSlicesContext => visitExprSlices(e) - case e: ExprFieldContext => Some(visitExprField(e)) - case e: ExprArrayContext => Some(visitExprArray(e)) - case e: ExprLitIntContext => Some(IntLiteral(parseInt(e))) - case e: ExprLitBitsContext => Some(visitExprLitBits(e)) + case e: ExprFieldContext => (Some(visitExprField(e)), None) + case e: ExprArrayContext => (Some(visitExprArray(e)), None) + case e: ExprLitIntContext => (Some(IntLiteral(parseInt(e))), None) + case e: ExprLitBitsContext => (Some(visitExprLitBits(e)), None) } } - private def visitExprVar(ctx: ExprVarContext): Option[Expr] = { + private def visitExprOnly(ctx: ExprContext): Option[Expr] = { + val (expr, load) = visitExpr(ctx) + if (load.isDefined) { + throw Exception(s"found load $expr $load") + } else { + expr + } + } + + private def visitExprVar(ctx: ExprVarContext): Option[Expr] = { val name = visitIdent(ctx.ident) name match { case n if constMap.contains(n) => Some(LocalVar(n + "$" + blockCount + "$" + instructionCount, constMap(n))) @@ -225,7 +262,7 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] } } - private def visitExprTApply(ctx: ExprTApplyContext): Option[Expr] = { + private def visitExprTApply(ctx: ExprTApplyContext): (Option[Expr], Option[MemoryLoad]) = { val function = visitIdent(ctx.ident) val typeArgs: mutable.Buffer[ExprContext] = Option(ctx.tes) match { @@ -241,7 +278,7 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] case "Mem.read.0" => checkArgs(function, 1, 3, typeArgs.size, args.size, ctx.getText) val mem = SharedMemory("mem", 64, 8) - val index = visitExpr(args.head) + val index = visitExprOnly(args.head) // can't have load inside load val size = parseInt(typeArgs.head) * 8 val otherSize = parseInt(args(1)) * 8 @@ -250,112 +287,112 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] throw Exception(s"inconsistent size parameters in Mem.read.0: ${ctx.getText}") } + val temp = LocalVar("load" + loadCounter, BitVecType(size.toInt)) + loadCounter += 1 + if (index.isDefined) { // LittleEndian is assumed - Some(MemoryLoad(mem, index.get, Endian.LittleEndian, size.toInt)) + (Some(temp), Some(MemoryLoad(temp, mem, index.get, Endian.LittleEndian, size.toInt, None))) } else { - None + (None, None) } case "cvt_bool_bv.0" => checkArgs(function, 0, 1, typeArgs.size, args.size, ctx.getText) - val expr = visitExpr(args.head) - if (expr.isDefined) { - val e = expr.get - e match { - case b: BinaryExpr if b.op == BVEQ => Some(BinaryExpr(BVCOMP, b.arg1, b.arg2)) - case FalseLiteral => Some(BitVecLiteral(0, 1)) - case TrueLiteral => Some(BitVecLiteral(1, 1)) - case o => Some(UnaryExpr(BoolToBV1, o)) + val (expr, load) = visitExpr(args.head) + val result : Option[Expr] = expr.map { + case b: BinaryExpr if b.op == BVEQ => BinaryExpr(BVCOMP, b.arg1, b.arg2) + case FalseLiteral => BitVecLiteral(0, 1) + case TrueLiteral => BitVecLiteral(1, 1) + case o => UnaryExpr(BoolToBV1, o) } - } else { - None - } - - case "not_bool.0" => resolveUnaryOp(BoolNOT, function, 0, typeArgs, args, ctx.getText) - case "eq_enum.0" => resolveBinaryOp(BoolEQ, function, 0, typeArgs, args, ctx.getText) - case "or_bool.0" => resolveBinaryOp(BoolOR, function, 0, typeArgs, args, ctx.getText) - case "and_bool.0" => resolveBinaryOp(BoolAND, function, 0, typeArgs, args, ctx.getText) - - case "not_bits.0" => resolveUnaryOp(BVNOT, function, 1, typeArgs, args, ctx.getText) - case "or_bits.0" => resolveBinaryOp(BVOR, function, 1, typeArgs, args, ctx.getText) - case "and_bits.0" => resolveBinaryOp(BVAND, function, 1, typeArgs, args, ctx.getText) - case "eor_bits.0" => resolveBinaryOp(BVXOR, function, 1, typeArgs, args, ctx.getText) - case "eq_bits.0" => resolveBinaryOp(BVEQ, function, 1, typeArgs, args, ctx.getText) - case "add_bits.0" => resolveBinaryOp(BVADD, function, 1, typeArgs, args, ctx.getText) - case "sub_bits.0" => resolveBinaryOp(BVSUB, function, 1, typeArgs, args, ctx.getText) - case "mul_bits.0" => resolveBinaryOp(BVMUL, function, 1, typeArgs, args, ctx.getText) - case "sdiv_bits.0" => resolveBinaryOp(BVSDIV, function, 1, typeArgs, args, ctx.getText) - - case "slt_bits.0" => resolveBinaryOp(BVSLT, function, 1, typeArgs, args, ctx.getText) - case "sle_bits.0" => resolveBinaryOp(BVSLE, function, 1, typeArgs, args, ctx.getText) - - case "lsl_bits.0" => resolveBitShiftOp(BVSHL, function, typeArgs, args, ctx.getText) - case "lsr_bits.0" => resolveBitShiftOp(BVLSHR, function, typeArgs, args, ctx.getText) - case "asr_bits.0" => resolveBitShiftOp(BVASHR, function, typeArgs, args, ctx.getText) + (result, load) + + case "not_bool.0" => (resolveUnaryOp(BoolNOT, function, 0, typeArgs, args, ctx.getText), None) + case "eq_enum.0" => (resolveBinaryOp(BoolEQ, function, 0, typeArgs, args, ctx.getText)) + case "or_bool.0" => (resolveBinaryOp(BoolOR, function, 0, typeArgs, args, ctx.getText)) + case "and_bool.0" => (resolveBinaryOp(BoolAND, function, 0, typeArgs, args, ctx.getText)) + + case "or_bits.0" => (resolveBinaryOp(BVOR, function, 1, typeArgs, args, ctx.getText)) + case "and_bits.0" => (resolveBinaryOp(BVAND, function, 1, typeArgs, args, ctx.getText)) + case "eor_bits.0" => (resolveBinaryOp(BVXOR, function, 1, typeArgs, args, ctx.getText)) + case "eq_bits.0" => (resolveBinaryOp(BVEQ, function, 1, typeArgs, args, ctx.getText)) + case "add_bits.0" => (resolveBinaryOp(BVADD, function, 1, typeArgs, args, ctx.getText)) + case "sub_bits.0" => (resolveBinaryOp(BVSUB, function, 1, typeArgs, args, ctx.getText)) + case "mul_bits.0" => (resolveBinaryOp(BVMUL, function, 1, typeArgs, args, ctx.getText)) + case "sdiv_bits.0" => (resolveBinaryOp(BVSDIV, function, 1, typeArgs, args, ctx.getText)) + case "slt_bits.0" => (resolveBinaryOp(BVSLT, function, 1, typeArgs, args, ctx.getText)) + case "sle_bits.0" => (resolveBinaryOp(BVSLE, function, 1, typeArgs, args, ctx.getText)) + + case "not_bits.0" => (resolveUnaryOp(BVNOT, function, 1, typeArgs, args, ctx.getText), None) + + case "lsl_bits.0" => (resolveBitShiftOp(BVSHL, function, typeArgs, args, ctx.getText), None) + case "lsr_bits.0" => (resolveBitShiftOp(BVLSHR, function, typeArgs, args, ctx.getText), None) + case "asr_bits.0" => (resolveBitShiftOp(BVASHR, function, typeArgs, args, ctx.getText), None) case "append_bits.0" => - resolveBinaryOp(BVCONCAT, function, 2, typeArgs, args, ctx.getText) + (resolveBinaryOp(BVCONCAT, function, 2, typeArgs, args, ctx.getText)) case "replicate_bits.0" => checkArgs(function, 2, 2, typeArgs.size, args.size, ctx.getText) val oldSize = parseInt(typeArgs(0)) val replications = parseInt(typeArgs(1)).toInt - val arg0 = visitExpr(args(0)) + // memory loads shouldn't appear here? + val arg0 = visitExprOnly(args(0)) val arg1 = parseInt(args(1)) val newSize = oldSize * replications if (arg1 != replications) { Exception(s"inconsistent size parameters in replicate_bits.0: ${ctx.getText}") } if (arg0.isDefined) { - Some(Repeat(replications, arg0.get)) + (Some(Repeat(replications, arg0.get)), None) } else { - None + (None, None) } case "ZeroExtend.0" => checkArgs(function, 2, 2, typeArgs.size, args.size, ctx.getText) val oldSize = parseInt(typeArgs(0)) val newSize = parseInt(typeArgs(1)) - val arg0 = visitExpr(args(0)) + val (arg0, load) = visitExpr(args(0)) val arg1 = parseInt(args(1)) if (arg1 != newSize) { Exception(s"inconsistent size parameters in ZeroExtend.0: ${ctx.getText}") } if (arg0.isDefined) { - Some(ZeroExtend((newSize - oldSize).toInt, arg0.get)) + (Some(ZeroExtend((newSize - oldSize).toInt, arg0.get)), load) } else { - None + (None, None) } case "SignExtend.0" => checkArgs(function, 2, 2, typeArgs.size, args.size, ctx.getText) val oldSize = parseInt(typeArgs(0)) val newSize = parseInt(typeArgs(1)) - val arg0 = visitExpr(args(0)) + val (arg0, load) = visitExpr(args(0)) val arg1 = parseInt(args(1)) if (arg1 != newSize) { Exception(s"inconsistent size parameters in SignExtend.0: ${ctx.getText}") } if (arg0.isDefined) { - Some(SignExtend((newSize - oldSize).toInt, arg0.get)) + (Some(SignExtend((newSize - oldSize).toInt, arg0.get)), load) } else { - None + (None, None) } case "FPCompareGT.0" | "FPCompareGE.0" | "FPCompareEQ.0" => checkArgs(function, 1, 3, typeArgs.size, args.size, ctx.getText) val name = function.stripSuffix(".0") val size = parseInt(typeArgs(0)) - val argsIR = args.flatMap(visitExpr).toSeq - Some(UninterpretedFunction(name + "$" + size, argsIR, BoolType)) + val argsIR = args.flatMap(visitExprOnly).toSeq + (Some(UninterpretedFunction(name + "$" + size, argsIR, BoolType)), None) case "FPAdd.0" | "FPMul.0" | "FPDiv.0" | "FPMulX.0" | "FPMax.0" | "FPMin.0" | "FPMaxNum.0" | "FPMinNum.0" | "FPSub.0" => checkArgs(function, 1, 3, typeArgs.size, args.size, ctx.getText) val name = function.stripSuffix(".0") val size = parseInt(typeArgs(0)).toInt - val argsIR = args.flatMap(visitExpr).toSeq - Some(UninterpretedFunction(name + "$" + size, argsIR, BitVecType(size))) + val argsIR = args.flatMap(visitExprOnly).toSeq + (Some(UninterpretedFunction(name + "$" + size, argsIR, BitVecType(size))), None) case "FPMulAddH.0" | "FPMulAdd.0" | "FPRoundInt.0" | @@ -363,31 +400,31 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] checkArgs(function, 1, 4, typeArgs.size, args.size, ctx.getText) val name = function.stripSuffix(".0") val size = parseInt(typeArgs(0)).toInt - val argsIR = args.flatMap(visitExpr).toSeq - Some(UninterpretedFunction(name + "$" + size, argsIR, BitVecType(size))) + val argsIR = args.flatMap(visitExprOnly).toSeq + (Some(UninterpretedFunction(name + "$" + size, argsIR, BitVecType(size))), None) case "FPRecpX.0" | "FPSqrt.0" | "FPRecipEstimate.0" | "FPRSqrtStepFused.0" | "FPRecipStepFused.0" => checkArgs(function, 1, 2, typeArgs.size, args.size, ctx.getText) val name = function.stripSuffix(".0") val size = parseInt(typeArgs(0)).toInt - val argsIR = args.flatMap(visitExpr).toSeq - Some(UninterpretedFunction(name + "$" + size, argsIR, BitVecType(size))) + val argsIR = args.flatMap(visitExprOnly).toSeq + (Some(UninterpretedFunction(name + "$" + size, argsIR, BitVecType(size))), None) case "FPCompare.0" => checkArgs(function, 1, 4, typeArgs.size, args.size, ctx.getText) val name = function.stripSuffix(".0") val size = parseInt(typeArgs(0)) - val argsIR = args.flatMap(visitExpr).toSeq - Some(UninterpretedFunction(name + "$" + size, argsIR, BitVecType(4))) + val argsIR = args.flatMap(visitExprOnly).toSeq + (Some(UninterpretedFunction(name + "$" + size, argsIR, BitVecType(4))), None) case "FPConvert.0" => checkArgs(function, 2, 3, typeArgs.size, args.size, ctx.getText) val name = function.stripSuffix(".0") val outSize = parseInt(typeArgs(0)).toInt val inSize = parseInt(typeArgs(1)) - val argsIR = args.flatMap(visitExpr).toSeq - Some(UninterpretedFunction(name + "$" + outSize + "$" + inSize, argsIR, BitVecType(outSize))) + val argsIR = args.flatMap(visitExprOnly).toSeq + (Some(UninterpretedFunction(name + "$" + outSize + "$" + inSize, argsIR, BitVecType(outSize))), None) case "FPToFixed.0" => checkArgs(function, 2, 5, typeArgs.size, args.size, ctx.getText) @@ -395,8 +432,8 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] val outSize = parseInt(typeArgs(0)).toInt val inSize = parseInt(typeArgs(1)) // need to specifically handle the integer parameter - val argsIR = args.flatMap(visitExpr).toSeq - Some(UninterpretedFunction(name + "$" + outSize + "$" + inSize, argsIR, BitVecType(outSize))) + val argsIR = args.flatMap(visitExprOnly).toSeq + (Some(UninterpretedFunction(name + "$" + outSize + "$" + inSize, argsIR, BitVecType(outSize))), None) case "FixedToFP.0" => checkArgs(function, 2, 5, typeArgs.size, args.size, ctx.getText) @@ -404,28 +441,28 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] val inSize = parseInt(typeArgs(0)) val outSize = parseInt(typeArgs(1)).toInt // need to specifically handle the integer parameter - val argsIR = args.flatMap(visitExpr).toSeq - Some(UninterpretedFunction(name + "$" + outSize + "$" + inSize, argsIR, BitVecType(outSize))) + val argsIR = args.flatMap(visitExprOnly).toSeq + (Some(UninterpretedFunction(name + "$" + outSize + "$" + inSize, argsIR, BitVecType(outSize))), None) case "FPConvertBF.0" => checkArgs(function, 0, 3, typeArgs.size, args.size, ctx.getText) val name = function.stripSuffix(".0") - val argsIR = args.flatMap(visitExpr).toSeq - Some(UninterpretedFunction(name, argsIR, BitVecType(32))) + val argsIR = args.flatMap(visitExprOnly).toSeq + (Some(UninterpretedFunction(name, argsIR, BitVecType(32))), None) case "FPToFixedJS_impl.0" => checkArgs(function, 2, 3, typeArgs.size, args.size, ctx.getText) val name = function.stripSuffix(".0") val inSize = parseInt(typeArgs(0)) val outSize = parseInt(typeArgs(1)).toInt - val argsIR = args.flatMap(visitExpr).toSeq - Some(UninterpretedFunction(name + "$" + outSize + "$" + inSize, argsIR, BitVecType(outSize))) + val argsIR = args.flatMap(visitExprOnly).toSeq + (Some(UninterpretedFunction(name + "$" + outSize + "$" + inSize, argsIR, BitVecType(outSize))), None) case "BFAdd.0" | "BFMul.0" => checkArgs(function, 0, 2, typeArgs.size, args.size, ctx.getText) val name = function.stripSuffix(".0") - val argsIR = args.flatMap(visitExpr).toSeq - Some(UninterpretedFunction(name, argsIR, BitVecType(32))) + val argsIR = args.flatMap(visitExprOnly).toSeq + (Some(UninterpretedFunction(name, argsIR, BitVecType(32))), None) case _ => // known ASLp methods not yet handled: @@ -434,7 +471,7 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] // and will require some research into their semantics // AtomicStart, AtomicEnd - can't model as uninterpreted functions, requires modelling atomic section Logger.debug(s"unidentified call to $function: ${ctx.getText}") - None + (None, None) } } @@ -445,15 +482,18 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] typeArgs: mutable.Buffer[ExprContext], args: mutable.Buffer[ExprContext], token: String - ): Option[BinaryExpr] = { + ): (Option[BinaryExpr], Option[MemoryLoad]) = { checkArgs(function, typeArgsExpected, 2, typeArgs.size, args.size, token) // we don't currently check the size for BV ops which is the type arg - val arg0 = visitExpr(args(0)) - val arg1 = visitExpr(args(1)) + // memory loads shouldn't appear inside binary operations? + val (arg0, l0) = visitExpr(args(0)) + val (arg1, l1) = visitExpr(args(1)) + val l = l0.orElse(l1) + assert(!(l0.isDefined && l1.isDefined), "Multiple loads in expression") if (arg0.isDefined && arg1.isDefined) { - Some(BinaryExpr(operator, arg0.get, arg1.get)) + (Some(BinaryExpr(operator, arg0.get, arg1.get)), l) } else { - None + (None, l) } } @@ -466,7 +506,8 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] ): Option[UnaryExpr] = { checkArgs(function, typeArgsExpected, 1, typeArgs.size, args.size, token) // we don't currently check the size for BV ops which is the type arg - val arg = visitExpr(args.head) + // memory loads shouldn't appear inside unary operations? + val arg = visitExprOnly(args.head) if (arg.isDefined) { Some(UnaryExpr(operator, arg.get)) } else { @@ -483,8 +524,9 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] checkArgs(function, 2, 2, typeArgs.size, args.size, token) val size0 = parseInt(typeArgs(0)) val size1 = parseInt(typeArgs(1)) - val arg0 = visitExpr(args(0)) - val arg1 = visitExpr(args(1)) + val arg0 = visitExprOnly(args(0)) + val arg1 = visitExprOnly(args(1)) + // memory loads shouldn't appear inside bitshifts? if (arg0.isDefined && arg1.isDefined) { if (size0 == size1) { Some(BinaryExpr(operator, arg0.get, arg1.get)) @@ -496,18 +538,18 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] } } - private def visitExprSlices(ctx: ExprSlicesContext): Option[Extract] = { + private def visitExprSlices(ctx: ExprSlicesContext): (Option[Extract], Option[MemoryLoad]) = { val slices = ctx.slices.slice().asScala if (slices.size != 1) { // need to determine the semantics for this case throw Exception(s"currently unable to handle Expr_Slices that contains more than one slice: ${ctx.getText}") } val (hi, lo) = visitSliceContext(slices.head) - val expr = visitExpr(ctx.expr) + val (expr, load) = visitExpr(ctx.expr) if (expr.isDefined) { - Some(Extract(hi, lo, expr.get)) + (Some(Extract(hi, lo, expr.get)), load) } else { - None + (None, None) } } @@ -524,7 +566,7 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] } } - private def visitExprField(ctx: ExprFieldContext): Register = { + private def visitExprField(ctx: ExprFieldContext): Register = { val name = ctx.expr match { case e: ExprVarContext => visitIdent(e.ident) case _ => throw Exception(s"expected ${ctx.getText} to have an Expr_Var as first parameter") @@ -534,7 +576,7 @@ class SemanticsLoader(parserMap: immutable.Map[String, Array[Array[StmtContext]] resolveFieldExpr(name, field) } - private def visitExprArray(ctx: ExprArrayContext): Register = { + private def visitExprArray(ctx: ExprArrayContext): Register = { val name = ctx.array match { case e: ExprVarContext => visitIdent(e.ident) case _ => throw Exception(s"expected ${ctx.getText} to have an Expr_Var as first parameter") diff --git a/src/main/scala/translating/GTIRBToIR.scala b/src/main/scala/translating/GTIRBToIR.scala index 74ba8b8eb..ceab95cbd 100644 --- a/src/main/scala/translating/GTIRBToIR.scala +++ b/src/main/scala/translating/GTIRBToIR.scala @@ -7,7 +7,7 @@ import com.grammatech.gtirb.proto.CFG.Edge import com.grammatech.gtirb.proto.CFG.EdgeLabel import com.grammatech.gtirb.proto.Module.Module import com.grammatech.gtirb.proto.Symbol.Symbol -import Parsers.SemanticsParser.* +import Parsers.ASLpParser.* import gtirb.* import ir.* @@ -158,7 +158,7 @@ class GTIRBToIR(mods: Seq[Module], parserMap: immutable.Map[String, Array[Array[ // maybe good to sort blocks by address around here? - val semanticsLoader = SemanticsLoader(parserMap) + val semanticsLoader = GTIRBLoader(parserMap) for ((functionUUID, blockUUIDs) <- functionBlocks) { val procedure = uuidToProcedure(functionUUID) @@ -202,29 +202,35 @@ class GTIRBToIR(mods: Seq[Module], parserMap: immutable.Map[String, Array[Array[ val sections = mods.flatMap(_.sections) - val initialMemory: ArrayBuffer[MemorySection] = ArrayBuffer() - sections.map {elem => - val bytestoInt = elem.byteIntervals.head.contents.toByteArray.map(byte => BigInt(byte)) - val bytes = bytestoInt.map {byte => - if (byte < 0) { - BitVecLiteral(byte + (BigInt(1) << 8), 8) - } else { - BitVecLiteral(byte, 8) - } + val initialMemory: mutable.TreeMap[BigInt, MemorySection] = mutable.TreeMap() + sections.map { elem => + val bytesToInt = elem.byteIntervals.head.contents.toByteArray.map(byte => BigInt(byte)) + val size = elem.byteIntervals.head.size.toInt + val bytes = if (elem.name == ".bss" && bytesToInt.isEmpty) { + for (_ <- 0 until size) yield BitVecLiteral(0, 8) + } else { + bytesToInt.map { byte => + if (byte < 0) { + BitVecLiteral(byte + (BigInt(1) << 8), 8) + } else { + BitVecLiteral(byte, 8) + } + }.toSeq } - val section = MemorySection(elem.name, elem.byteIntervals.head.address.toInt, elem.byteIntervals.head.size.toInt, bytes.toSeq) - initialMemory += section + val readOnly = elem.name == ".rodata" || elem.name == ".got" // crude heuristic for now + val address = BigInt(elem.byteIntervals.head.address) + val section = MemorySection(elem.name, address, size, bytes, readOnly, None) + initialMemory += (address -> section) } - val readOnlyMemory: ArrayBuffer[MemorySection] = ArrayBuffer() val intialProc: Procedure = procedures.find(_.address.get == mainAddress).get - Program(procedures, intialProc, initialMemory, readOnlyMemory) + Program(procedures, intialProc, initialMemory) } private def removePCAssign(block: Block): Option[String] = { block.statements.last match { - case last @ Assign(lhs: Register, _, _) if lhs.name == "_PC" => + case last @ LocalAssign(lhs: Register, _, _) if lhs.name == "_PC" => val label = last.label block.statements.remove(last) label @@ -234,7 +240,7 @@ class GTIRBToIR(mods: Seq[Module], parserMap: immutable.Map[String, Array[Array[ private def getPCTarget(block: Block): Register = { block.statements.last match { - case Assign(lhs: Register, rhs: Register, _) if lhs.name == "_PC" => rhs + case LocalAssign(lhs: Register, rhs: Register, _) if lhs.name == "_PC" => rhs case _ => throw Exception(s"expected block ${block.label} to have a program counter assignment at its end") } } @@ -371,8 +377,8 @@ class GTIRBToIR(mods: Seq[Module], parserMap: immutable.Map[String, Array[Array[ // need to copy jump as it can't have multiple parents val jumpCopy = currentBlock.jump match { case GoTo(targets, label) => GoTo(targets, label) - case h: Unreachable => Unreachable() - case r: Return => Return() + case Unreachable(label) => Unreachable(label) + case Return(label, args) => Return(label, args) case _ => throw Exception("this shouldn't be reachable") } trueBlock.replaceJump(currentBlock.jump) @@ -395,7 +401,7 @@ class GTIRBToIR(mods: Seq[Module], parserMap: immutable.Map[String, Array[Array[ if (proxySymbols.isEmpty) { // indirect call with no further information val target = block.statements.last match { - case Assign(lhs: Register, rhs: Register, _) if lhs.name == "_PC" => rhs + case LocalAssign(lhs: Register, rhs: Register, _) if lhs.name == "_PC" => rhs case _ => throw Exception(s"no assignment to program counter found before indirect call in block ${block.label}") } val label = block.statements.last.label @@ -650,5 +656,5 @@ class GTIRBToIR(mods: Seq[Module], parserMap: immutable.Map[String, Array[Array[ val assume = Assume(condition, checkSecurity = true) Block(newLabel, None, ArrayBuffer(assume), GoTo(ArrayBuffer(target))) } - } + diff --git a/src/main/scala/translating/ILtoIL.scala b/src/main/scala/translating/ILtoIL.scala index 585897c7c..2177b84f6 100644 --- a/src/main/scala/translating/ILtoIL.scala +++ b/src/main/scala/translating/ILtoIL.scala @@ -1,6 +1,6 @@ package translating -import ir._ import ir.cilvisitor.* +import ir.* private class ILSerialiser extends ReadOnlyVisitor { var program: StringBuilder = StringBuilder() @@ -33,7 +33,7 @@ private class ILSerialiser extends ReadOnlyVisitor { override def visitStatement(node: Statement): Statement = node.acceptVisit(this) - override def visitAssign(node: Assign): Statement = { + override def visitLocalAssign(node: LocalAssign): Statement = { program ++= "LocalAssign(" visitVariable(node.lhs) program ++= " := " @@ -42,8 +42,8 @@ private class ILSerialiser extends ReadOnlyVisitor { node } - override def visitMemoryAssign(node: MemoryAssign): Statement = { - program ++= "MemoryAssign(" + override def visitMemoryStore(node: MemoryStore): Statement = { + program ++= "MemoryStore(" visitMemory(node.mem) program ++= "[" visitExpr(node.index) @@ -62,6 +62,17 @@ private class ILSerialiser extends ReadOnlyVisitor { node } + override def visitMemoryLoad(node: MemoryLoad): Statement = { + program ++= "MemoryLoad(" + visitVariable(node.lhs) + program ++= " := " + visitMemory(node.mem) + program ++= ", [" + visitExpr(node.index) + program ++= "])" + node + } + override def visitAssert(node: Assert): Statement = { program ++= "Assert(" visitExpr(node.body) @@ -86,7 +97,6 @@ private class ILSerialiser extends ReadOnlyVisitor { node } - override def visitDirectCall(node: DirectCall): Statement = { program ++= "DirectCall(" program ++= "(" + node.outParams.map(_._2).mkString(", ") + ") := call " @@ -207,15 +217,6 @@ private class ILSerialiser extends ReadOnlyVisitor { node } - override def visitMemoryLoad(node: MemoryLoad): Expr = { - program ++= "MemoryLoad(" - visitMemory(node.mem) - program ++= ", [" - visitExpr(node.index) - program ++= "])" - node - } - override def visitMemory(node: Memory): Memory = { program ++= "Memory(" program ++= s"\"${node.name}\", ${node.addressSize}, ${node.valueSize})" diff --git a/src/main/scala/translating/IRExpToSMT2.scala b/src/main/scala/translating/IRExpToSMT2.scala index 9e71771ba..107b630fe 100644 --- a/src/main/scala/translating/IRExpToSMT2.scala +++ b/src/main/scala/translating/IRExpToSMT2.scala @@ -11,8 +11,9 @@ trait BasilIR[Repr[+_]] extends BasilIRExp[Repr] { def vstmt(s: Statement): Repr[Statement] = { s match { - case a: Assign => vassign(vlvar(a.lhs), vexpr(a.rhs)) - case m: MemoryAssign => vstore(m.mem.name, vexpr(m.index), vexpr(m.value), m.endian, m.size) + case a: LocalAssign => vassign(vlvar(a.lhs), vexpr(a.rhs)) + case m @ MemoryLoad(lhs, mem, index, endian, size, _) => vload(vlvar(lhs), mem.name, vexpr(index), endian, size) + case m: MemoryStore => vstore(m.mem.name, vexpr(m.index), vexpr(m.value), m.endian, m.size) case c: DirectCall => vcall( c.outParams.toList.map((l, r) => (vlvar(l), vexpr(r))), @@ -38,7 +39,6 @@ trait BasilIR[Repr[+_]] extends BasilIRExp[Repr] { def vexpr(e: Expr): Repr[Expr] = { e match { case n: Literal => vliteral(n) - case m @ MemoryLoad(mem, index, endian, size) => vload(m) case Extract(ed, start, arg) => vextract(ed, start, vexpr(arg)) case Repeat(repeats, arg) => vrepeat(repeats, vexpr(arg)) case ZeroExtend(bits, arg) => vzeroextend(bits, vexpr(arg)) @@ -74,8 +74,9 @@ trait BasilIR[Repr[+_]] extends BasilIRExp[Repr] { returnBlock: Option[Repr[Block]] ): Repr[Procedure] - def vassign(lhs: Repr[Variable], rhs: Repr[Expr]): Repr[Assign] - def vstore(mem: String, index: Repr[Expr], value: Repr[Expr], endian: Endian, size: Int): Repr[MemoryAssign] + def vassign(lhs: Repr[Variable], rhs: Repr[Expr]): Repr[LocalAssign] + def vload(lhs: Repr[Variable], mem: String, index: Repr[Expr], endian: Endian, size: Int): Repr[MemoryLoad] + def vstore(mem: String, index: Repr[Expr], value: Repr[Expr], endian: Endian, size: Int): Repr[MemoryStore] def vcall( outParams: List[(Repr[Variable], Repr[Expr])], procname: String, @@ -118,7 +119,6 @@ trait BasilIRExp[Repr[+_]] { def vuninterp_function(name: String, args: Seq[Repr[Expr]]): Repr[Expr] def vrvar(e: Variable): Repr[Variable] - def vload(arg: MemoryLoad): Repr[Expr] } trait BasilIRExpWithVis[Repr[+_]] extends BasilIRExp[Repr] { @@ -130,7 +130,6 @@ trait BasilIRExpWithVis[Repr[+_]] extends BasilIRExp[Repr] { def vexpr(e: Expr): Repr[Expr] = { e match { case n: Literal => vliteral(n) - case m @ MemoryLoad(mem, index, endian, size) => vload(m) case Extract(ed, start, arg) => vextract(ed, start, vexpr(arg)) case Repeat(repeats, arg) => { vexpr((0 until (repeats - 1)).foldLeft(arg)((acc, n) => BinaryExpr(BVCONCAT, acc, arg))) @@ -156,7 +155,6 @@ trait BasilIRExpWithVis[Repr[+_]] extends BasilIRExp[Repr] { enum Sexp[+T] { case Symb(v: String) case Slist(v: List[Sexp[T]]) - } object Sexp { @@ -171,6 +169,8 @@ def sym[T](l: String): Sexp[T] = Sexp.Symb[T](l) def list[T](l: Sexp[T]*): Sexp[T] = Sexp.Slist(l.toList) object BasilIRToSMT2 extends BasilIRExpWithVis[Sexp] { + def vload(lhs: Sexp[Variable], mem: String, index: Sexp[Expr], endian: Endian, size: Int): Sexp[MemoryLoad] = ??? + def vstore(mem: String, index: Sexp[Expr], value: Sexp[Expr], endian: Endian, size: Int): Sexp[MemoryStore] = ??? def vprog(mainProc: String, procedures: List[Sexp[Procedure]]) : Sexp[Program] = ??? def vrepeat(reps: Int, value: Sexp[Expr]): Sexp[Expr] = ??? @@ -276,8 +276,6 @@ object BasilIRToSMT2 extends BasilIRExpWithVis[Sexp] { } override def vrvar(e: Variable): Sexp[Variable] = sym(fixVname(e.name)) - override def vload(l: MemoryLoad): Sexp[Expr] = - list(sym("memoryload"), sym(l.mem.name), vexpr(l.index), endianToBool(l.endian), int2smt(l.size)) def basilTypeToSMTType(v: IRType): Sexp[Expr] = { v match { @@ -337,23 +335,6 @@ object BasilIRToSMT2 extends BasilIRExpWithVis[Sexp] { decled = decled + decl SkipChildren() } - case l: MemoryLoad => { - val decl = list( - sym("declare-fun"), - sym("memoryload"), - list( - basilTypeToSMTType(l.mem.getType), - basilTypeToSMTType(BitVecType(l.mem.addressSize)), - basilTypeToSMTType(BoolType), - basilTypeToSMTType(IntType) - ), - basilTypeToSMTType(BitVecType(l.size)) - ) - val mem = list(sym("declare-const"), sym(l.mem.name), basilTypeToSMTType(l.mem.getType)) - decled = decled + mem - decled = decled + decl - DoChildren() - } case _ => DoChildren() } diff --git a/src/main/scala/translating/IRToBoogie.scala b/src/main/scala/translating/IRToBoogie.scala index 9bcf81c39..af71abfd7 100644 --- a/src/main/scala/translating/IRToBoogie.scala +++ b/src/main/scala/translating/IRToBoogie.scala @@ -1,28 +1,33 @@ package translating +import analysis.{RegionInjector, DataRegion, HeapRegion, MergedRegion} import ir.{BoolOR, *} import boogie.* import specification.* import util.{BoogieGeneratorConfig, BoogieMemoryAccessMode, ProcRelyVersion, Logger} +import scala.collection.mutable import scala.collection.mutable.ArrayBuffer -class IRToBoogie(var program: Program, var spec: Specification, var thread: Option[ProgramThread], val filename: String) { +class IRToBoogie(var program: Program, var spec: Specification, var thread: Option[ProgramThread], val filename: String, val regionInjector: Option[RegionInjector], val config: BoogieGeneratorConfig) { private val externAttr = BAttribute("extern") private val inlineAttr = BAttribute("inline") private val globals = spec.globals private val controls = spec.controls private val controlled = spec.controlled - private val relies = spec.relies.map(r => r.resolveSpec) - private val reliesParam = spec.relies.map(r => r.resolveSpecParam) - private val reliesReflexive = spec.relies.map(r => r.removeOld) - private val guarantees = spec.guarantees.map(g => g.resolveOld) - private val guaranteesParam = spec.guarantees.map(g => g.resolveSpecParam) - private val guaranteesReflexive = spec.guarantees.map(g => g.removeOld) - private val guaranteeOldVars = spec.guaranteeOldVars - private val LPreds = spec.LPreds.map((k, v) => k -> v.resolveSpecL) - private val requires = spec.subroutines.map(s => s.name -> s.requires.map(e => e.resolveSpec)).toMap + private val resolveSpec = ResolveSpec(regionInjector) + private val resolveSpecL = ResolveSpecL(regionInjector) + private val resolveOld = ResolveOld(resolveSpec) + private val removeOld = RemoveOld(resolveSpec) + private val relies = spec.relies.map(resolveSpec.visitBExpr) + private val reliesParam = spec.relies.map(ResolveSpecParam.visitBExpr) + private val reliesReflexive = spec.relies.map(removeOld.visitBExpr) + private val guarantees = spec.guarantees.map(g => resolveOld.visitBExpr(g) -> g.oldSpecGlobals).toMap + private val guaranteeRegions = guarantees.keys.map(g => g -> g.globals).toMap + private val guaranteesParam = spec.guarantees.map(ResolveSpecParam.visitBExpr) + private val guaranteesReflexive = spec.guarantees.map(removeOld.visitBExpr) + private val requires = spec.subroutines.map(s => s.name -> s.requires.map(resolveSpec.visitBExpr)).toMap private val requiresDirect = spec.subroutines.map(s => s.name -> s.requiresDirect).toMap - private val ensures = spec.subroutines.map(s => s.name -> s.ensures.map(e => e.resolveSpec)).toMap + private val ensures = spec.subroutines.map(s => s.name -> s.ensures.map(resolveSpec.visitBExpr)).toMap private val ensuresDirect = spec.subroutines.map(s => s.name -> s.ensuresDirect).toMap private val libRelies = spec.subroutines.map(s => s.name -> s.rely).toMap private val libGuarantees = spec.subroutines.map(s => s.name -> s.guarantee).toMap @@ -31,6 +36,22 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti private val mem = BMapVar("mem", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Global) private val Gamma_mem = BMapVar("Gamma_mem", MapBType(BitVecBType(64), BoolBType), Scope.Global) + private val LPreds = spec.LPreds.map((k, v) => k -> resolveSpecL.visitBExpr(v)) + private val LArgs = lArgs + + private val memoriesToGamma = if (regionInjector.isDefined) { + regionInjector.get.mergedRegions.collect { + case (_: DataRegion | _: HeapRegion, region: MergedRegion) => + val memory = BMapVar(region.name, MapBType(BitVecBType(64), BitVecBType(8)), Scope.Global) + val gamma = BMapVar(s"Gamma_${region.name}", MapBType(BitVecBType(64), BoolBType), Scope.Global) + memory -> gamma + }.toMap + } else { + Map(mem -> Gamma_mem) + } + + private val memoriesAndGammas: Set[BVar] = memoriesToGamma.flatMap((k, v) => Set(k, v)).toSet + private val mem_in = BMapVar("mem$in", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter) private val Gamma_mem_in = BMapVar("Gamma_mem$in", MapBType(BitVecBType(64), BoolBType), Scope.Parameter) private val mem_out = BMapVar("mem$out", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Parameter) @@ -41,8 +62,6 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti private val mem_inv2 = BMapVar("mem$inv2", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Local) private val Gamma_mem_inv2 = BMapVar("Gamma_mem$inv2", MapBType(BitVecBType(64), BoolBType), Scope.Local) - - private var config: BoogieGeneratorConfig = BoogieGeneratorConfig() private val modifiedCheck: Set[BVar] = (for (i <- 19 to 29) yield { Set(BVariable("R" + i, BitVecBType(64), Scope.Global), BVariable("Gamma_R" + i, BoolBType, Scope.Global)) }).flatten.toSet ++ Set( @@ -50,35 +69,43 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti BVariable("Gamma_R31", BoolBType, Scope.Global) ) - def translate(boogieGeneratorConfig: BoogieGeneratorConfig): BProgram = { - config = boogieGeneratorConfig - val readOnlyMemory = memoryToCondition(program.readOnlyMemory) + def lArgs: List[BMapVar] = { + if (regionInjector.isDefined) { + spec.LPreds.values.flatMap(_.specGlobals).toSet.map { g => + regionInjector.get.getMergedRegion(g.address) match { + case Some(region) => BMapVar(s"${region.name}", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Global) + case None => mem + } + }.toList.sorted + } else { + List(mem) + } + } + + def translate: BProgram = { + val readOnlySections = program.usedMemory.values.filter(_.readOnly) + val readOnlyMemory = memoryToCondition(readOnlySections) + val initialSections = program.usedMemory.values.filter(!_.readOnly) + val initialMemory = memoryToCondition(initialSections) - val procedures = thread match { + val procedures: ArrayBuffer[BProcedure] = thread match { case None => program.procedures.map(f => translateProcedure(f, readOnlyMemory)) case Some(t) => - val translatedProcedures = ArrayBuffer[BProcedure]() + val translatedProcedures: ArrayBuffer[BProcedure] = ArrayBuffer[BProcedure]() t.procedures.foreach(p => translatedProcedures.addOne(translateProcedure(p, readOnlyMemory))) translatedProcedures } - val defaultGlobals = List(BVarDecl(mem, List(externAttr)), BVarDecl(Gamma_mem, List(externAttr))) - val globalVars = procedures.flatMap(p => p.globals) - val globalDecls = (globalVars.map(b => BVarDecl(b, List(externAttr))) ++ defaultGlobals).distinct.sorted.toList - - val globalConsts: List[BConstAxiomPair] = - globals.map(g => BConstAxiomPair(BVarDecl(g.toAddrVar, List(externAttr)), g.toAxiom)).toList.sorted val guaranteeReflexive = BProcedure( name = "guarantee_reflexive", - modifies = Set(mem, Gamma_mem), + modifies = memoriesAndGammas, body = guaranteesReflexive.map(g => BAssert(g)), attributes = List(externAttr) ) val rgProcs = genRely(relies, readOnlyMemory) :+ guaranteeReflexive - val rgLib = config.procedureRely match { case Some(ProcRelyVersion.Function) => // if rely/guarantee lib exist, create genRelyInv, and genInv for every procedure where rely/guarantee lib exist @@ -91,7 +118,6 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti case None => Nil } - val functionsUsed1 = procedures.flatMap(p => p.functionOps).toSet ++ rgProcs.flatMap(p => p.functionOps).toSet ++ rgLib.flatMap(p => p.functionOps).toSet ++ @@ -103,6 +129,12 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti val functionsUsed5 = functionsUsed4.flatMap(p => p.functionOps).map(p => functionOpToDefinition(p)) val functionsUsed = (functionsUsed2 ++ functionsUsed3 ++ functionsUsed4 ++ functionsUsed5).toList.sorted + val globalVars = procedures.flatMap(_.globals) ++ rgProcs.flatMap(_.globals) + val globalDecls = globalVars.map(b => BVarDecl(b, List(externAttr))).distinct.sorted.toList + + val globalConsts: List[BConstAxiomPair] = globals.map { g => + BConstAxiomPair(BVarDecl(g.toAddrVar, List(externAttr)), g.toAxiom) + }.toList.sorted val declarations = globalDecls ++ globalConsts ++ functionsUsed ++ rgLib ++ pushUpModifiesFixedPoint(rgProcs ++ procedures) BProgram(declarations, filename) @@ -113,23 +145,32 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti relies } else { // default case where no rely is given - rely on no external changes - List(BinaryBExpr(BVEQ, mem, Old(mem)), BinaryBExpr(BVEQ, Gamma_mem, Old(Gamma_mem))) + memoriesAndGammas.toList.sorted.map(m => BinaryBExpr(BVEQ, m, Old(m))) } val relyEnsures = if (relies.nonEmpty) { val i = BVariable("i", BitVecBType(64), Scope.Local) - val rely2 = ForAll(List(i), BinaryBExpr(BoolIMPLIES, BinaryBExpr(BVEQ, MapAccess(mem, i), Old(MapAccess(mem, i))), BinaryBExpr(BVEQ, MapAccess(Gamma_mem, i), Old(MapAccess(Gamma_mem, i))))) - List(rely2) ++ reliesUsed + + val memImpliesGamma = memoriesToGamma.keys.toList.sorted.map { memory => + val gamma = memoriesToGamma(memory) + ForAll( + List(i), + BinaryBExpr(BoolIMPLIES, + BinaryBExpr(BVEQ, MapAccess(memory, i), Old(MapAccess(memory, i))), + BinaryBExpr(BVEQ, MapAccess(gamma, i), Old(MapAccess(gamma, i))) + ) + ) + } + memImpliesGamma ++ reliesUsed } else { reliesUsed } - val relyProc = BProcedure("rely", ensures = relyEnsures, freeEnsures = readOnlyMemory, modifies = Set(mem, Gamma_mem), attributes = List(externAttr)) - val relyTransitive = BProcedure("rely_transitive", ensures = reliesUsed, modifies = Set(mem, Gamma_mem), body = List(BProcedureCall("rely"), BProcedureCall("rely")), + val relyProc = BProcedure("rely", ensures = relyEnsures, freeEnsures = readOnlyMemory, modifies = memoriesAndGammas, attributes = List(externAttr)) + val relyTransitive = BProcedure("rely_transitive", ensures = reliesUsed, modifies = memoriesAndGammas, body = List(BProcedureCall("rely"), BProcedureCall("rely")), attributes = List(externAttr)) val relyReflexive = BProcedure("rely_reflexive", body = reliesReflexive.map(r => BAssert(r)), attributes = List(externAttr)) List(relyProc, relyTransitive, relyReflexive) } - def genRelyInv: BProcedure = { val reliesUsed = if (reliesParam.nonEmpty) { reliesParam @@ -169,7 +210,7 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti relyEnsures.head } - val guaranteeEnsures = libGuarantees(name).map(g => g.resolveSpecParam) + val guaranteeEnsures = libGuarantees(name).map(ResolveSpecParam.visitBExpr) val guaranteeOneLine = if (guaranteeEnsures.size > 1) { guaranteeEnsures.tail.foldLeft(guaranteeEnsures.head)((ands: BExpr, next: BExpr) => BinaryBExpr(BoolAND, ands, next)) } else { @@ -191,7 +232,7 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti def genLibGuarantee(name: String): BProcedure = { // G_f - val guaranteeLib = libGuarantees(name).map(g => g.resolveSpecParam) + val guaranteeLib = libGuarantees(name).map(ResolveSpecParam.visitBExpr) val guaranteeOneLine = if (guaranteeLib.size > 1) { guaranteeLib.tail.foldLeft(guaranteeLib.head)((ands: BExpr, next: BExpr) => BinaryBExpr(BoolAND, ands, next)) } else { @@ -273,7 +314,7 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti val in = List(memVar, indexVar, valueVar) val out = BParam(memType) val body: BExpr = config.memoryFunctionType match { - case BoogieMemoryAccessMode.SuccessiveStoreSelect => { + case BoogieMemoryAccessMode.SuccessiveStoreSelect => val indices: Seq[BExpr] = for (i <- 0 until m.accesses) yield { if (i == 0) { indexVar @@ -293,18 +334,19 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti } indiceValues.tail.foldLeft(MapUpdate(memVar, indices.head, valuesEndian.head)) { - (update: MapUpdate, next: (BExpr, BExpr)) => MapUpdate(update, next._1, next._2) + (update: MapUpdate, next: (BExpr, BExpr)) => MapUpdate(update, next(0), next(1)) } - } + case BoogieMemoryAccessMode.LambdaStoreSelect => - if m.accesses == 1 then + if (m.accesses == 1) { MapUpdate(memVar, indexVar, valueVar) - else { + } else { val i = BVariable("i", BitVecBType(m.addressSize), Scope.Local) Lambda(List(i), IfThenElse( BInBounds(indexVar, BitVecBLiteral(m.accesses, m.addressSize), m.endian, i), BByteExtract(valueVar, BinaryBExpr(BVSUB, i, indexVar)), - MapAccess(memVar, i))) + MapAccess(memVar, i)) + ) } } @@ -326,7 +368,8 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti Lambda(List(i), IfThenElse( BInBounds(indexVar, BitVecBLiteral(g.accesses, g.addressSize), Endian.LittleEndian, i), valueVar, - MapAccess(gammaMapVar, i))) + MapAccess(gammaMapVar, i)) + ) } case BoogieMemoryAccessMode.SuccessiveStoreSelect => val indices: Seq[BExpr] = for (i <- 0 until g.accesses) yield { @@ -343,47 +386,51 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti (indices(i), values(i)) } indiceValues.tail.foldLeft(MapUpdate(gammaMapVar, indices.head, values.head)) { - (update: MapUpdate, next: (BExpr, BExpr)) => MapUpdate(update, next._1, next._2) + (update: MapUpdate, next: (BExpr, BExpr)) => MapUpdate(update, next(0), next(1)) } } BFunction(g.fnName, in, out, Some(body), List(externAttr)) case l: LOp => - val memoryVar = BParam("memory", l.memoryType) - val indexVar = BParam("index", l.indexType) + val indexVar: BVar = BParam("index", l.indexType) val body: BExpr = LPreds.keys.foldLeft(FalseBLiteral) { (ite: BExpr, next: SpecGlobal) => - { - val guard = next.arraySize match { - case Some(size: Int) => - val initial: BExpr = BinaryBExpr(BoolEQ, indexVar, ArrayAccess(next, 0).toAddrVar) - val indices = 1 until size - indices.foldLeft(initial) { (or: BExpr, i: Int) => - { - BinaryBExpr(BoolOR, BinaryBExpr(BoolEQ, indexVar, ArrayAccess(next, i).toAddrVar), or) - } - } - case None => BinaryBExpr(BoolEQ, indexVar, next.toAddrVar) - } - val LPred = LPreds(next) - /*if (controlled.contains(next)) { - FunctionCall(s"L_${next.name}", List(l.memory), BoolType) - } else { - LPreds(next) - } */ - IfThenElse(guard, LPred, ite) + val guard = next.arraySize match { + case Some(size: Int) => + val initial: BExpr = BinaryBExpr(BoolEQ, indexVar, ArrayAccess(next, 0).toAddrVar) + val indices = 1 until size + indices.foldLeft(initial) { (or: BExpr, i: Int) => + BinaryBExpr(BoolOR, BinaryBExpr(BoolEQ, indexVar, ArrayAccess(next, i).toAddrVar), or) + } + case None => + BinaryBExpr(BoolEQ, indexVar, next.toAddrVar) } + val LPred = LPreds(next) + /*if (controlled.contains(next)) { + FunctionCall(s"L_${next.name}", List(l.memory), BoolType) + } else { + LPreds(next) + } */ + IfThenElse(guard, LPred, ite) } - BFunction("L", List(memoryVar, indexVar), BParam(BoolBType), Some(body), List(externAttr)) + val params = if (regionInjector.isDefined) { + (body.params - indexVar).toList.sorted + } else { + List(BParam("mem$in", mem.bType)) + } + BFunction("L", params :+ indexVar, BParam(BoolBType), Some(body), List(externAttr)) case b: ByteExtract => val valueVar = BParam("value", BitVecBType(b.valueSize)) val offsetVar = BParam("offset", BitVecBType(b.offsetSize)) val in = List(valueVar, offsetVar) val out = BParam(BitVecBType(8)) val shift = BinaryBExpr(BVMUL, offsetVar, BitVecBLiteral(8, b.offsetSize)) - val eshift = - if (b.valueSize < b.offsetSize) BVExtract(b.valueSize, 0, shift) - else if (b.valueSize == b.offsetSize) shift - else BVZeroExtend(b.valueSize - b.offsetSize, shift) + val eshift = if (b.valueSize < b.offsetSize) { + BVExtract(b.valueSize, 0, shift) + } else if (b.valueSize == b.offsetSize) { + shift + } else { + BVZeroExtend(b.valueSize - b.offsetSize, shift) + } val body = BVExtract(8, 0, BinaryBExpr(BVLSHR, valueVar, eshift)) BFunction(b.fnName, in, out, Some(body), List(inlineAttr)) case b: InBounds => @@ -413,27 +460,24 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti } def pushUpModifiesFixedPoint(procedures: List[BProcedure]): List[BProcedure] = { - var changed = true var proceduresUpdated = procedures while (changed) { changed = false val nameToProcedure = proceduresUpdated.map(p => p.name -> p).toMap - proceduresUpdated = proceduresUpdated.map( - procedure => { - val cmds: List[BCmd] = procedure.body.flatten { - case b: BBlock => b.body - case c: BCmd => Seq(c) - } - val callModifies = cmds.collect { case c: BProcedureCall => nameToProcedure(c.name) }.flatMap(_.modifies) - val modifiesUpdate = procedure.modifies ++ callModifies - if (modifiesUpdate != procedure.modifies) { - changed = true - } - - procedure.copy(modifies = modifiesUpdate) + proceduresUpdated = proceduresUpdated.map { procedure => + val cmds: List[BCmd] = procedure.body.flatten { + case b: BBlock => b.body + case c: BCmd => Seq(c) } - ) + val callModifies = cmds.collect { case c: BProcedureCall => nameToProcedure(c.name) }.flatMap(_.modifies) + val modifiesUpdate = procedure.modifies ++ callModifies + if (modifiesUpdate != procedure.modifies) { + changed = true + } + + procedure.copy(modifies = modifiesUpdate) + } } proceduresUpdated } @@ -442,12 +486,7 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti def translateProcedure(p: Procedure, readOnlyMemory: List[BExpr]): BProcedure = { val body = (p.entryBlock.view ++ ArrayBuffer.from(p.blocks).sortBy( x => -x.rpoOrder).filterNot(x => p.entryBlock.contains(x))).map(translateBlock).toList - val callsRely: Boolean = body.flatMap(_.body).exists(_ match - case BProcedureCall("rely", lhs, params, comment) => true - case _ => false) - - val modifies: Seq[BVar] = p.modifies.toSeq - .flatMap { + val modifies: Seq[BVar] = p.modifies.toSeq.flatMap { case m: Memory => Seq(m.toBoogie, m.toGamma) case r: Register => Seq(r.toBoogie, r.toGamma) }.distinct.sorted @@ -455,14 +494,14 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti val modifiedPreserve = modifies.collect { case m: BVar if modifiedCheck.contains(m) => m } val modifiedPreserveEnsures: List[BExpr] = modifiedPreserve.map(m => BinaryBExpr(BoolEQ, m, Old(m))).toList - val procRequires: List[BExpr] = p.requires ++ requires.getOrElse(p.name, List()) - val procEnsures: List[BExpr] = p.ensures ++ ensures.getOrElse(p.name, List()) + val procRequires: List[BExpr] = p.requires ++ requires.getOrElse(p.procName, List()) + val procEnsures: List[BExpr] = p.ensures ++ ensures.getOrElse(p.procName, List()) - val procRequiresDirect: List[String] = requiresDirect.getOrElse(p.name, List()) - val procEnsuresDirect: List[String] = ensuresDirect.getOrElse(p.name, List()) + val procRequiresDirect: List[String] = requiresDirect.getOrElse(p.procName, List()) + val procEnsuresDirect: List[String] = ensuresDirect.getOrElse(p.procName, List()) val freeRequires: List[BExpr] = if (p == program.mainProcedure) { - memoryToCondition(program.initialMemory) ++ readOnlyMemory + memoryToCondition(program.initialMemory.values) ++ readOnlyMemory } else { readOnlyMemory } @@ -487,10 +526,10 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti ) } - private def memoryToCondition(memory: ArrayBuffer[MemorySection]): List[BExpr] = { + private def memoryToCondition(memorySections: Iterable[MemorySection]): List[BExpr] = { def coalesced: List[BExpr] = { - val sections = memory.flatMap { s => + val sections = memorySections.flatMap { s => // Phrase the memory condition in terms of 64-bit operations, as long as the memory // section's size is a multiple of 64-bits and 64-bits (8 bytes) aligned // If the memory section is not aligned, the initial unaligned part of it will not be coalesced into a 64-bit @@ -498,66 +537,86 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti // If the memory section's size is not a multiple of 64-bits, the last part of it that cannot be coalesced into // a 64-bit representation will remain as an 8-bit representation - val aligned: Int = (s.address % 8).toInt - - val alignedSizeMultiple = (s.bytes.size - aligned) % 8 - // index of the byte that marks the end of the part that is a multiple of 64-bits - val alignedEnd = s.bytes.size - alignedSizeMultiple - - // Aligned section that is safe to convert to 64-bit values - val alignedSection = for (b <- aligned until alignedEnd by 8) yield { - // Combine the byte constants into a 64-bit value - val combined: BigInt = - (0 until 8).foldLeft(BigInt(0))((x, y) => x + (s.bytes(b + y).value * BigInt(2).pow(y * 8))) - BinaryBExpr( - BVEQ, - BMemoryLoad(mem, BitVecBLiteral(s.address + b, 64), Endian.LittleEndian, 64), - BitVecBLiteral(combined, 64) - ) + val memory = s.region match { + case Some(region) => BMapVar(region.name, MapBType(BitVecBType(64), BitVecBType(8)), Scope.Global) + case None => mem } - // If memory section is somehow not aligned (is this possible?) then don't convert the initial non-aligned - // section to 64-bit operations, just the rest - val unalignedStartSection = if (aligned == 0) { - Seq() + if (s.bytes.size <= 8) { + // if section is less than 8 bytes, just represent it with one access + val combined = s.bytes.indices.foldLeft(BigInt(0))((x, y) => x + (s.bytes(y).value * BigInt(2).pow(y * 8))) + val bits = s.bytes.size * 8 + Seq(BinaryBExpr( + BVEQ, + BMemoryLoad(memory, BitVecBLiteral(s.address, 64), Endian.LittleEndian, bits), + BitVecBLiteral(combined, bits) + )) } else { - for (b <- 0 until aligned) yield { + val aligned: Int = (s.address % 8).toInt + + val alignedSizeMultiple = (s.bytes.size - aligned) % 8 + // index of the byte that marks the end of the part that is a multiple of 64-bits + val alignedEnd = s.bytes.size - alignedSizeMultiple + + // Aligned section that is safe to convert to 64-bit values + val alignedSection = for (b <- aligned until alignedEnd by 8) yield { + // Combine the byte constants into a 64-bit value + val combined: BigInt = + (0 until 8).foldLeft(BigInt(0))((x, y) => x + (s.bytes(b + y).value * BigInt(2).pow(y * 8))) BinaryBExpr( BVEQ, - BMemoryLoad(mem, BitVecBLiteral(s.address + b, 64), Endian.LittleEndian, 8), - s.bytes(b).toBoogie + BMemoryLoad(memory, BitVecBLiteral(s.address + b, 64), Endian.LittleEndian, 64), + BitVecBLiteral(combined, 64) ) } - } - // If the memory section is not a multiple of 64-bits then don't convert the last section to 64-bits - // This is not ideal but will do for now - // Ideal solution is to match the sizes based on the sizes listed in the symbol table, dividing further - // for values greater than 64-bit as much as possible - // But that requires more work - // Combine the byte constants into a 64-bit value - val unalignedEndSection = if (alignedSizeMultiple == 0) { - Seq() - } else { - for (b <- alignedEnd until s.bytes.size) yield { - BinaryBExpr( - BVEQ, - BMemoryLoad(mem, BitVecBLiteral(s.address + b, 64), Endian.LittleEndian, 8), - s.bytes(b).toBoogie - ) + // If memory section is somehow not aligned (is this possible?) then don't convert the initial non-aligned + // section to 64-bit operations, just the rest + val unalignedStartSection = if (aligned == 0) { + Seq() + } else { + for (b <- 0 until aligned) yield { + BinaryBExpr( + BVEQ, + BMemoryLoad(memory, BitVecBLiteral(s.address + b, 64), Endian.LittleEndian, 8), + s.bytes(b).toBoogie + ) + } } + + // If the memory section is not a multiple of 64-bits then don't convert the last section to 64-bits + // This is not ideal but will do for now + // Ideal solution is to match the sizes based on the sizes listed in the symbol table, dividing further + // for values greater than 64-bit as much as possible + // But that requires more work + // Combine the byte constants into a 64-bit value + val unalignedEndSection = if (alignedSizeMultiple == 0) { + Seq() + } else { + for (b <- alignedEnd until s.bytes.size) yield { + BinaryBExpr( + BVEQ, + BMemoryLoad(memory, BitVecBLiteral(s.address + b, 64), Endian.LittleEndian, 8), + s.bytes(b).toBoogie + ) + } + } + unalignedStartSection ++ alignedSection ++ unalignedEndSection } - unalignedStartSection ++ alignedSection ++ unalignedEndSection } sections.toList } def bytes: List[BExpr] = { - val sections = memory.flatMap { s => + val sections = memorySections.flatMap { s => + val memory = s.region match { + case Some(region) => BMapVar(region.name, MapBType(BitVecBType(64), BitVecBType(8)), Scope.Global) + case None => mem + } for (b <- s.bytes.indices) yield { BinaryBExpr( BVEQ, - BMemoryLoad(mem, BitVecBLiteral(s.address + b, 64), Endian.LittleEndian, 8), + BMemoryLoad(memory, BitVecBLiteral(s.address + b, 64), Endian.LittleEndian, 8), s.bytes(b).toBoogie ) } @@ -598,12 +657,12 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti * Procedures with no precond and the predicate as their postcond are generated to encode two-state assumptions. * */ - (libRelies.keySet ++ libGuarantees.keySet).filter(x => libRelies(x).nonEmpty && libGuarantees(x).nonEmpty).map(targetName => { - val Rc: BExpr = spec.relies.reduce((a, b) => BinaryBExpr(BoolAND, a, b)).resolveSpec - val Gc: BExpr = spec.guarantees.reduce((a, b) => BinaryBExpr(BoolAND, a, b)).resolveSpec + (libRelies.keySet ++ libGuarantees.keySet).filter(x => libRelies(x).nonEmpty && libGuarantees(x).nonEmpty).map { targetName => + val Rc: BExpr = resolveSpec.visitBExpr(spec.relies.reduce((a, b) => BinaryBExpr(BoolAND, a, b))) + val Gc: BExpr = resolveSpec.visitBExpr(spec.guarantees.reduce((a, b) => BinaryBExpr(BoolAND, a, b))) - val Rf: BExpr = libRelies(targetName).reduce((a, b) => BinaryBExpr(BoolAND, a, b)).resolveSpec - val Gf: BExpr = libGuarantees(targetName).reduce((a, b) => BinaryBExpr(BoolAND, a, b)).resolveSpec + val Rf: BExpr = resolveSpec.visitBExpr(libRelies(targetName).reduce((a, b) => BinaryBExpr(BoolAND, a, b))) + val Gf: BExpr = resolveSpec.visitBExpr(libGuarantees(targetName).reduce((a, b) => BinaryBExpr(BoolAND, a, b))) val inv = BinaryBExpr(BoolOR, Rc, Gf) val conseq = BinaryBExpr(BoolIMPLIES, Rc, Rf) @@ -627,20 +686,19 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti )) targetName -> Seq(procInv, proc2, procGf, proc4, proc5) - }).toMap + }.toMap } - def relyfun(targetName: String) : Option[IfCmd] = { - libRGFunsContradictionProof.get(targetName).map(proc => - { - IfCmd(StarBLiteral, List( - BProcedureCall(proc(0).name, Seq(), Seq()), - BProcedureCall(proc(1).name, Seq(), Seq()), - BAssert(FalseBLiteral) - )) - } - ) + def relyfun(targetName: String): Option[IfCmd] = { + libRGFunsContradictionProof.get(targetName).map { proc => + IfCmd(StarBLiteral, List( + BProcedureCall(proc(0).name, Seq(), Seq()), + BProcedureCall(proc(1).name, Seq(), Seq()), + BAssert(FalseBLiteral) + )) + } } + def translate(j: Jump): List[BCmd] = j match { case g: GoTo => // collects all targets of the goto with a branch condition that we need to check the security level for @@ -662,17 +720,17 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti val out = r.outParams.toList if (out.nonEmpty) then List( AssignCmd(out.map(_._1.toBoogie), out.map(_._2.toBoogie)), - AssignCmd(out.map(_._1.toGamma), out.map(_._2.toGamma)), + AssignCmd(out.map(_._1.toGamma), out.map(c => exprToGamma(c._2))), ReturnCmd) else List(ReturnCmd) } - case r: Unreachable => List(BAssume(FalseBLiteral)) + case _: Unreachable => List(BAssume(FalseBLiteral)) } def translate(j: Call): List[BCmd] = j match { case d: DirectCall => val call = BProcedureCall(d.target.name, - d.outParams.toList.flatMap(c => Seq(c._2.toBoogie, c._2.toGamma)), - d.actualParams.toList.flatMap(c => Seq(c._2.toBoogie, c._2.toGamma)) + d.outParams.toList.flatMap(c => Seq(c._2.toBoogie, c._2.gammas.head.toGamma)), + d.actualParams.toList.flatMap(c => Seq(c._2.toBoogie, exprToGamma(c._2))) ) (config.procedureRely match { @@ -680,7 +738,7 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti if (libRelies.contains(d.target.name) && libGuarantees.contains(d.target.name) && libRelies(d.target.name).nonEmpty && libGuarantees(d.target.name).nonEmpty) { val invCall1 = BProcedureCall(d.target.name + "$inv", List(mem_inv1, Gamma_mem_inv1), List(mem, Gamma_mem)) val invCall2 = BProcedureCall("rely$inv", List(mem_inv2, Gamma_mem_inv2), List(mem_inv1, Gamma_mem_inv1)) - val libRGAssert = libRelies(d.target.name).map(r => BAssert(r.resolveSpecInv)) + val libRGAssert = libRelies(d.target.name).map(r => BAssert(ResolveSpecInv.visitBExpr(r))) List(invCall1, invCall2) ++ libRGAssert } else { List() @@ -693,35 +751,64 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti def translate(s: Statement): List[BCmd] = s match { case d: Call => translate(d) - case m: NOP => List.empty - case m: MemoryAssign => + case _: NOP => List.empty + case m: MemoryStore => val lhs = m.mem.toBoogie val rhs = BMemoryStore(m.mem.toBoogie, m.index.toBoogie, m.value.toBoogie, m.endian, m.size) val lhsGamma = m.mem.toGamma - val rhsGamma = GammaStore(m.mem.toGamma, m.index.toBoogie, m.value.toGamma, m.size, m.size / m.mem.valueSize) + val rhsGamma = GammaStore(m.mem.toGamma, m.index.toBoogie, exprToGamma(m.value), m.size, m.size / m.mem.valueSize) val store = AssignCmd(List(lhs, lhsGamma), List(rhs, rhsGamma)) val stateSplit = List.empty /*s match { - case MemoryAssign(_, _, _, _, _, Some(label)) => List(captureStateStatement(s"$label")) - case Assign(_, _, Some(label)) => List(captureStateStatement(s"$label")) + val stateSplit = s match { + case MemoryStore(_, _, _, _, _, Some(label)) => List(captureStateStatement(s"$label")) + case LocalAssign(_, _, Some(label)) => List(captureStateStatement(s"$label")) case _ => List.empty } */ m.mem match { - case s: StackMemory => + case _: StackMemory => List(store) ++ stateSplit - case s: SharedMemory => + case _: SharedMemory => val rely = BProcedureCall("rely") - val gammaValueCheck = BAssert(BinaryBExpr(BoolIMPLIES, L(lhs, rhs.index), m.value.toGamma)) - val oldAssigns = - guaranteeOldVars.map(g => AssignCmd(g.toOldVar, BMemoryLoad(lhs, g.toAddrVar, Endian.LittleEndian, g.size))) - val oldGammaAssigns = controlled.map(g => + val gammaValueCheck = BAssert(BinaryBExpr(BoolIMPLIES, L(LArgs, rhs.index), exprToGamma(m.value))) + val oldVars = guarantees.keys.view.toSet.flatMap { g => + if (guaranteeRegions(g).contains(lhs)) { + guarantees(g) + } else { + Set() + } + } + val oldAssigns = oldVars.toList.sorted.map { g => + val memory = if (regionInjector.isDefined) { + regionInjector.get.getMergedRegion(g.address) match { + case Some(region) => BMapVar(region.name, MapBType(BitVecBType(64), BitVecBType(8)), Scope.Global) + case None => mem + } + } else { + mem + } + AssignCmd(g.toOldVar, BMemoryLoad(memory, g.toAddrVar, Endian.LittleEndian, g.size)) + } + val oldGammaAssigns = controlled.map { g => + val gamma = if (regionInjector.isDefined) { + regionInjector.get.getMergedRegion(g.address) match { + case Some(region) => + BMapVar(s"Gamma_${region.name}", MapBType(BitVecBType(64), BoolBType), Scope.Global) + case None => + Gamma_mem + } + } else { + Gamma_mem + } AssignCmd( g.toOldGamma, - BinaryBExpr(BoolOR, GammaLoad(lhsGamma, g.toAddrVar, g.size, g.size / m.mem.valueSize), L(lhs, g.toAddrVar)) + BinaryBExpr(BoolOR, GammaLoad(gamma, g.toAddrVar, g.size, g.size / m.mem.valueSize), L(LArgs, g.toAddrVar)) ) - ) - val secureUpdate = for (c <- controls.keys) yield { + } + val secureUpdate = for (c <- controls.keys.view.toSeq.sorted) yield { val addrCheck = BinaryBExpr(BVEQ, rhs.index, c.toAddrVar) - val checks = controls(c).map(v => BinaryBExpr(BoolIMPLIES, L(lhs, v.toAddrVar), v.toOldGamma)).toList + val checks = controls(c).toList.sorted.map { v => + BinaryBExpr(BoolIMPLIES, L(LArgs, v.toAddrVar), v.toOldGamma) + } val checksAnd = if (checks.size > 1) { checks.tail.foldLeft(checks.head)((next: BExpr, ands: BExpr) => BinaryBExpr(BoolAND, next, ands)) } else { @@ -729,25 +816,34 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti } BAssert(BinaryBExpr(BoolIMPLIES, addrCheck, checksAnd)) } - val guaranteeChecks = guarantees.map(v => BAssert(v)) + val guaranteeChecks = guarantees.keys.collect { + case g if guaranteeRegions(g).contains(lhs) => BAssert(g) + } (List(rely, gammaValueCheck) ++ oldAssigns ++ oldGammaAssigns :+ store) ++ secureUpdate ++ guaranteeChecks ++ stateSplit } - case l: Assign => + case l: LocalAssign => val lhs = l.lhs.toBoogie val rhs = l.rhs.toBoogie val lhsGamma = l.lhs.toGamma - val rhsGamma = l.rhs.toGamma - val assign = AssignCmd(List(lhs, lhsGamma), List(rhs, rhsGamma)) - val loads = l.rhs.loads - if (loads.size > 1) { - throw Exception(s"$l contains multiple loads") + val rhsGamma = exprToGamma(l.rhs) + List(AssignCmd(List(lhs, lhsGamma), List(rhs, rhsGamma))) + case m: MemoryLoad => + val lhs = m.lhs.toBoogie + val lhsGamma = m.lhs.toGamma + val rhs = BMemoryLoad(m.mem.toBoogie, m.index.toBoogie, m.endian, m.size) + val rhsGamma = m.mem match { + case s: StackMemory => + GammaLoad(s.toGamma, m.index.toBoogie, m.size, m.size / s.valueSize) + case s: SharedMemory => + val boogieIndex = m.index.toBoogie + BinaryBExpr(BoolOR, GammaLoad(s.toGamma, boogieIndex, m.size, m.size / s.valueSize), L(LArgs, boogieIndex)) } - // add rely call if assignment contains a non-stack load - loads.headOption match { - case Some(MemoryLoad(SharedMemory(_, _, _), _, _, _)) => + val assign = AssignCmd(List(lhs, lhsGamma), List(rhs, rhsGamma)) + // add rely call if is a non-stack load + m.mem match { + case _: SharedMemory => List(BProcedureCall("rely"), assign) case _ => - // load is a stack load or doesn't exist List(assign) } case a: Assert => @@ -757,4 +853,17 @@ class IRToBoogie(var program: Program, var spec: Specification, var thread: Opti val body = a.body.toBoogie List(BAssume(body, a.comment)) } + + def exprToGamma(e: Expr): BExpr = { + val gammaVars: Set[BExpr] = e.gammas.map(_.toGamma) + if (gammaVars.isEmpty) { + TrueBLiteral + } else if (gammaVars.size == 1) { + gammaVars.head + } else { + gammaVars.tail.foldLeft(gammaVars.head) { (join: BExpr, next: BExpr) => + BinaryBExpr(BoolAND, next, join) + } + } + } } diff --git a/src/main/scala/translating/PrettyPrinter.scala b/src/main/scala/translating/PrettyPrinter.scala index 98bbef13a..033fefa68 100644 --- a/src/main/scala/translating/PrettyPrinter.scala +++ b/src/main/scala/translating/PrettyPrinter.scala @@ -67,12 +67,16 @@ class BasilIRPrettyPrinter() extends BasilIR[BST] { BST(s"proc $name(${inParams.mkString(", ")}) -> (${outParams.mkString(", ")}) {\n$entry${middleBlocks.mkString("\n")}$ret\n}") } - override def vassign(lhs: BST[Variable], rhs: BST[Expr]): BST[Assign] = BST(s"${lhs} := ${rhs}") + override def vassign(lhs: BST[Variable], rhs: BST[Expr]): BST[LocalAssign] = BST(s"${lhs} := ${rhs}") - override def vstore(mem: String, index: BST[Expr], value: BST[Expr], endian: Endian, size: Int): BST[MemoryAssign] = { + override def vstore(mem: String, index: BST[Expr], value: BST[Expr], endian: Endian, size: Int): BST[MemoryStore] = { val le = if endian == Endian.LittleEndian then "le" else "be" BST(s"store_$le(${mem}, ${index}, ${value}, ${size})") } + def vload(lhs: BST[Variable], mem: String, index: BST[Expr], endian: Endian, size: Int): BST[MemoryLoad] = { + val le = if endian == Endian.LittleEndian then "le" else "be" + BST(s"$lhs := load_$le(${mem}, ${index}, ${size})") + } override def vcall( outParams: List[(BST[Variable], BST[Expr])], @@ -96,6 +100,7 @@ class BasilIRPrettyPrinter() extends BasilIR[BST] { case BitVecType(sz) => s"bv$sz" case IntType => "nat" case BoolType => "bool" + case _ => ??? } override def vrvar(e: Variable): BST[Variable] = vlvar(e) @@ -121,17 +126,11 @@ class BasilIRPrettyPrinter() extends BasilIR[BST] { BST(s"$opn($arg)") } - override def vboollit(b: Boolean) = BST(b.toString) override def vintlit(i: BigInt) = BST("0x%x".format(i)) override def vbvlit(i: BitVecLiteral) = BST("0x%x".format(i.value) + s"bv${i.size}") override def vuninterp_function(name: String, args: Seq[BST[Expr]]): BST[Expr] = BST(s"$name(${args.mkString(", ")})") - override def vload(arg: MemoryLoad): BST[Expr] = { - val le = if Endian == Endian.LittleEndian then "le" else "be" - BST(s"load_${le}(${arg.mem.name}, ${vexpr(arg.index)}, ${arg.size})") - } - } diff --git a/src/main/scala/translating/ReadELFLoader.scala b/src/main/scala/translating/ReadELFLoader.scala index 01af088d8..cea924901 100644 --- a/src/main/scala/translating/ReadELFLoader.scala +++ b/src/main/scala/translating/ReadELFLoader.scala @@ -46,20 +46,24 @@ case class ELFSymbol(num: Int, /* symbol number */ name: String) object ReadELFLoader { - def visitSyms(ctx: SymsContext, config: ILLoadingConfig): (List[ELFSymbol], Set[ExternalFunction], Set[SpecGlobal], Map[BigInt, BigInt], BigInt) = { + def visitSyms(ctx: SymsContext, config: ILLoadingConfig): (List[ELFSymbol], Set[ExternalFunction], Set[SpecGlobal], Set[FuncEntry], Map[BigInt, BigInt], BigInt) = { val externalFunctions = ctx.relocationTable.asScala.filter(_.relocationTableHeader != null).flatMap(r => visitRelocationTableExtFunc(r)).toSet val relocationOffsets = ctx.relocationTable.asScala.filter(_.relocationTableHeader != null).flatMap(r => visitRelocationTableOffsets(r)).toMap val mainAddress = ctx.symbolTable.asScala.flatMap(s => getFunctionAddress(s, config.mainProcedureName)) val symbolTable = ctx.symbolTable.asScala.flatMap(s => visitSymbolTable(s)).toList - val globalVariables = (symbolTable.collect { - case ELFSymbol(num, value, size, ELFSymType.OBJECT, ELFBind.GLOBAL, ELFVis.DEFAULT, ndx, name) if ndx != ELFNDX.UND => SpecGlobal(name, size * 8, None, value) - }).toSet + val globalVariables = symbolTable.collect { + case ELFSymbol(_, value, size, ELFSymType.OBJECT, ELFBind.GLOBAL, ELFVis.DEFAULT, ndx, name) if ndx != ELFNDX.UND => SpecGlobal(name, size * 8, None, value) + }.toSet + + val functionEntries = symbolTable.collect { + case ELFSymbol(_, value, size, ELFSymType.FUNC, ELFBind.GLOBAL, ELFVis.DEFAULT, ndx, name) if ndx != ELFNDX.UND => FuncEntry(name, size * 8, value) + }.toSet if (mainAddress.isEmpty) { throw Exception(s"no ${config.mainProcedureName} function in symbol table") } - (symbolTable, externalFunctions, globalVariables, relocationOffsets, mainAddress.head) + (symbolTable, externalFunctions, globalVariables, functionEntries, relocationOffsets, mainAddress.head) } def visitRelocationTableExtFunc(ctx: RelocationTableContext): Set[ExternalFunction] = { diff --git a/src/main/scala/translating/SpecificationLoader.scala b/src/main/scala/translating/SpecificationLoader.scala index 73449f879..557c369f4 100644 --- a/src/main/scala/translating/SpecificationLoader.scala +++ b/src/main/scala/translating/SpecificationLoader.scala @@ -4,6 +4,7 @@ import Parsers.SpecificationsParser._ import boogie._ import specification._ import ir._ +import util.Logger import scala.collection.mutable.ArrayBuffer import scala.jdk.CollectionConverters._ @@ -43,7 +44,7 @@ case class SpecificationLoader(symbols: Set[SpecGlobal], program: Program) { case Some(_) => visitDirectFunctions(ctx.directFunctions) case None => Set() } - Specification(globals, lPreds, relies, guarantees, subroutines, directFunctions) + Specification(Set(), globals, lPreds, relies, guarantees, subroutines, directFunctions) } def visitDirectFunctions(ctx: DirectFunctionsContext): Set[FunctionOp] = { @@ -276,8 +277,8 @@ case class SpecificationLoader(symbols: Set[SpecGlobal], program: Program) { def visitBoogieTypeName(ctx: BoogieTypeNameContext): BType = { ctx match { case b: BvBTypeContext => BitVecBType(Integer.parseInt(b.BVSIZE.getText.stripPrefix("bv"))) - case c: IntBTypeContext => IntBType - case c: BoolBTypeContext => BoolBType + case _: IntBTypeContext => IntBType + case _: BoolBTypeContext => BoolBType case m: MapBTypeContext => MapBType(visitBoogieTypeName(m.keyT), visitBoogieTypeName(m.valT)) } } @@ -317,38 +318,38 @@ case class SpecificationLoader(symbols: Set[SpecGlobal], program: Program) { } def visitId(ctx: IdContext, nameToGlobals: Map[String, SpecGlobal], params: Map[String, Expr] = Map()): BExpr = { - val id = ctx.getText - id match { + ctx.getText match { case id if id.startsWith("Gamma_R") => { BVariable(id, BoolBType, Scope.Global) } case id if (id.startsWith("Gamma_")) => { - val gamma_id = id.stripPrefix("Gamma_") - params.get(gamma_id) match { - case Some(p: LocalVar) => p.toGamma - case Some(p: Expr) => p.toGamma - case None => - nameToGlobals.get(gamma_id) match { - case Some(g: SpecGlobal) => SpecGamma(g) - case None => throw new Exception(s"unresolvable reference to '$id' in specification") - } + val gamma_id = id.stripPrefix("Gamma_") + params.get(gamma_id) match { + case Some(p: LocalVar) => p.toGamma + case Some(p: Expr) => p.gammas.map(_.toGamma).head + case None => + nameToGlobals.get(gamma_id) match { + case Some(g: SpecGlobal) => SpecGamma(g) + case None => throw new Exception(s"unresolvable reference to '$id' in specification") + } } } - case id if id.startsWith("R") => { + case id if id.startsWith("R") => BVariable(id, BitVecBType(64), Scope.Global) - } - case id => { + case id => params.get(id) match { case Some(p: LocalVar) => p.toBoogie case Some(p: Expr) => p.toBoogie case None => nameToGlobals.get(ctx.getText) match { case Some(g: SpecGlobal) => g - case None => throw new Exception(s"unresolvable reference to '$id' in specification") + case None => { + Logger.error(s"$params \n\n $nameToGlobals") + throw new Exception(s"unresolvable reference to '$id' in specification") + } } } - } - } + } } def visitMulDivModOp(ctx: MulDivModOpContext): BVBinOp = ctx.getText match { @@ -374,13 +375,13 @@ case class SpecificationLoader(symbols: Set[SpecGlobal], program: Program) { def visitSubroutine(ctx: SubroutineContext, nameToGlobals: Map[String, SpecGlobal]): SubroutineSpec = { val name = ctx.id.getText - val irProc = program.procedures.collectFirst { case p if p.name == name => p } + val irProc = program.procedures.collectFirst { case p if p.procName == name => p } val params: Map[String, Expr] = irProc match { case None => Map() case Some(p) => val r = p.inParamDefaultBinding.map(p => p._1.name -> p._2).toMap ++ p.outParamDefaultBinding.map(p => p._1.name -> p._2).toMap - + (p.name + "_result" -> (Extract(32,0,Register("R0", 64)))) + + (p.procName + "_result" -> (Extract(32,0,Register("R0", 64)))) r } diff --git a/src/main/scala/util/BASILConfig.scala b/src/main/scala/util/BASILConfig.scala index a971148af..4ecc4b9b2 100644 --- a/src/main/scala/util/BASILConfig.scala +++ b/src/main/scala/util/BASILConfig.scala @@ -22,7 +22,8 @@ case class StaticAnalysisConfig(dumpILToPath: Option[String] = None, analysisDotPath: Option[String] = None, threadSplit: Boolean = false, summariseProcedures: Boolean = false, - ) + memoryRegions: Boolean = false) + enum BoogieMemoryAccessMode: case SuccessiveStoreSelect, LambdaStoreSelect diff --git a/src/main/scala/util/RunUtils.scala b/src/main/scala/util/RunUtils.scala index 09bde6d09..2377515e9 100644 --- a/src/main/scala/util/RunUtils.scala +++ b/src/main/scala/util/RunUtils.scala @@ -1,16 +1,15 @@ package util -import java.io.{File, PrintWriter, FileInputStream, BufferedWriter, FileWriter, IOException} +import java.io.{BufferedWriter, File, FileInputStream, FileWriter, IOException, PrintWriter} import com.grammatech.gtirb.proto.IR.IR import com.grammatech.gtirb.proto.Module.Module import com.grammatech.gtirb.proto.Section.Section import spray.json.* import ir.eval import gtirb.* + import scala.collection.mutable.ListBuffer import scala.collection.mutable.ArrayBuffer -import java.io.{File, PrintWriter} -import java.io.{BufferedWriter, FileWriter, IOException} import scala.jdk.CollectionConverters.* import analysis.solvers.* import analysis.* @@ -19,12 +18,14 @@ import ir.* import boogie.* import specification.* import Parsers.* -import Parsers.SemanticsParser.* +import Parsers.ASLpParser.* +import analysis.data_structure_analysis.{DataStructureAnalysis, Graph, SymbolicAddress, SymbolicAddressAnalysis} import org.antlr.v4.runtime.tree.ParseTreeWalker import org.antlr.v4.runtime.BailErrorStrategy import org.antlr.v4.runtime.{CharStreams, CommonTokenStream, Token} import translating.* import util.Logger + import java.util.Base64 import spray.json.DefaultJsonProtocol.* import util.intrusive_list.IntrusiveList @@ -43,6 +44,7 @@ case class IRContext( symbols: List[ELFSymbol], externalFunctions: Set[ExternalFunction], globals: Set[SpecGlobal], + funcEntries: Set[FuncEntry], globalOffsets: Map[BigInt, BigInt], specification: Specification, program: Program // internally mutable @@ -51,17 +53,21 @@ case class IRContext( /** Stores the results of the static analyses. */ case class StaticAnalysisContext( - constPropResult: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], - IRconstPropResult: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], - memoryRegionResult: Map[CFGPosition, LiftedElement[Set[MemoryRegion]]], - vsaResult: Map[CFGPosition, LiftedElement[Map[Variable | MemoryRegion, Set[Value]]]], - interLiveVarsResults: Map[CFGPosition, Map[Variable, TwoElement]], - paramResults: Map[Procedure, Set[Variable]], - steensgaardResults: Map[RegisterVariableWrapper, Set[RegisterVariableWrapper | MemoryRegion]], - mmmResults: MemoryModelMap, - memoryRegionContents: Map[MemoryRegion, Set[BitVecLiteral | MemoryRegion]], - reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])], - varDepsSummaries: Map[Procedure, Map[Taintable, Set[Taintable]]], + intraProcConstProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], + interProcConstProp: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]], + memoryRegionResult: Map[CFGPosition, Set[StackRegion]], + vsaResult: Map[CFGPosition, LiftedElement[Map[Variable | MemoryRegion, Set[Value]]]], + interLiveVarsResults: Map[CFGPosition, Map[Variable, TwoElement]], + paramResults: Map[Procedure, Set[Variable]], + steensgaardResults: Map[RegisterWrapperEqualSets, Set[RegisterWrapperEqualSets | MemoryRegion]], + mmmResults: MemoryModelMap, + reachingDefs: Map[CFGPosition, (Map[Variable, Set[Assign]], Map[Variable, Set[Assign]])], + varDepsSummaries: Map[Procedure, Map[Taintable, Set[Taintable]]], + regionInjector: Option[RegionInjector], + symbolicAddresses: Map[CFGPosition, Map[SymbolicAddress, TwoElement]], + localDSA: Map[Procedure, Graph], + bottomUpDSA: Map[Procedure, Graph], + topDownDSA: Map[Procedure, Graph] ) /** Results of the main program execution. @@ -75,14 +81,14 @@ object IRLoading { /** Create a context from just an IR program. */ def load(p: Program): IRContext = { - IRContext(List.empty, Set.empty, Set.empty, Map.empty, IRLoading.loadSpecification(None, p, Set.empty), p) + IRContext(List.empty, Set.empty, Set.empty, Set.empty, Map.empty, IRLoading.loadSpecification(None, p, Set.empty), p) } /** Load a program from files using the provided configuration. */ def load(q: ILLoadingConfig): IRContext = { // TODO: this tuple is large, should be a case class - val (symbols, externalFunctions, globals, globalOffsets, mainAddress) = IRLoading.loadReadELF(q.relfFile, q) + val (symbols, externalFunctions, globals, funcEntries, globalOffsets, mainAddress) = IRLoading.loadReadELF(q.relfFile, q) val program: Program = if (q.inputFile.endsWith(".adt")) { val bapProgram = loadBAP(q.inputFile) @@ -96,7 +102,7 @@ object IRLoading { val specification = IRLoading.loadSpecification(q.specFile, program, globals) - IRContext(symbols, externalFunctions, globals, globalOffsets, specification, program) + IRContext(symbols, externalFunctions, globals, funcEntries, globalOffsets, specification, program) } def loadBAP(fileName: String): BAPProgram = { @@ -118,9 +124,9 @@ object IRLoading { val semantics = mods.map(_.auxData("ast").data.toStringUtf8.parseJson.convertTo[Map[String, Array[Array[String]]]]) def parse_insn(line: String): StmtContext = { - val semanticsLexer = SemanticsLexer(CharStreams.fromString(line)) - val tokens = CommonTokenStream(semanticsLexer) - val parser = SemanticsParser(tokens) + val lexer = ASLpLexer(CharStreams.fromString(line)) + val tokens = CommonTokenStream(lexer) + val parser = ASLpParser(tokens) parser.setErrorHandler(BailErrorStrategy()) parser.setBuildParseTree(true) @@ -154,7 +160,7 @@ object IRLoading { def loadReadELF( fileName: String, config: ILLoadingConfig - ): (List[ELFSymbol], Set[ExternalFunction], Set[SpecGlobal], Map[BigInt, BigInt], BigInt) = { + ): (List[ELFSymbol], Set[ExternalFunction], Set[SpecGlobal], Set[FuncEntry], Map[BigInt, BigInt], BigInt) = { val lexer = ReadELFLexer(CharStreams.fromFileName(fileName)) val tokens = CommonTokenStream(lexer) val parser = ReadELFParser(tokens) @@ -171,7 +177,7 @@ object IRLoading { specParser.setBuildParseTree(true) val specLoader = SpecificationLoader(globals, program) specLoader.visitSpecification(specParser.specification()) - case None => Specification(globals, Map(), List(), List(), List(), Set()) + case None => Specification(Set(), globals, Map(), List(), List(), List(), Set()) } } } @@ -203,9 +209,7 @@ object IRTransform { cilvisitor.visit_prog(transforms.ConvertSingleReturn(), ctx.program) val externalRemover = ExternalRemover(externalNamesLibRemoved.toSet) - val renamer = Renamer(boogieReserved) externalRemover.visitProgram(ctx.program) - renamer.visitProgram(ctx.program) assert(invariant.singleCallBlockEnd(ctx.program)) assert(invariant.cfgCorrect(ctx.program)) @@ -216,24 +220,31 @@ object IRTransform { /** Cull unneccessary information that does not need to be included in the translation, and infer stack regions, and * add in modifies from the spec. */ - def prepareForTranslation(config: ILLoadingConfig, ctx: IRContext): Unit = { - ctx.program.determineRelevantMemory(ctx.globalOffsets) - transforms.applyRPO(ctx.program) + def prepareForTranslation(config: BASILConfig, ctx: IRContext): Unit = { + if (!config.staticAnalysis.isDefined || !config.staticAnalysis.get.memoryRegions) { + ctx.program.determineRelevantMemory(ctx.globalOffsets) + } Logger.info("[!] Stripping unreachable") val before = ctx.program.procedures.size - transforms.stripUnreachableFunctions(ctx.program, config.procedureTrimDepth) - Logger.info( + transforms.stripUnreachableFunctions(ctx.program, config.loading.procedureTrimDepth) + Logger.debug( s"[!] Removed ${before - ctx.program.procedures.size} functions (${ctx.program.procedures.size} remaining)" ) - val dupProcNames = (ctx.program.procedures.groupBy(_.name).filter((n,p) => p.size > 1)).toList.flatMap(_._2) + val dupProcNames = ctx.program.procedures.groupBy(_.name).filter((_, p) => p.size > 1).toList.flatMap(_(1)) assert(dupProcNames.isEmpty) - val stackIdentification = StackSubstituter() - stackIdentification.visitProgram(ctx.program) + if (!config.staticAnalysis.isDefined || !config.staticAnalysis.get.memoryRegions) { + val stackIdentification = StackSubstituter() + stackIdentification.visitProgram(ctx.program) + } val specModifies = ctx.specification.subroutines.map(s => s.name -> s.modifies).toMap ctx.program.setModifies(specModifies) + + val renamer = Renamer(boogieReserved) + renamer.visitProgram(ctx.program) + assert(invariant.singleCallBlockEnd(ctx.program)) } @@ -277,7 +288,8 @@ object StaticAnalysis { def analyse( ictx: IRContext, config: StaticAnalysisConfig, - iteration: Int + iteration: Int, + previousResults: Option[StaticAnalysisContext] = None ): StaticAnalysisContext = { var ctx = ictx val IRProgram: Program = ctx.program @@ -296,11 +308,14 @@ object StaticAnalysis { .map(p => p.address.get -> p.name) .toMap val globalAddresses = globals.map(s => s.address -> s.name).toMap + val globalSizes = globals.map(s => s.name -> s.size).toMap val externalAddresses = externalFunctions.map(e => e.offset -> e.name).toMap Logger.debug("Globals:") Logger.debug(globalAddresses) Logger.debug("Global Offsets: ") Logger.debug(globalOffsets) + Logger.debug("Global Sizes: ") + Logger.debug(globalSizes) Logger.debug("External: ") Logger.debug(externalAddresses) Logger.debug("Subroutine Addresses:") @@ -310,11 +325,11 @@ object StaticAnalysis { // reducible loops val detector = LoopDetector(IRProgram) val foundLoops = detector.identify_loops() - foundLoops.foreach(l => Logger.debug(s"Loop found: ${l.name}")) + foundLoops.foreach(l => Logger.info(s"Loop found: ${l.name}")) val transformer = LoopTransform(foundLoops) val newLoops = transformer.llvm_transform() - newLoops.foreach(l => Logger.debug(s"Loop found: ${l.name}")) + newLoops.foreach(l => Logger.info(s"Loop found: ${l.name}")) config.analysisDotPath.foreach { s => writeToFile(dotBlockGraph(IRProgram, IRProgram.map(b => b -> b.toString).toMap), s"${s}_graph-after-reduce-$iteration.dot") @@ -324,80 +339,70 @@ object StaticAnalysis { val mergedSubroutines = subroutines ++ externalAddresses val domain = computeDomain(IntraProcIRCursor, IRProgram.procedures) + val interDomain = computeDomain(InterProcIRCursor, IRProgram.procedures) - Logger.debug("[!] Running ANR") + Logger.info("[!] Running ANR") val ANRSolver = ANRAnalysisSolver(IRProgram) val ANRResult = ANRSolver.analyze() - Logger.debug("[!] Running RNA") + Logger.info("[!] Running RNA") val RNASolver = RNAAnalysisSolver(IRProgram) val RNAResult = RNASolver.analyze() - config.analysisResultsPath.foreach(s => - writeToFile(printAnalysisResults(IRProgram, ANRResult), s"${s}-anr-result$iteration.txt") - ) - config.analysisResultsPath.foreach(s => - writeToFile(printAnalysisResults(IRProgram, RNAResult), s"${s}-rna-result$iteration.txt") - ) + Logger.info("[!] Running Inter-procedural Constant Propagation") + val interProcConstProp = InterProcConstantPropagation(IRProgram) + val interProcConstPropResult: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]] = interProcConstProp.analyze() - Logger.debug("[!] Running Constant Propagation") - val constPropSolver = ConstantPropagationSolver(IRProgram) - val constPropResult: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]] = constPropSolver.analyze() + config.analysisResultsPath.foreach { s => + writeToFile(printAnalysisResults(IRProgram, interProcConstPropResult), s"${s}OGconstprop$iteration.txt") + } - Logger.debug("[!] Variable dependency summaries") + Logger.info("[!] Variable dependency summaries") val scc = stronglyConnectedComponents(CallGraph, List(IRProgram.mainProcedure)) val specGlobalAddresses = ctx.specification.globals.map(s => s.address -> s.name).toMap - val varDepsSummaries = VariableDependencyAnalysis(IRProgram, ctx.specification.globals, specGlobalAddresses, constPropResult, scc).analyze() + val varDepsSummaries = VariableDependencyAnalysis(IRProgram, ctx.specification.globals, specGlobalAddresses, interProcConstPropResult, scc).analyze() - val ilcpsolver = IRSimpleValueAnalysis.Solver(IRProgram) - val newCPResult: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]] = ilcpsolver.analyze() + val intraProcConstProp = IntraProcConstantPropagation(IRProgram) + val intraProcConstPropResult: Map[CFGPosition, Map[Variable, FlatElement[BitVecLiteral]]] = intraProcConstProp.analyze() - config.analysisResultsPath.foreach(s => - writeToFile(printAnalysisResults(IRProgram, newCPResult), s"${s}_new_ir_constprop$iteration.txt") - ) + config.analysisResultsPath.foreach { s => + writeToFile(printAnalysisResults(IRProgram, intraProcConstPropResult), s"${s}_new_ir_constprop$iteration.txt") + } - config.analysisDotPath.foreach(f => { - val dumpdomain = computeDomain[CFGPosition, CFGPosition](InterProcIRCursor, IRProgram.procedures).toSet - writeToFile(toDot(dumpdomain, InterProcIRCursor, Map.empty), s"${f}_new_ir_intercfg$iteration.dot") - }) + config.analysisDotPath.foreach { f => + val dumpdomain = computeDomain[CFGPosition, CFGPosition](InterProcIRCursor, IRProgram.procedures) + writeToFile(toDot(dumpdomain.toSet, InterProcIRCursor, Map.empty), s"${f}_new_ir_intercfg$iteration.dot") + } - val reachingDefinitionsAnalysisSolver = ReachingDefinitionsAnalysisSolver(IRProgram) + val reachingDefinitionsAnalysisSolver = InterprocReachingDefinitionsAnalysisSolver(IRProgram) val reachingDefinitionsAnalysisResults = reachingDefinitionsAnalysisSolver.analyze() - - config.analysisDotPath.foreach(s => { + config.analysisDotPath.foreach { s => writeToFile( - toDot(IRProgram, IRProgram.filter(_.isInstanceOf[Command]).map(b => b -> reachingDefinitionsAnalysisResults(b).toString).toMap), + toDot(IRProgram, IRProgram.filter(_.isInstanceOf[Command]).map(b => b -> reachingDefinitionsAnalysisResults(b).toString).toMap, true), s"${s}_reachingDefinitions$iteration.dot" ) - }) - - - Logger.debug("[!] Running RegToMemAnalysisSolver") - val regionAccessesAnalysisSolver = RegionAccessesAnalysisSolver(IRProgram, constPropResult, reachingDefinitionsAnalysisResults) - val regionAccessesAnalysisResults = regionAccessesAnalysisSolver.analyze() - -// config.analysisDotPath.foreach(s => writeToFile(cfg.toDot(Output.labeler(regionAccessesAnalysisResults, true), Output.dotIder), s"${s}_RegTo$iteration.dot")) - config.analysisResultsPath.foreach(s => writeToFile(printAnalysisResults(IRProgram, regionAccessesAnalysisResults), s"${s}_RegTo$iteration.txt")) - config.analysisDotPath.foreach(s => { - writeToFile( - toDot(IRProgram, IRProgram.filter(_.isInstanceOf[Command]).map(b => b -> regionAccessesAnalysisResults(b).toString).toMap), - s"${s}_RegTo$iteration.dot" - ) - }) + } + val mmm = MemoryModelMap(globalOffsets) + mmm.preLoadGlobals(mergedSubroutines, globalAddresses, globalSizes) - Logger.debug("[!] Running Constant Propagation with SSA") - val constPropSolverWithSSA = ConstantPropagationSolverWithSSA(IRProgram, reachingDefinitionsAnalysisResults) - val constPropResultWithSSA = constPropSolverWithSSA.analyze() + val previousVSAResults = if (previousResults.isDefined) { + previousResults.get.vsaResult + } else { + Map[CFGPosition, LiftedElement[Map[Variable | MemoryRegion, Set[Value]]]]() + } + Logger.info("[!] Running GRA") + val graSolver = GlobalRegionAnalysisSolver(IRProgram, domain.toSet, interProcConstPropResult, reachingDefinitionsAnalysisResults, mmm, previousVSAResults) + val graResult = graSolver.analyze() - Logger.debug("[!] Running MRA") - val mraSolver = MemoryRegionAnalysisSolver(IRProgram, globalAddresses, globalOffsets, mergedSubroutines, constPropResult, ANRResult, RNAResult, regionAccessesAnalysisResults, reachingDefinitionsAnalysisResults) + Logger.info("[!] Running MRA") + val mraSolver = MemoryRegionAnalysisSolver(IRProgram, domain.toSet, globalAddresses, globalOffsets, mergedSubroutines, interProcConstPropResult, ANRResult, RNAResult, reachingDefinitionsAnalysisResults, graResult, mmm) val mraResult = mraSolver.analyze() - config.analysisDotPath.foreach(s => { + config.analysisDotPath.foreach { s => writeToFile(dotCallGraph(IRProgram), s"${s}_callgraph$iteration.dot") writeToFile( dotBlockGraph(IRProgram, IRProgram.filter(_.isInstanceOf[Block]).map(b => b -> b.toString).toMap), @@ -405,7 +410,7 @@ object StaticAnalysis { ) writeToFile( - toDot(IRProgram, IRProgram.filter(_.isInstanceOf[Command]).map(b => b -> newCPResult(b).toString).toMap), + toDot(IRProgram, IRProgram.filter(_.isInstanceOf[Command]).map(b => b -> intraProcConstPropResult(b).toString).toMap), s"${s}_new_ir_constprop$iteration.dot" ) @@ -413,55 +418,64 @@ object StaticAnalysis { toDot(IRProgram, IRProgram.filter(_.isInstanceOf[Command]).map(b => b -> mraResult(b).toString).toMap), s"${s}_MRA$iteration.dot" ) - }) + + writeToFile( + toDot(IRProgram, IRProgram.filter(_.isInstanceOf[Command]).map(b => b -> graResult(b).toString).toMap), + s"${s}_GRA$iteration.dot" + ) + } Logger.debug("[!] Running MMM") - val mmm = MemoryModelMap() - mmm.convertMemoryRegions(mraResult, mergedSubroutines, globalOffsets, mraSolver.procedureToSharedRegions) + mmm.convertMemoryRegions(mraSolver.procedureToStackRegions, mraSolver.procedureToHeapRegions, mraResult, mraSolver.procedureToSharedRegions, graSolver.getDataMap, graResult) mmm.logRegions() Logger.debug("[!] Running Steensgaard") - val steensgaardSolver = InterprocSteensgaardAnalysis(IRProgram, constPropResultWithSSA, regionAccessesAnalysisResults, mmm, reachingDefinitionsAnalysisResults, globalOffsets) + val steensgaardSolver = InterprocSteensgaardAnalysis(interDomain.toSet, mmm, reachingDefinitionsAnalysisResults, previousVSAResults) steensgaardSolver.analyze() val steensgaardResults = steensgaardSolver.pointsTo() - val memoryRegionContents = steensgaardSolver.getMemoryRegionContents - mmm.logRegions(memoryRegionContents) - // turn fake procedures into diamonds Logger.debug("[!] Running VSA") - val vsaSolver = ValueSetAnalysisSolver(IRProgram, globalAddresses, externalAddresses, globalOffsets, subroutines, mmm, constPropResult) + val vsaSolver = ValueSetAnalysisSolver(IRProgram, mmm, interProcConstPropResult) val vsaResult: Map[CFGPosition, LiftedElement[Map[Variable | MemoryRegion, Set[Value]]]] = vsaSolver.analyze() - var paramResults: Map[Procedure, Set[Variable]] = Map.empty - var interLiveVarsResults: Map[CFGPosition, Map[Variable, TwoElement]] = Map.empty - - if (IRProgram.mainProcedure.blocks.nonEmpty && IRProgram.mainProcedure.returnBlock.isDefined && IRProgram.mainProcedure.entryBlock.isDefined) { - Logger.debug("[!] Running Interprocedural Live Variables Analysis") - interLiveVarsResults = InterLiveVarsAnalysis(IRProgram).analyze() - - Logger.debug("[!] Running Parameter Analysis") - paramResults = ParamAnalysis(IRProgram).analyze() + config.analysisDotPath.foreach { s => + writeToFile( + toDot(IRProgram, IRProgram.filter(_.isInstanceOf[Command]).map(b => b -> vsaResult(b).toString).toMap), + s"${s}_VSA$iteration.dot" + ) + } + Logger.debug("[!] Injecting regions") + val regionInjector = if (config.memoryRegions) { + val injector = RegionInjector(IRProgram, mmm) + injector.nodeVisitor() + Some(injector) } else { - Logger.warn(s"Disabling IDE solver tests due to external main procedure: ${IRProgram.mainProcedure.name}") + None } + val paramResults: Map[Procedure, Set[Variable]] = ParamAnalysis(IRProgram).analyze() + val interLiveVarsResults: Map[CFGPosition, Map[Variable, TwoElement]] = InterLiveVarsAnalysis(IRProgram).analyze() + StaticAnalysisContext( - constPropResult = constPropResult, - IRconstPropResult = newCPResult, + intraProcConstProp = interProcConstPropResult, + interProcConstProp = intraProcConstPropResult, memoryRegionResult = mraResult, vsaResult = vsaResult, interLiveVarsResults = interLiveVarsResults, paramResults = paramResults, steensgaardResults = steensgaardResults, mmmResults = mmm, - memoryRegionContents = memoryRegionContents, + symbolicAddresses = Map.empty, reachingDefs = reachingDefinitionsAnalysisResults, varDepsSummaries = varDepsSummaries, + regionInjector = regionInjector, + localDSA = Map.empty, + bottomUpDSA = Map.empty, + topDownDSA = Map.empty, ) } - def printAnalysisResults(prog: Program, result: Map[CFGPosition, _]): String = { val results = mutable.ArrayBuffer[String]() val toVisit = mutable.Stack[CFGPosition]() @@ -527,7 +541,7 @@ object RunUtils { // writeToFile(dotBlockGraph(ctx.program, ctx.program.filter(_.isInstanceOf[Block]).map(b => b -> b.toString).toMap), s"blockgraph-before-simp.dot") Logger.info("[!] Running Simplify") val timer = PerformanceTimer("Simplify") - val write = false + val write = true transforms.applyRPO(ctx.program) @@ -593,8 +607,6 @@ object RunUtils { // re-apply dsa // transforms.OnePassDSA().applyTransform(ctx.program) - Logger.info("writing") - if write then writeToFile(translating.BasilIRPrettyPrinter()(ctx.program), "prettyprinted.il") if (ir.eval.SimplifyValidation.validate) { @@ -647,8 +659,10 @@ object RunUtils { assert(invariant.correctCalls(ctx.program)) q.loading.dumpIL.foreach(s => writeToFile(serialiseIL(ctx.program), s"$s-before-analysis.il")) - val analysis = q.staticAnalysis.map(conf => staticAnalysis(conf, ctx)) - q.loading.dumpIL.foreach(s => writeToFile(serialiseIL(ctx.program), s"$s-after-all-analysis.il")) + val analysis = q.staticAnalysis.map { + conf => staticAnalysis(conf, ctx) + } + q.loading.dumpIL.foreach(s => writeToFile(serialiseIL(ctx.program), s"$s-after-analysis.il")) if (q.runInterpret) { val fs = eval.interpretTrace(ctx) @@ -661,21 +675,23 @@ object RunUtils { } } - IRTransform.prepareForTranslation(q.loading, ctx) + IRTransform.prepareForTranslation(q, ctx) Logger.info("[!] Translating to Boogie") + val regionInjector = analysis.flatMap(a => a.regionInjector) + val boogiePrograms = if (q.boogieTranslation.threadSplit && ctx.program.threads.nonEmpty) { val outPrograms = ArrayBuffer[BProgram]() for (thread <- ctx.program.threads) { val fileName = q.outputPrefix.stripSuffix(".bpl") + "_" + thread.entry.name + ".bpl" - val boogieTranslator = IRToBoogie(ctx.program, ctx.specification, Some(thread), fileName) - outPrograms.addOne(boogieTranslator.translate(q.boogieTranslation)) + val boogieTranslator = IRToBoogie(ctx.program, ctx.specification, Some(thread), fileName, regionInjector, q.boogieTranslation) + outPrograms.addOne(boogieTranslator.translate) } outPrograms } else { - val boogieTranslator = IRToBoogie(ctx.program, ctx.specification, None, q.outputPrefix) - ArrayBuffer(boogieTranslator.translate(q.boogieTranslation)) + val boogieTranslator = IRToBoogie(ctx.program, ctx.specification, None, q.outputPrefix, regionInjector, q.boogieTranslation) + ArrayBuffer(boogieTranslator.translate) } assert(invariant.singleCallBlockEnd(ctx.program)) @@ -688,21 +704,31 @@ object RunUtils { var iteration = 1 var modified: Boolean = true val analysisResult = mutable.ArrayBuffer[StaticAnalysisContext]() - while (modified) { + while (modified || (analysisResult.size < 2 && config.memoryRegions)) { Logger.debug("[!] Running Static Analysis") - val result = StaticAnalysis.analyse(ctx, config, iteration) + val result = StaticAnalysis.analyse(ctx, config, iteration, analysisResult.lastOption) analysisResult.append(result) Logger.debug("[!] Replacing Indirect Calls") - modified = transforms.resolveIndirectCallsUsingPointsTo( + + /* + modified = transforms.SteensgaardIndirectCallResolution( + ctx.program, result.steensgaardResults, - result.memoryRegionContents, - result.reachingDefs, - ctx.program - ) + result.reachingDefs + ).resolveIndirectCalls() + */ + + modified = transforms.VSAIndirectCallResolution( + ctx.program, + result.vsaResult, + result.mmmResults + ).resolveIndirectCalls() + Logger.debug("[!] Generating Procedure Summaries") if (config.summariseProcedures) { - IRTransform.generateProcedureSummaries(ctx, ctx.program, result.constPropResult, result.varDepsSummaries) + IRTransform.generateProcedureSummaries(ctx, ctx.program, result.intraProcConstProp, result.varDepsSummaries) } + if (modified) { iteration += 1 Logger.debug(s"[!] Analysing again (iter $iteration)") @@ -712,12 +738,42 @@ object RunUtils { // should later move this to be inside while (modified) loop and have splitting threads cause further iterations if (config.threadSplit) { - transforms.splitThreads(ctx.program, analysisResult.last.steensgaardResults, analysisResult.last.memoryRegionContents, analysisResult.last.reachingDefs) + transforms.splitThreads(ctx.program, analysisResult.last.steensgaardResults, analysisResult.last.reachingDefs) + } + + Logger.debug("[!] Running Writes To") + val writesTo = WriteToAnalysis(ctx.program).analyze() + val reachingDefs = ReachingDefsAnalysis(ctx.program, writesTo).analyze() + config.analysisDotPath.foreach { s => + writeToFile(toDot(ctx.program), s"${s}_ct.dot") + } + + Logger.debug("[!] Running Symbolic Access Analysis") + val symResults: Map[CFGPosition, Map[SymbolicAddress, TwoElement]] = + SymbolicAddressAnalysis(ctx.program, analysisResult.last.interProcConstProp).analyze() + config.analysisDotPath.foreach { s => + val labels = symResults.map { (k, v) => k -> v.toString } + writeToFile(toDot(ctx.program, labels), s"${s}_saa.dot") + } + + Logger.debug("[!] Running DSA Analysis") + val symbolTableEntries: Set[SymbolTableEntry] = ctx.globals ++ ctx.funcEntries + val dsa = DataStructureAnalysis(ctx.program, symResults, analysisResult.last.interProcConstProp, symbolTableEntries, ctx.globalOffsets, ctx.externalFunctions, reachingDefs, writesTo, analysisResult.last.paramResults) + dsa.analyze() + + config.analysisDotPath.foreach { s => + dsa.topDown(ctx.program.mainProcedure).toDot + writeToFile(dsa.topDown(ctx.program.mainProcedure).toDot, s"${s}_main_dsg.dot") } assert(invariant.singleCallBlockEnd(ctx.program)) Logger.debug(s"[!] Finished indirect call resolution after $iteration iterations") - analysisResult.last + analysisResult.last.copy( + symbolicAddresses = symResults, + localDSA = dsa.local.toMap, + bottomUpDSA = dsa.bottomUp.toMap, + topDownDSA = dsa.topDown.toMap + ) } } diff --git a/src/test/correct/arrays_simple/clang/arrays_simple.expected b/src/test/correct/arrays_simple/clang/arrays_simple.expected index 935475caa..73aa783a4 100644 --- a/src/test/correct/arrays_simple/clang/arrays_simple.expected +++ b/src/test/correct/arrays_simple/clang/arrays_simple.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1872bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,23 +27,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1872bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1873bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1874bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1875bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1872bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -58,8 +44,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -72,40 +58,42 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_stack, R0, R31, R8, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1872bv64) == 1bv8); - free requires (memory_load8_le(mem, 1873bv64) == 0bv8); - free requires (memory_load8_le(mem, 1874bv64) == 2bv8); - free requires (memory_load8_le(mem, 1875bv64) == 0bv8); + free requires (memory_load32_le(mem, 1872bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1872bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1873bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1874bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1875bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1872bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var R8_3: bv64; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 7bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R8_3[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R8_3); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + R8, Gamma_R8 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "%0000089b"} true; + R8, Gamma_R8 := 7bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "%000008a8"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%000008b7"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R31_out, R8_out := 0bv64, R31_in, R8_3; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := true, Gamma_R31_in, Gamma_R8_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/arrays_simple/clang/arrays_simple_gtirb.expected b/src/test/correct/arrays_simple/clang/arrays_simple_gtirb.expected index 5750f6268..eda5cac95 100644 --- a/src/test/correct/arrays_simple/clang/arrays_simple_gtirb.expected +++ b/src/test/correct/arrays_simple/clang/arrays_simple_gtirb.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1872bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,23 +27,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1872bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1873bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1874bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1875bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1872bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -58,8 +44,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -72,40 +58,42 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_stack, R0, R31, R8, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1872bv64) == 1bv8); - free requires (memory_load8_le(mem, 1873bv64) == 0bv8); - free requires (memory_load8_le(mem, 1874bv64) == 2bv8); - free requires (memory_load8_le(mem, 1875bv64) == 0bv8); + free requires (memory_load32_le(mem, 1872bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1872bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1873bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1874bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1875bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1872bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var R8_3: bv64; $main$__0__$hLpmd_ERQq2v3Sj7g4WZPA: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 7bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R8_3[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R8_3); + assume {:captureState "$main$__0__$hLpmd_ERQq2v3Sj7g4WZPA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + R8, Gamma_R8 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "1820$0"} true; + R8, Gamma_R8 := 7bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "1828$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1836$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R31_out, R8_out := 0bv64, R31_in, R8_3; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := true, Gamma_R31_in, Gamma_R8_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_read/clang/basic_arrays_read.expected b/src/test/correct/basic_arrays_read/clang/basic_arrays_read.expected index 716685b0b..1fcc04f91 100644 --- a/src/test/correct/basic_arrays_read/clang/basic_arrays_read.expected +++ b/src/test/correct/basic_arrays_read/clang/basic_arrays_read.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +31,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +40,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -85,43 +71,41 @@ implementation {:extern} guarantee_reflexive() assert true; } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_mem, Gamma_stack, R0, R31, R8, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var R0_1: bv64; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002d1"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 0bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert true; + assert (L(mem, bvadd64(R8, 52bv64)) ==> true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), true); + assume {:captureState "%000002dd"} true; call rely(); - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, 69632bv64; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_read/clang/basic_arrays_read_gtirb.expected b/src/test/correct/basic_arrays_read/clang/basic_arrays_read_gtirb.expected index 74d0755c3..f4cde0c06 100644 --- a/src/test/correct/basic_arrays_read/clang/basic_arrays_read_gtirb.expected +++ b/src/test/correct/basic_arrays_read/clang/basic_arrays_read_gtirb.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +31,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +40,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -85,43 +71,41 @@ implementation {:extern} guarantee_reflexive() assert true; } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_mem, Gamma_stack, R0, R31, R8, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var R0_1: bv64; $main$__0__$nH8DWmocTJOsal3tXpRbMg: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$nH8DWmocTJOsal3tXpRbMg"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1816$0"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 0bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert true; + assert (L(mem, bvadd64(R8, 52bv64)) ==> true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), true); + assume {:captureState "1824$0"} true; call rely(); - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, 69632bv64; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read.expected b/src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read.expected index 792bc6066..b97a02fe9 100644 --- a/src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read.expected +++ b/src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read.expected @@ -1,23 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +24,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +35,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -55,15 +44,12 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); - free ensures (memory_load8_le(mem, 1928bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1929bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1930bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1931bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1928bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -90,49 +76,45 @@ implementation {:extern} guarantee_reflexive() assert true; } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_mem, Gamma_stack, R0, R31, R8, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1928bv64) == 1bv8); - free requires (memory_load8_le(mem, 1929bv64) == 0bv8); - free requires (memory_load8_le(mem, 1930bv64) == 2bv8); - free requires (memory_load8_le(mem, 1931bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1928bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69584bv64) == 1876bv64); free requires (memory_load64_le(mem, 69592bv64) == 69684bv64); - free ensures (memory_load8_le(mem, 1928bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1929bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1930bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1931bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1928bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_2: bool; - var R0_1: bv64; - var R8_2: bv64; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002d5"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4056bv64)) || L(mem, bvadd64(R8, 4056bv64))); call rely(); - assert (L(mem, R8_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R8_2, 0bv32), gamma_store32(Gamma_mem, R8_2, true); - assert true; + assert (L(mem, R8) ==> true); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); + assume {:captureState "%000002e8"} true; call rely(); - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(mem, R8_2)), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_2; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read_gtirb.expected b/src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read_gtirb.expected index 56818db04..36598de3f 100644 --- a/src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read_gtirb.expected +++ b/src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read_gtirb.expected @@ -1,23 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +24,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +35,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -55,15 +44,12 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); - free ensures (memory_load8_le(mem, 1928bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1929bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1930bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1931bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1928bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -90,49 +76,45 @@ implementation {:extern} guarantee_reflexive() assert true; } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_mem, Gamma_stack, R0, R31, R8, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1928bv64) == 1bv8); - free requires (memory_load8_le(mem, 1929bv64) == 0bv8); - free requires (memory_load8_le(mem, 1930bv64) == 2bv8); - free requires (memory_load8_le(mem, 1931bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1928bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69584bv64) == 1876bv64); free requires (memory_load64_le(mem, 69592bv64) == 69684bv64); - free ensures (memory_load8_le(mem, 1928bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1929bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1930bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1931bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1928bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_2: bool; - var R0_1: bv64; - var R8_2: bv64; $main$__0__$CGPwXKgfQxikvfXy7SP7PQ: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$CGPwXKgfQxikvfXy7SP7PQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1880$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4056bv64)) || L(mem, bvadd64(R8, 4056bv64))); call rely(); - assert (L(mem, R8_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R8_2, 0bv32), gamma_store32(Gamma_mem, R8_2, true); - assert true; + assert (L(mem, R8) ==> true); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); + assume {:captureState "1892$0"} true; call rely(); - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(mem, R8_2)), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_2; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_read/gcc/basic_arrays_read.expected b/src/test/correct/basic_arrays_read/gcc/basic_arrays_read.expected index 06ed110fa..7c0e78f1a 100644 --- a/src/test/correct/basic_arrays_read/gcc/basic_arrays_read.expected +++ b/src/test/correct/basic_arrays_read/gcc/basic_arrays_read.expected @@ -1,31 +1,20 @@ +var {:extern} Gamma_R0: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,12 +25,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -49,10 +34,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -83,42 +65,38 @@ implementation {:extern} guarantee_reflexive() assert true; } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_mem, R0, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool) +implementation main() { - var Gamma_R0_6: bool; - var R0_6: bv64; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 0bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert true; + assert (L(mem, R0) ==> true); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assume {:captureState "%000002d6"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := zero_extend32_32(memory_load32_le(mem, 69656bv64)), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); goto main_basil_return; main_basil_return: - R0_out := R0_6; - Gamma_R0_out := Gamma_R0_6; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_read/gcc/basic_arrays_read_gtirb.expected b/src/test/correct/basic_arrays_read/gcc/basic_arrays_read_gtirb.expected index ad7c2f46a..c0bf7949f 100644 --- a/src/test/correct/basic_arrays_read/gcc/basic_arrays_read_gtirb.expected +++ b/src/test/correct/basic_arrays_read/gcc/basic_arrays_read_gtirb.expected @@ -1,31 +1,20 @@ +var {:extern} Gamma_R0: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,12 +25,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -49,10 +34,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -83,42 +65,38 @@ implementation {:extern} guarantee_reflexive() assert true; } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_mem, R0, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool) +implementation main() { - var Gamma_R0_6: bool; - var R0_6: bv64; $main$__0__$LzETjB03RAicd22wmYTXcg: + assume {:captureState "$main$__0__$LzETjB03RAicd22wmYTXcg"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 0bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert true; + assert (L(mem, R0) ==> true); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assume {:captureState "1820$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := zero_extend32_32(memory_load32_le(mem, 69656bv64)), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); goto main_basil_return; main_basil_return: - R0_out := R0_6; - Gamma_R0_out := Gamma_R0_6; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read.expected b/src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read.expected index d2d8c7995..99eaf7326 100644 --- a/src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read.expected +++ b/src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read.expected @@ -1,21 +1,14 @@ +var {:extern} Gamma_R0: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -25,11 +18,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +29,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,15 +38,12 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); - free ensures (memory_load8_le(mem, 1924bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1925bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1926bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1927bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1924bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69608bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69616bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -88,52 +70,42 @@ implementation {:extern} guarantee_reflexive() assert true; } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_mem, R0, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1924bv64) == 1bv8); - free requires (memory_load8_le(mem, 1925bv64) == 0bv8); - free requires (memory_load8_le(mem, 1926bv64) == 2bv8); - free requires (memory_load8_le(mem, 1927bv64) == 0bv8); + free requires (memory_load32_le(mem, 1924bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69608bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69616bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1924bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1925bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1926bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1927bv64) == 0bv8); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1924bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69608bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69616bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var R0_3: bv64; - var R0_5: bv64; - var R0_6: bv64; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69616bv64), (gamma_load64(Gamma_mem, 69616bv64) || L(mem, 69616bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4080bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4080bv64)) || L(mem, bvadd64(R0, 4080bv64))); call rely(); - assert (L(mem, R0_3) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 0bv32), gamma_store32(Gamma_mem, R0_3, true); - assert true; + assert (L(mem, R0) ==> true); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assume {:captureState "%000002d7"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69616bv64), (gamma_load64(Gamma_mem, 69616bv64) || L(mem, 69616bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4080bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4080bv64)) || L(mem, bvadd64(R0, 4080bv64))); call rely(); - R0_6, Gamma_R0_6 := zero_extend32_32(memory_load32_le(mem, R0_5)), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); goto main_basil_return; main_basil_return: - R0_out := R0_6; - Gamma_R0_out := Gamma_R0_6; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read_gtirb.expected b/src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read_gtirb.expected index 02345e659..9015de36a 100644 --- a/src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read_gtirb.expected +++ b/src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read_gtirb.expected @@ -1,21 +1,14 @@ +var {:extern} Gamma_R0: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -25,11 +18,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +29,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,15 +38,12 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); - free ensures (memory_load8_le(mem, 1924bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1925bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1926bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1927bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1924bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69608bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69616bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -88,52 +70,42 @@ implementation {:extern} guarantee_reflexive() assert true; } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_mem, R0, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1924bv64) == 1bv8); - free requires (memory_load8_le(mem, 1925bv64) == 0bv8); - free requires (memory_load8_le(mem, 1926bv64) == 2bv8); - free requires (memory_load8_le(mem, 1927bv64) == 0bv8); + free requires (memory_load32_le(mem, 1924bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69608bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69616bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1924bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1925bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1926bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1927bv64) == 0bv8); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1924bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69608bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69616bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var R0_3: bv64; - var R0_5: bv64; - var R0_6: bv64; $main$__0__$H8IsYbn_SQGlYyUfKVFdig: + assume {:captureState "$main$__0__$H8IsYbn_SQGlYyUfKVFdig"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69616bv64), (gamma_load64(Gamma_mem, 69616bv64) || L(mem, 69616bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4080bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4080bv64)) || L(mem, bvadd64(R0, 4080bv64))); call rely(); - assert (L(mem, R0_3) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 0bv32), gamma_store32(Gamma_mem, R0_3, true); - assert true; + assert (L(mem, R0) ==> true); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assume {:captureState "1884$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69616bv64), (gamma_load64(Gamma_mem, 69616bv64) || L(mem, 69616bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4080bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4080bv64)) || L(mem, bvadd64(R0, 4080bv64))); call rely(); - R0_6, Gamma_R0_6 := zero_extend32_32(memory_load32_le(mem, R0_5)), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); goto main_basil_return; main_basil_return: - R0_out := R0_6; - Gamma_R0_out := Gamma_R0_6; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_write/clang/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/clang/basic_arrays_write.expected index 7dfbd5004..02898a966 100644 --- a/src/test/correct/basic_arrays_write/clang/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/clang/basic_arrays_write.expected @@ -1,33 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +33,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +42,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -85,45 +73,46 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R31, R8, R9, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_1: bool; - var R8_1: bv64; var arr$0_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - R8_1, Gamma_R8_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R9, Gamma_R9 := 69632bv64, true; + R9, Gamma_R9 := bvadd64(R9, 52bv64), Gamma_R9; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002e5"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_1); + assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%000002f4"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R31_out, R8_out, R9_out := 0bv64, R31_in, R8_1, 69684bv64; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R31_in, Gamma_R8_1, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_write/clang/basic_arrays_write_gtirb.expected b/src/test/correct/basic_arrays_write/clang/basic_arrays_write_gtirb.expected index fa3b94a80..c0e68cb5f 100644 --- a/src/test/correct/basic_arrays_write/clang/basic_arrays_write_gtirb.expected +++ b/src/test/correct/basic_arrays_write/clang/basic_arrays_write_gtirb.expected @@ -1,33 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +33,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +42,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -85,45 +73,46 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R31, R8, R9, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_1: bool; - var R8_1: bv64; var arr$0_old: bv32; $main$__0__$pfAb81AKR8CuFLyGhCrxEg: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - R8_1, Gamma_R8_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__0__$pfAb81AKR8CuFLyGhCrxEg"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R9, Gamma_R9 := 69632bv64, true; + R9, Gamma_R9 := bvadd64(R9, 52bv64), Gamma_R9; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1824$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_1); + assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "1832$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R31_out, R8_out, R9_out := 0bv64, R31_in, R8_1, 69684bv64; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R31_in, Gamma_R8_1, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write.expected index 8b2b7f93c..cd666691a 100644 --- a/src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write.expected @@ -1,27 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,12 +25,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -45,10 +34,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -79,44 +65,39 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_1: bool; - var R8_1: bv64; var arr$0_old: bv32; lmain: - R8_1, Gamma_R8_1 := zero_extend32_32(R0_in[32:0]), Gamma_R0_in; + assume {:captureState "lmain"} true; + R8, Gamma_R8 := zero_extend32_32(R0[32:0]), Gamma_R0; + R9, Gamma_R9 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_1); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%000002d4"} true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_1, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_1, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write_gtirb.expected b/src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write_gtirb.expected index 5e9987b5e..7b61c3082 100644 --- a/src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write_gtirb.expected +++ b/src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write_gtirb.expected @@ -1,27 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,12 +25,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -45,10 +34,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -79,44 +65,39 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_1: bool; - var R8_1: bv64; var arr$0_old: bv32; $main$__0__$9B_32roeToOuqgp1UmQUlw: - R8_1, Gamma_R8_1 := zero_extend32_32(R0_in[32:0]), Gamma_R0_in; + assume {:captureState "$main$__0__$9B_32roeToOuqgp1UmQUlw"} true; + R8, Gamma_R8 := zero_extend32_32(R0[32:0]), Gamma_R0; + R9, Gamma_R9 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_1); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "1824$0"} true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_1, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_1, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write.expected index 013c01046..a9469c047 100644 --- a/src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write.expected @@ -1,23 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +26,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -55,15 +46,12 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -90,51 +78,49 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R31, R8, R9, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69584bv64) == 1876bv64); free requires (memory_load64_le(mem, 69592bv64) == 69684bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_1: bool; - var Gamma_R9_2: bool; - var R8_1: bv64; - var R9_2: bv64; var arr$0_old: bv32; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - R8_1, Gamma_R8_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4056bv64)) || L(mem, bvadd64(R9, 4056bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002e6"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, bvadd64(R9_2, 4bv64)) ==> Gamma_R8_1); + assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); - mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9_2, 4bv64), R8_1[32:0]), gamma_store32(Gamma_mem, bvadd64(R9_2, 4bv64), Gamma_R8_1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%000002f5"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R31_out, R8_out, R9_out := 0bv64, R31_in, R8_1, R9_2; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R31_in, Gamma_R8_1, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write_gtirb.expected b/src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write_gtirb.expected index 69bd5368f..b6eec67eb 100644 --- a/src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write_gtirb.expected +++ b/src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write_gtirb.expected @@ -1,23 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +26,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -55,15 +46,12 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -90,51 +78,49 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R31, R8, R9, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69584bv64) == 1876bv64); free requires (memory_load64_le(mem, 69592bv64) == 69684bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_1: bool; - var Gamma_R9_2: bool; - var R8_1: bv64; - var R9_2: bv64; var arr$0_old: bv32; $main$__0__$QhI~JImIRPKZUYP_OR5sGw: + assume {:captureState "$main$__0__$QhI~JImIRPKZUYP_OR5sGw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - R8_1, Gamma_R8_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4056bv64)) || L(mem, bvadd64(R9, 4056bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1888$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, bvadd64(R9_2, 4bv64)) ==> Gamma_R8_1); + assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); - mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9_2, 4bv64), R8_1[32:0]), gamma_store32(Gamma_mem, bvadd64(R9_2, 4bv64), Gamma_R8_1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "1896$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R31_out, R8_out, R9_out := 0bv64, R31_in, R8_1, R9_2; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R31_in, Gamma_R8_1, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_write/gcc/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/gcc/basic_arrays_write.expected index fe3cdb5ca..10630740e 100644 --- a/src/test/correct/basic_arrays_write/gcc/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/gcc/basic_arrays_write.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +31,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +40,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -85,45 +71,46 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R1_1: bool; - var R1_1: bv64; var arr$0_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - R1_1, Gamma_R1_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002da"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, 69660bv64) ==> Gamma_R1_1); + assert (L(mem, bvadd64(R0, 4bv64)) ==> Gamma_R1); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); - mem, Gamma_mem := memory_store32_le(mem, 69660bv64, R1_1[32:0]), gamma_store32(Gamma_mem, 69660bv64, Gamma_R1_1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%000002f4"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_1, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_1, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_write/gcc/basic_arrays_write_gtirb.expected b/src/test/correct/basic_arrays_write/gcc/basic_arrays_write_gtirb.expected index 435ad2ea0..f2284d404 100644 --- a/src/test/correct/basic_arrays_write/gcc/basic_arrays_write_gtirb.expected +++ b/src/test/correct/basic_arrays_write/gcc/basic_arrays_write_gtirb.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +31,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +40,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -85,45 +71,46 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R1_1: bool; - var R1_1: bv64; var arr$0_old: bv32; $main$__0__$xPJOAvxpQvOT0IITWVjgKA: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - R1_1, Gamma_R1_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__0__$xPJOAvxpQvOT0IITWVjgKA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1816$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, 69660bv64) ==> Gamma_R1_1); + assert (L(mem, bvadd64(R0, 4bv64)) ==> Gamma_R1); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); - mem, Gamma_mem := memory_store32_le(mem, 69660bv64, R1_1[32:0]), gamma_store32(Gamma_mem, 69660bv64, Gamma_R1_1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "1832$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_1, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_1, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_write/gcc_O2/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/gcc_O2/basic_arrays_write.expected index 9656cb4d9..846543f7b 100644 --- a/src/test/correct/basic_arrays_write/gcc_O2/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/gcc_O2/basic_arrays_write.expected @@ -1,27 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,12 +25,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -45,10 +34,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -79,44 +65,39 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R2_1: bool; - var R2_1: bv64; var arr$0_old: bv32; lmain: - R2_1, Gamma_R2_1 := zero_extend32_32(R0_in[32:0]), Gamma_R0_in; + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69660bv64) ==> Gamma_R2_1); + assert (L(mem, bvadd64(R1, 28bv64)) ==> Gamma_R2); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); - mem, Gamma_mem := memory_store32_le(mem, 69660bv64, R2_1[32:0]), gamma_store32(Gamma_mem, 69660bv64, Gamma_R2_1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 28bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 28bv64), Gamma_R2); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%000001be"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, R2_1; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, Gamma_R2_1; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_write/gcc_O2/basic_arrays_write_gtirb.expected b/src/test/correct/basic_arrays_write/gcc_O2/basic_arrays_write_gtirb.expected index 85ead905b..0fe8d5e9c 100644 --- a/src/test/correct/basic_arrays_write/gcc_O2/basic_arrays_write_gtirb.expected +++ b/src/test/correct/basic_arrays_write/gcc_O2/basic_arrays_write_gtirb.expected @@ -1,27 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,12 +25,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -45,10 +34,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -79,44 +65,39 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R2_1: bool; - var R2_1: bv64; var arr$0_old: bv32; $main$__0__$V~T77jbITpWbEe~BkyODXA: - R2_1, Gamma_R2_1 := zero_extend32_32(R0_in[32:0]), Gamma_R0_in; + assume {:captureState "$main$__0__$V~T77jbITpWbEe~BkyODXA"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69660bv64) ==> Gamma_R2_1); + assert (L(mem, bvadd64(R1, 28bv64)) ==> Gamma_R2); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); - mem, Gamma_mem := memory_store32_le(mem, 69660bv64, R2_1[32:0]), gamma_store32(Gamma_mem, 69660bv64, Gamma_R2_1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 28bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 28bv64), Gamma_R2); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "1548$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, R2_1; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, Gamma_R2_1; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_write/gcc_pic/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/gcc_pic/basic_arrays_write.expected index b51522b29..244532440 100644 --- a/src/test/correct/basic_arrays_write/gcc_pic/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/gcc_pic/basic_arrays_write.expected @@ -1,23 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +24,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +35,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -55,15 +44,12 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69608bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69616bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -90,51 +76,49 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69608bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69616bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69608bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69616bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R1_1: bool; - var R0_3: bv64; - var R1_1: bv64; var arr$0_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002da"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69616bv64), (gamma_load64(Gamma_mem, 69616bv64) || L(mem, 69616bv64)); - R1_1, Gamma_R1_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4080bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4080bv64)) || L(mem, bvadd64(R0, 4080bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, bvadd64(R0_3, 4bv64)) ==> Gamma_R1_1); + assert (L(mem, bvadd64(R0, 4bv64)) ==> Gamma_R1); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); - mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0_3, 4bv64), R1_1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0_3, 4bv64), Gamma_R1_1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%000002f5"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_1, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_1, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_arrays_write/gcc_pic/basic_arrays_write_gtirb.expected b/src/test/correct/basic_arrays_write/gcc_pic/basic_arrays_write_gtirb.expected index ecdb6d4cb..bffaf2ca4 100644 --- a/src/test/correct/basic_arrays_write/gcc_pic/basic_arrays_write_gtirb.expected +++ b/src/test/correct/basic_arrays_write/gcc_pic/basic_arrays_write_gtirb.expected @@ -1,23 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +24,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +35,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -55,15 +44,12 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69608bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69616bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -90,51 +76,49 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69608bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69616bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69608bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69616bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R1_1: bool; - var R0_3: bv64; - var R1_1: bv64; var arr$0_old: bv32; $main$__0__$QDmuMUDLRx6nO2lgyEhfoQ: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "$main$__0__$QDmuMUDLRx6nO2lgyEhfoQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1880$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69616bv64), (gamma_load64(Gamma_mem, 69616bv64) || L(mem, 69616bv64)); - R1_1, Gamma_R1_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4080bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4080bv64)) || L(mem, bvadd64(R0, 4080bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, bvadd64(R0_3, 4bv64)) ==> Gamma_R1_1); + assert (L(mem, bvadd64(R0, 4bv64)) ==> Gamma_R1); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); - mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0_3, 4bv64), R1_1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0_3, 4bv64), Gamma_R1_1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "1896$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_1, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_1, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_assign/clang/basic_assign_assign.expected b/src/test/correct/basic_assign_assign/clang/basic_assign_assign.expected index 0b5491eaf..4eac10daa 100644 --- a/src/test/correct/basic_assign_assign/clang/basic_assign_assign.expected +++ b/src/test/correct/basic_assign_assign/clang/basic_assign_assign.expected @@ -1,27 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,22 +25,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -78,42 +64,40 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures ((memory_load32_le(mem, $x_addr) == 5bv32) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 5bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 5bv32), gamma_store32(Gamma_mem, 69684bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "%000002ce"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 5bv64, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_assign/clang/basic_assign_assign_gtirb.expected b/src/test/correct/basic_assign_assign/clang/basic_assign_assign_gtirb.expected index 52e4aaa46..4b43006e8 100644 --- a/src/test/correct/basic_assign_assign/clang/basic_assign_assign_gtirb.expected +++ b/src/test/correct/basic_assign_assign/clang/basic_assign_assign_gtirb.expected @@ -1,27 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,22 +25,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -78,42 +64,40 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures ((memory_load32_le(mem, $x_addr) == 5bv32) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var x_old: bv32; $main$__0__$Zdsp6UAuTvmVrSYb5TVuFA: + assume {:captureState "$main$__0__$Zdsp6UAuTvmVrSYb5TVuFA"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 5bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 5bv32), gamma_store32(Gamma_mem, 69684bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "1820$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 5bv64, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign.expected b/src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign.expected index d2b7cab5f..254255f97 100644 --- a/src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign.expected +++ b/src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign.expected @@ -1,31 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,27 +29,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -83,48 +69,44 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures ((memory_load32_le(mem, $x_addr) == 5bv32) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R9_3: bool; - var R9_3: bv64; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); + R8, Gamma_R8 := 5bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 5bv32), gamma_store32(Gamma_mem, R9_3, true); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "%000002d9"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 5bv64, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign_gtirb.expected b/src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign_gtirb.expected index ca568449d..e43de6329 100644 --- a/src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign_gtirb.expected +++ b/src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign_gtirb.expected @@ -1,31 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,27 +29,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -83,48 +69,44 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures ((memory_load32_le(mem, $x_addr) == 5bv32) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R9_3: bool; - var R9_3: bv64; var x_old: bv32; $main$__0__$Qq63bBfPSoWeSaa0hhOw6Q: + assume {:captureState "$main$__0__$Qq63bBfPSoWeSaa0hhOw6Q"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); + R8, Gamma_R8 := 5bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 5bv32), gamma_store32(Gamma_mem, R9_3, true); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "1888$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 5bv64, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_assign/gcc/basic_assign_assign.expected b/src/test/correct/basic_assign_assign/gcc/basic_assign_assign.expected index 75c593799..2bc7acf80 100644 --- a/src/test/correct/basic_assign_assign/gcc/basic_assign_assign.expected +++ b/src/test/correct/basic_assign_assign/gcc/basic_assign_assign.expected @@ -1,27 +1,18 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,22 +23,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -78,42 +62,41 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures ((memory_load32_le(mem, $x_addr) == 5bv32) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 5bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 5bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "%000002d8"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 5bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_assign/gcc/basic_assign_assign_gtirb.expected b/src/test/correct/basic_assign_assign/gcc/basic_assign_assign_gtirb.expected index a6b271526..163ad1ce6 100644 --- a/src/test/correct/basic_assign_assign/gcc/basic_assign_assign_gtirb.expected +++ b/src/test/correct/basic_assign_assign/gcc/basic_assign_assign_gtirb.expected @@ -1,27 +1,18 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,22 +23,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -78,42 +62,41 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures ((memory_load32_le(mem, $x_addr) == 5bv32) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { var x_old: bv32; $main$__0__$Wqz78H8dRsSZVuDqF6tLlA: + assume {:captureState "$main$__0__$Wqz78H8dRsSZVuDqF6tLlA"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 5bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 5bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 5bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_assign/gcc_O2/basic_assign_assign.expected b/src/test/correct/basic_assign_assign/gcc_O2/basic_assign_assign.expected index f23c212ef..962054198 100644 --- a/src/test/correct/basic_assign_assign/gcc_O2/basic_assign_assign.expected +++ b/src/test/correct/basic_assign_assign/gcc_O2/basic_assign_assign.expected @@ -1,27 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,22 +25,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -78,42 +64,40 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures ((memory_load32_le(mem, $x_addr) == 5bv32) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := 5bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 5bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "%000001bd"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, 5bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_assign/gcc_O2/basic_assign_assign_gtirb.expected b/src/test/correct/basic_assign_assign/gcc_O2/basic_assign_assign_gtirb.expected index 9ce6a0fca..b581f7d08 100644 --- a/src/test/correct/basic_assign_assign/gcc_O2/basic_assign_assign_gtirb.expected +++ b/src/test/correct/basic_assign_assign/gcc_O2/basic_assign_assign_gtirb.expected @@ -1,27 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,22 +25,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -78,42 +64,40 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures ((memory_load32_le(mem, $x_addr) == 5bv32) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { var x_old: bv32; $main$__0__$0n7MZQ5WQm2ayeQrMFoqXw: + assume {:captureState "$main$__0__$0n7MZQ5WQm2ayeQrMFoqXw"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := 5bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 5bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "1548$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, 5bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_assign/gcc_pic/basic_assign_assign.expected b/src/test/correct/basic_assign_assign/gcc_pic/basic_assign_assign.expected index 26ca46660..07cde5e52 100644 --- a/src/test/correct/basic_assign_assign/gcc_pic/basic_assign_assign.expected +++ b/src/test/correct/basic_assign_assign/gcc_pic/basic_assign_assign.expected @@ -1,31 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,27 +27,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -83,48 +67,44 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures ((memory_load32_le(mem, $x_addr) == 5bv32) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var R0_3: bv64; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := 5bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 5bv32), gamma_store32(Gamma_mem, R0_3, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "%000002d9"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 5bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_assign/gcc_pic/basic_assign_assign_gtirb.expected b/src/test/correct/basic_assign_assign/gcc_pic/basic_assign_assign_gtirb.expected index 924710083..57456a981 100644 --- a/src/test/correct/basic_assign_assign/gcc_pic/basic_assign_assign_gtirb.expected +++ b/src/test/correct/basic_assign_assign/gcc_pic/basic_assign_assign_gtirb.expected @@ -1,31 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,27 +27,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -83,48 +67,44 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures ((memory_load32_le(mem, $x_addr) == 5bv32) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var R0_3: bv64; var x_old: bv32; $main$__0__$2duqIb9aRtKZChm_n6bdGQ: + assume {:captureState "$main$__0__$2duqIb9aRtKZChm_n6bdGQ"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := 5bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 5bv32), gamma_store32(Gamma_mem, R0_3, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "1888$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 5bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_increment/clang/basic_assign_increment.expected b/src/test/correct/basic_assign_increment/clang/basic_assign_increment.expected index 70dd4c974..812b609e6 100644 --- a/src/test/correct/basic_assign_increment/clang/basic_assign_increment.expected +++ b/src/test/correct/basic_assign_increment/clang/basic_assign_increment.expected @@ -1,32 +1,25 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -37,12 +30,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -50,10 +39,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -84,49 +70,42 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (((memory_load32_le(mem, $x_addr) == 1bv32) || (memory_load32_le(mem, $x_addr) == 5bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var R8_2: bv32; - var R8_3: bv64; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - R8_3, Gamma_R8_3 := zero_extend32_32(bvadd32(R8_2, 1bv32)), Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R8_3); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69684bv64, Gamma_R8_3); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "%000002da"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_increment/clang/basic_assign_increment_gtirb.expected b/src/test/correct/basic_assign_increment/clang/basic_assign_increment_gtirb.expected index d6866b0c1..ef78d2241 100644 --- a/src/test/correct/basic_assign_increment/clang/basic_assign_increment_gtirb.expected +++ b/src/test/correct/basic_assign_increment/clang/basic_assign_increment_gtirb.expected @@ -1,32 +1,25 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -37,12 +30,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -50,10 +39,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -84,49 +70,42 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (((memory_load32_le(mem, $x_addr) == 1bv32) || (memory_load32_le(mem, $x_addr) == 5bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var R8_2: bv32; - var R8_3: bv64; var x_old: bv32; $main$__0__$H_EeiA6dR0KUx9b5mWQKhQ: + assume {:captureState "$main$__0__$H_EeiA6dR0KUx9b5mWQKhQ"} true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - R8_3, Gamma_R8_3 := zero_extend32_32(bvadd32(R8_2, 1bv32)), Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R8_3); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69684bv64, Gamma_R8_3); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment.expected b/src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment.expected index a4ff37e33..e4e53c315 100644 --- a/src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment.expected +++ b/src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment.expected @@ -1,22 +1,19 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -26,11 +23,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -41,12 +34,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -54,15 +43,12 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); - free ensures (memory_load8_le(mem, 1924bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1925bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1926bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1927bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1924bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -89,55 +75,46 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1924bv64) == 1bv8); - free requires (memory_load8_le(mem, 1925bv64) == 0bv8); - free requires (memory_load8_le(mem, 1926bv64) == 2bv8); - free requires (memory_load8_le(mem, 1927bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1924bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (((memory_load32_le(mem, $x_addr) == 1bv32) || (memory_load32_le(mem, $x_addr) == 5bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1924bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1925bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1926bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1927bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1924bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_3: bool; - var R8_2: bv32; - var R8_3: bv64; - var R9_3: bv64; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, R9_3), (gamma_load32(Gamma_mem, R9_3) || L(mem, R9_3)); - R8_3, Gamma_R8_3 := zero_extend32_32(bvadd32(R8_2, 1bv32)), Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_3); + assert (L(mem, R9) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R8_3[32:0]), gamma_store32(Gamma_mem, R9_3, Gamma_R8_3); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "%000002e5"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_3, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_3, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment_gtirb.expected b/src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment_gtirb.expected index 85da19726..330e91d98 100644 --- a/src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment_gtirb.expected +++ b/src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment_gtirb.expected @@ -1,22 +1,19 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -26,11 +23,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -41,12 +34,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -54,15 +43,12 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); - free ensures (memory_load8_le(mem, 1924bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1925bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1926bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1927bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1924bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -89,55 +75,46 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1924bv64) == 1bv8); - free requires (memory_load8_le(mem, 1925bv64) == 0bv8); - free requires (memory_load8_le(mem, 1926bv64) == 2bv8); - free requires (memory_load8_le(mem, 1927bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1924bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (((memory_load32_le(mem, $x_addr) == 1bv32) || (memory_load32_le(mem, $x_addr) == 5bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1924bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1925bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1926bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1927bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1924bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_3: bool; - var R8_2: bv32; - var R8_3: bv64; - var R9_3: bv64; var x_old: bv32; $main$__0__$bZWV3u7ES1C1enASABiKYQ: + assume {:captureState "$main$__0__$bZWV3u7ES1C1enASABiKYQ"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, R9_3), (gamma_load32(Gamma_mem, R9_3) || L(mem, R9_3)); - R8_3, Gamma_R8_3 := zero_extend32_32(bvadd32(R8_2, 1bv32)), Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_3); + assert (L(mem, R9) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R8_3[32:0]), gamma_store32(Gamma_mem, R9_3, Gamma_R8_3); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "1892$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_3, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_3, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_increment/gcc/basic_assign_increment.expected b/src/test/correct/basic_assign_increment/gcc/basic_assign_increment.expected index 6535907cc..78dc01415 100644 --- a/src/test/correct/basic_assign_increment/gcc/basic_assign_increment.expected +++ b/src/test/correct/basic_assign_increment/gcc/basic_assign_increment.expected @@ -1,32 +1,23 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -37,12 +28,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -50,10 +37,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -84,49 +68,45 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (((memory_load32_le(mem, $x_addr) == 1bv32) || (memory_load32_le(mem, $x_addr) == 5bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_4: bool; - var Gamma_R1_2: bool; - var R0_4: bv32; - var R1_2: bv64; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - R1_2, Gamma_R1_2 := zero_extend32_32(bvadd32(R0_4, 1bv32)), Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_2[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_2); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "%000002f7"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_2; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_increment/gcc/basic_assign_increment_gtirb.expected b/src/test/correct/basic_assign_increment/gcc/basic_assign_increment_gtirb.expected index 79fd4bff1..ca01cce2f 100644 --- a/src/test/correct/basic_assign_increment/gcc/basic_assign_increment_gtirb.expected +++ b/src/test/correct/basic_assign_increment/gcc/basic_assign_increment_gtirb.expected @@ -1,32 +1,23 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -37,12 +28,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -50,10 +37,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -84,49 +68,45 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (((memory_load32_le(mem, $x_addr) == 1bv32) || (memory_load32_le(mem, $x_addr) == 5bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_4: bool; - var Gamma_R1_2: bool; - var R0_4: bv32; - var R1_2: bv64; var x_old: bv32; $main$__0__$wuKKiZcoTsun5X2agtHvyA: + assume {:captureState "$main$__0__$wuKKiZcoTsun5X2agtHvyA"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - R1_2, Gamma_R1_2 := zero_extend32_32(bvadd32(R0_4, 1bv32)), Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_2[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_2); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "1836$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_2; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_increment/gcc_O2/basic_assign_increment.expected b/src/test/correct/basic_assign_increment/gcc_O2/basic_assign_increment.expected index 2f7789a20..960b020dc 100644 --- a/src/test/correct/basic_assign_increment/gcc_O2/basic_assign_increment.expected +++ b/src/test/correct/basic_assign_increment/gcc_O2/basic_assign_increment.expected @@ -1,32 +1,25 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -37,12 +30,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -50,10 +39,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -84,49 +70,42 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (((memory_load32_le(mem, $x_addr) == 1bv32) || (memory_load32_le(mem, $x_addr) == 5bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var R1_2: bv32; - var R1_3: bv64; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R2, Gamma_R2 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - R1_2, Gamma_R1_2 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - R1_3, Gamma_R1_3 := zero_extend32_32(bvadd32(R1_2, 1bv32)), Gamma_R1_2; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 20bv64)) || L(mem, bvadd64(R2, 20bv64))); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R1[32:0], 1bv32)), Gamma_R1; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_3); + assert (L(mem, bvadd64(R2, 20bv64)) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_3[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_3); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 20bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R2, 20bv64), Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "%000001c5"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, R1_3, 69632bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, Gamma_R1_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_increment/gcc_O2/basic_assign_increment_gtirb.expected b/src/test/correct/basic_assign_increment/gcc_O2/basic_assign_increment_gtirb.expected index 27d7e495c..04b71a74b 100644 --- a/src/test/correct/basic_assign_increment/gcc_O2/basic_assign_increment_gtirb.expected +++ b/src/test/correct/basic_assign_increment/gcc_O2/basic_assign_increment_gtirb.expected @@ -1,32 +1,25 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -37,12 +30,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -50,10 +39,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -84,49 +70,42 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (((memory_load32_le(mem, $x_addr) == 1bv32) || (memory_load32_le(mem, $x_addr) == 5bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var R1_2: bv32; - var R1_3: bv64; var x_old: bv32; $main$__0__$xDQgkCAvTRyzcNBtjizdZg: + assume {:captureState "$main$__0__$xDQgkCAvTRyzcNBtjizdZg"} true; + R2, Gamma_R2 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - R1_2, Gamma_R1_2 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - R1_3, Gamma_R1_3 := zero_extend32_32(bvadd32(R1_2, 1bv32)), Gamma_R1_2; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 20bv64)) || L(mem, bvadd64(R2, 20bv64))); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R1[32:0], 1bv32)), Gamma_R1; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_3); + assert (L(mem, bvadd64(R2, 20bv64)) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_3[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_3); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 20bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R2, 20bv64), Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "1552$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, R1_3, 69632bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, Gamma_R1_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_increment/gcc_pic/basic_assign_increment.expected b/src/test/correct/basic_assign_increment/gcc_pic/basic_assign_increment.expected index 96fe9112f..7fa9d9aee 100644 --- a/src/test/correct/basic_assign_increment/gcc_pic/basic_assign_increment.expected +++ b/src/test/correct/basic_assign_increment/gcc_pic/basic_assign_increment.expected @@ -1,22 +1,17 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -26,11 +21,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -41,12 +32,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -54,15 +41,12 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -89,59 +73,49 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (((memory_load32_le(mem, $x_addr) == 1bv32) || (memory_load32_le(mem, $x_addr) == 5bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_6: bool; - var Gamma_R1_2: bool; - var R0_3: bv64; - var R0_4: bv32; - var R0_6: bv64; - var R1_2: bv64; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, R0_3), (gamma_load32(Gamma_mem, R0_3) || L(mem, R0_3)); - R1_2, Gamma_R1_2 := zero_extend32_32(bvadd32(R0_4, 1bv32)), Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_6, Gamma_R0_6 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - assert (L(mem, R0_6) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_6, R1_2[32:0]), gamma_store32(Gamma_mem, R0_6, Gamma_R1_2); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "%000002f9"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_2; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_assign_increment/gcc_pic/basic_assign_increment_gtirb.expected b/src/test/correct/basic_assign_increment/gcc_pic/basic_assign_increment_gtirb.expected index bfdb7a2ec..b429d97d2 100644 --- a/src/test/correct/basic_assign_increment/gcc_pic/basic_assign_increment_gtirb.expected +++ b/src/test/correct/basic_assign_increment/gcc_pic/basic_assign_increment_gtirb.expected @@ -1,22 +1,17 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -26,11 +21,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -41,12 +32,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -54,15 +41,12 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -89,59 +73,49 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (((memory_load32_le(mem, $x_addr) == 1bv32) || (memory_load32_le(mem, $x_addr) == 5bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_6: bool; - var Gamma_R1_2: bool; - var R0_3: bv64; - var R0_4: bv32; - var R0_6: bv64; - var R1_2: bv64; var x_old: bv32; $main$__0__$x4rdl4IySJOtuvEUdyndvg: + assume {:captureState "$main$__0__$x4rdl4IySJOtuvEUdyndvg"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, R0_3), (gamma_load32(Gamma_mem, R0_3) || L(mem, R0_3)); - R1_2, Gamma_R1_2 := zero_extend32_32(bvadd32(R0_4, 1bv32)), Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_6, Gamma_R0_6 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - assert (L(mem, R0_6) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_6, R1_2[32:0]), gamma_store32(Gamma_mem, R0_6, Gamma_R1_2); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "1900$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_2; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/clang/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/clang/basic_function_call_caller.expected index fa1483921..cb29dbcb0 100644 --- a/src/test/correct/basic_function_call_caller/clang/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/clang/basic_function_call_caller.expected @@ -1,30 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,15 +32,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -53,16 +47,12 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -71,10 +61,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1820bv64); @@ -108,99 +95,104 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R29, R30, R31, R8, R9, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1820bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1820bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var Gamma_R8_2: bool; + var #4: bv64; + var #5: bv64; + var Gamma_#4: bool; + var Gamma_#5: bool; var Gamma_y_old: bool; - var R0_2: bv64; - var R29_3: bv64; - var R30_3: bv64; - var R8_2: bv64; var x_old: bv32; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - call R0_2, Gamma_R0_2 := zero(); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + #4, Gamma_#4 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000304"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000030a"} true; + R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R0); + assume {:captureState "%00000318"} true; + R30, Gamma_R30 := 1840bv64, true; + call zero(); goto l00000321; l00000321: + assume {:captureState "l00000321"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R0_2); + assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R0); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, R0_2[32:0]), gamma_store32(Gamma_mem, 69684bv64, Gamma_R0_2); - assert ((69684bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R0); + assert ((bvadd64(R8, 52bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R8_2, Gamma_R8_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); + assume {:captureState "%0000032c"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64)); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_2); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_2[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_2); - assert ((69688bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assert ((bvadd64(R9, 56bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "%00000340"} true; + R0, Gamma_R0 := 0bv64, true; + #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#5, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out, R9_out := 0bv64, R29_3, R30_3, R31_in, R8_2, 69632bv64; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in, Gamma_R8_2, true; + assume {:captureState "main_basil_return"} true; return; } -procedure zero() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); +procedure zero(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1820bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - ensures ((R0_out[32:0] == 0bv32) && Gamma_R0_out); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures ((R0[32:0] == 0bv32) && Gamma_R0); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1820bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation zero() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation zero() { lzero: + assume {:captureState "lzero"} true; + R0, Gamma_R0 := 0bv64, true; goto zero_basil_return; zero_basil_return: - R0_out := 0bv64; - Gamma_R0_out := true; + assume {:captureState "zero_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/clang/basic_function_call_caller_gtirb.expected b/src/test/correct/basic_function_call_caller/clang/basic_function_call_caller_gtirb.expected index 28aaa5b1e..d9bbf3d49 100644 --- a/src/test/correct/basic_function_call_caller/clang/basic_function_call_caller_gtirb.expected +++ b/src/test/correct/basic_function_call_caller/clang/basic_function_call_caller_gtirb.expected @@ -1,30 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,15 +32,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -53,16 +47,12 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -71,10 +61,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1820bv64); @@ -108,99 +95,104 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R29, R30, R31, R8, R9, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1820bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1820bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var Gamma_R8_2: bool; + var Cse0__5$0$1: bv64; + var Cse0__5$1$6: bv64; + var Gamma_Cse0__5$0$1: bool; + var Gamma_Cse0__5$1$6: bool; var Gamma_y_old: bool; - var R0_2: bv64; - var R29_3: bv64; - var R30_3: bv64; - var R8_2: bv64; var x_old: bv32; $main$__0__$cikrXZAWRXiUPK6lrh286g: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - call R0_2, Gamma_R0_2 := zero(); + assume {:captureState "$main$__0__$cikrXZAWRXiUPK6lrh286g"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + Cse0__5$0$1, Gamma_Cse0__5$0$1 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$1, R29), gamma_store64(Gamma_stack, Cse0__5$0$1, Gamma_R29); + assume {:captureState "1824$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$1, 8bv64), Gamma_R30); + assume {:captureState "1824$2"} true; + R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R0); + assume {:captureState "1832$0"} true; + R30, Gamma_R30 := 1840bv64, true; + call zero(); goto $main$__1__$tUsSswMeSRWNOjHB4V55Fw; $main$__1__$tUsSswMeSRWNOjHB4V55Fw: + assume {:captureState "$main$__1__$tUsSswMeSRWNOjHB4V55Fw"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R0_2); + assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R0); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, R0_2[32:0]), gamma_store32(Gamma_mem, 69684bv64, Gamma_R0_2); - assert ((69684bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R0); + assert ((bvadd64(R8, 52bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R8_2, Gamma_R8_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); + assume {:captureState "1844$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64)); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_2); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_2[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_2); - assert ((69688bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assert ((bvadd64(R9, 56bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "1856$0"} true; + R0, Gamma_R0 := 0bv64, true; + Cse0__5$1$6, Gamma_Cse0__5$1$6 := bvadd64(R31, 16bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$1$6), gamma_load64(Gamma_stack, Cse0__5$1$6); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$1$6, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$1$6, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out, R9_out := 0bv64, R29_3, R30_3, R31_in, R8_2, 69632bv64; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in, Gamma_R8_2, true; + assume {:captureState "main_basil_return"} true; return; } -procedure zero() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); +procedure zero(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1820bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - ensures ((R0_out[32:0] == 0bv32) && Gamma_R0_out); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures ((R0[32:0] == 0bv32) && Gamma_R0); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1820bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation zero() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation zero() { $zero$__0__$dXyEHeAuQ5WTjIZmtrK5_w: + assume {:captureState "$zero$__0__$dXyEHeAuQ5WTjIZmtrK5_w"} true; + R0, Gamma_R0 := 0bv64, true; goto zero_basil_return; zero_basil_return: - R0_out := 0bv64; - Gamma_R0_out := true; + assume {:captureState "zero_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller.expected index 8cf4b9563..21551088c 100644 --- a/src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller.expected @@ -1,33 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +33,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -52,10 +43,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1820bv64); @@ -89,56 +77,53 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R8, R9, mem; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1820bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1820bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_1: bool; var Gamma_y_old: bool; - var R8_1: bv64; var x_old: bv32; lmain: - R8_1, Gamma_R8_1 := zero_extend32_32(R0_in[32:0]), Gamma_R0_in; + assume {:captureState "lmain"} true; + R8, Gamma_R8 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R10, Gamma_R10 := 69632bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> true); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 0bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), true); + assert ((bvadd64(R9, 52bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%000002f2"} true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_1); + assert (L(mem, bvadd64(R10, 56bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_1); - assert ((69688bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R10, 56bv64), Gamma_R8); + assert ((bvadd64(R10, 56bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%000002fa"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R8_out, R9_out := 0bv64, 69632bv64, R8_1, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R8_1, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller_gtirb.expected b/src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller_gtirb.expected index 0e7833cad..60c056c27 100644 --- a/src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller_gtirb.expected +++ b/src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller_gtirb.expected @@ -1,33 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +33,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -52,10 +43,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1820bv64); @@ -89,56 +77,53 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R8, R9, mem; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1820bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1820bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_1: bool; var Gamma_y_old: bool; - var R8_1: bv64; var x_old: bv32; $main$__0__$R19aP0IbQWWtedSj9WMhiQ: - R8_1, Gamma_R8_1 := zero_extend32_32(R0_in[32:0]), Gamma_R0_in; + assume {:captureState "$main$__0__$R19aP0IbQWWtedSj9WMhiQ"} true; + R8, Gamma_R8 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R10, Gamma_R10 := 69632bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> true); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 0bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), true); + assert ((bvadd64(R9, 52bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "1836$0"} true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_1); + assert (L(mem, bvadd64(R10, 56bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_1); - assert ((69688bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R10, 56bv64), Gamma_R8); + assert ((bvadd64(R10, 56bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "1840$0"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R8_out, R9_out := 0bv64, 69632bv64, R8_1, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R8_1, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller.expected index 363f296d5..826223e20 100644 --- a/src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller.expected @@ -1,30 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,15 +32,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -53,16 +47,12 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -71,16 +61,13 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1884bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -110,115 +97,116 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R29, R30, R31, R8, R9, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1968bv64) == 1bv8); - free requires (memory_load8_le(mem, 1969bv64) == 0bv8); - free requires (memory_load8_le(mem, 1970bv64) == 2bv8); - free requires (memory_load8_le(mem, 1971bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load32_le(mem, 1968bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1884bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1884bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_2: bool; + var #4: bv64; + var #5: bv64; + var Gamma_#4: bool; + var Gamma_#5: bool; var Gamma_y_old: bool; - var R0_2: bv64; - var R29_3: bv64; - var R30_3: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R9_2: bv64; var x_old: bv32; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - call R0_2, Gamma_R0_2 := zero(); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + #4, Gamma_#4 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000030c"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000312"} true; + R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R0); + assume {:captureState "%00000320"} true; + R30, Gamma_R30 := 1904bv64, true; + call zero(); goto l00000329; l00000329: + assume {:captureState "l00000329"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - assert (L(mem, R8_2) ==> Gamma_R0_2); + assert (L(mem, R8) ==> Gamma_R0); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_2, R0_2[32:0]), gamma_store32(Gamma_mem, R8_2, Gamma_R0_2); - assert ((R8_2 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, R0[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R0); + assert ((R8 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); + assume {:captureState "%0000033b"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4048bv64)) || L(mem, bvadd64(R9, 4048bv64))); call rely(); - assert (L(mem, R9_2) ==> Gamma_R8_3); + assert (L(mem, R9) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_2, R8_3[32:0]), gamma_store32(Gamma_mem, R9_2, Gamma_R8_3); - assert ((R9_2 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assert ((R9 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "%00000356"} true; + R0, Gamma_R0 := 0bv64, true; + #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#5, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out, R9_out := 0bv64, R29_3, R30_3, R31_in, R8_3, R9_2; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in, Gamma_R8_3, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } -procedure zero() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1968bv64) == 1bv8); - free requires (memory_load8_le(mem, 1969bv64) == 0bv8); - free requires (memory_load8_le(mem, 1970bv64) == 2bv8); - free requires (memory_load8_le(mem, 1971bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); +procedure zero(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1968bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1884bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - ensures ((R0_out[32:0] == 0bv32) && Gamma_R0_out); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + ensures ((R0[32:0] == 0bv32) && Gamma_R0); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1884bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation zero() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation zero() { lzero: + assume {:captureState "lzero"} true; + R0, Gamma_R0 := 0bv64, true; goto zero_basil_return; zero_basil_return: - R0_out := 0bv64; - Gamma_R0_out := true; + assume {:captureState "zero_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller_gtirb.expected b/src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller_gtirb.expected index a62cbdeac..8d53aaa0e 100644 --- a/src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller_gtirb.expected +++ b/src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller_gtirb.expected @@ -1,30 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,15 +32,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -53,16 +47,12 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -71,16 +61,13 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1884bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -110,115 +97,116 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure zero() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1968bv64) == 1bv8); - free requires (memory_load8_le(mem, 1969bv64) == 0bv8); - free requires (memory_load8_le(mem, 1970bv64) == 2bv8); - free requires (memory_load8_le(mem, 1971bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); +procedure zero(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1968bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1884bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - ensures ((R0_out[32:0] == 0bv32) && Gamma_R0_out); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + ensures ((R0[32:0] == 0bv32) && Gamma_R0); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1884bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation zero() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation zero() { $zero$__0__$1fqyj6pOSBuFGojVzGfGVg: + assume {:captureState "$zero$__0__$1fqyj6pOSBuFGojVzGfGVg"} true; + R0, Gamma_R0 := 0bv64, true; goto zero_basil_return; zero_basil_return: - R0_out := 0bv64; - Gamma_R0_out := true; + assume {:captureState "zero_basil_return"} true; return; } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R29, R30, R31, R8, R9, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1968bv64) == 1bv8); - free requires (memory_load8_le(mem, 1969bv64) == 0bv8); - free requires (memory_load8_le(mem, 1970bv64) == 2bv8); - free requires (memory_load8_le(mem, 1971bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load32_le(mem, 1968bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1884bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1884bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_2: bool; + var Cse0__5$0$8: bv64; + var Cse0__5$1$1: bv64; + var Gamma_Cse0__5$0$8: bool; + var Gamma_Cse0__5$1$1: bool; var Gamma_y_old: bool; - var R0_2: bv64; - var R29_3: bv64; - var R30_3: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R9_2: bv64; var x_old: bv32; $main$__0__$5CsLNppuR5eqRvmqjx~n_g: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - call R0_2, Gamma_R0_2 := zero(); + assume {:captureState "$main$__0__$5CsLNppuR5eqRvmqjx~n_g"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + Cse0__5$1$1, Gamma_Cse0__5$1$1 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$1, R29), gamma_store64(Gamma_stack, Cse0__5$1$1, Gamma_R29); + assume {:captureState "1888$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$1, 8bv64), Gamma_R30); + assume {:captureState "1888$2"} true; + R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R0); + assume {:captureState "1896$0"} true; + R30, Gamma_R30 := 1904bv64, true; + call zero(); goto $main$__1__$kSn83H7yT_uMmQNkg3LR7w; $main$__1__$kSn83H7yT_uMmQNkg3LR7w: + assume {:captureState "$main$__1__$kSn83H7yT_uMmQNkg3LR7w"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - assert (L(mem, R8_2) ==> Gamma_R0_2); + assert (L(mem, R8) ==> Gamma_R0); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_2, R0_2[32:0]), gamma_store32(Gamma_mem, R8_2, Gamma_R0_2); - assert ((R8_2 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, R0[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R0); + assert ((R8 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); + assume {:captureState "1912$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4048bv64)) || L(mem, bvadd64(R9, 4048bv64))); call rely(); - assert (L(mem, R9_2) ==> Gamma_R8_3); + assert (L(mem, R9) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_2, R8_3[32:0]), gamma_store32(Gamma_mem, R9_2, Gamma_R8_3); - assert ((R9_2 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assert ((R9 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "1928$0"} true; + R0, Gamma_R0 := 0bv64, true; + Cse0__5$0$8, Gamma_Cse0__5$0$8 := bvadd64(R31, 16bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$0$8), gamma_load64(Gamma_stack, Cse0__5$0$8); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$0$8, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$0$8, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out, R9_out := 0bv64, R29_3, R30_3, R31_in, R8_3, R9_2; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in, Gamma_R8_3, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/gcc/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/gcc/basic_function_call_caller.expected index c193dcca5..617c5bbf6 100644 --- a/src/test/correct/basic_function_call_caller/gcc/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/gcc/basic_function_call_caller.expected @@ -1,30 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,15 +30,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -53,16 +45,12 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -71,10 +59,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1820bv64); @@ -108,102 +93,104 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R29, R30, R31, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1900bv64) == 1bv8); - free requires (memory_load8_le(mem, 1901bv64) == 0bv8); - free requires (memory_load8_le(mem, 1902bv64) == 2bv8); - free requires (memory_load8_le(mem, 1903bv64) == 0bv8); + free requires (memory_load32_le(mem, 1900bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1820bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1820bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; + var #4: bv64; + var Gamma_#4: bool; var Gamma_y_old: bool; - var R0_2: bv64; - var R1_1: bv32; - var R1_2: bv64; - var R29_3: bv64; - var R30_3: bv64; var x_old: bv32; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - call R0_2, Gamma_R0_2 := zero(); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000302"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000308"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000031a"} true; + R30, Gamma_R30 := 1836bv64, true; + call zero(); goto l00000323; l00000323: - R1_1, Gamma_R1_1 := R0_2[32:0], Gamma_R0_2; + assume {:captureState "l00000323"} true; + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_1), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_1); - assert ((69652bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "%0000033a"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, R1_2[32:0]), gamma_store32(Gamma_mem, 69656bv64, Gamma_R1_2); - assert ((69656bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "%00000354"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_2, R29_3, R30_3, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } -procedure zero() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1900bv64) == 1bv8); - free requires (memory_load8_le(mem, 1901bv64) == 0bv8); - free requires (memory_load8_le(mem, 1902bv64) == 2bv8); - free requires (memory_load8_le(mem, 1903bv64) == 0bv8); +procedure zero(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1900bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1820bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - ensures ((R0_out[32:0] == 0bv32) && Gamma_R0_out); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + ensures ((R0[32:0] == 0bv32) && Gamma_R0); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1820bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation zero() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation zero() { lzero: + assume {:captureState "lzero"} true; + R0, Gamma_R0 := 0bv64, true; goto zero_basil_return; zero_basil_return: - R0_out := 0bv64; - Gamma_R0_out := true; + assume {:captureState "zero_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/gcc/basic_function_call_caller_gtirb.expected b/src/test/correct/basic_function_call_caller/gcc/basic_function_call_caller_gtirb.expected index d467dcfc8..ce6869d8e 100644 --- a/src/test/correct/basic_function_call_caller/gcc/basic_function_call_caller_gtirb.expected +++ b/src/test/correct/basic_function_call_caller/gcc/basic_function_call_caller_gtirb.expected @@ -1,30 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,15 +30,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -53,16 +45,12 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -71,10 +59,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1820bv64); @@ -108,102 +93,104 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R29, R30, R31, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1900bv64) == 1bv8); - free requires (memory_load8_le(mem, 1901bv64) == 0bv8); - free requires (memory_load8_le(mem, 1902bv64) == 2bv8); - free requires (memory_load8_le(mem, 1903bv64) == 0bv8); + free requires (memory_load32_le(mem, 1900bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1820bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1820bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; + var Cse0__5$1$0: bv64; + var Gamma_Cse0__5$1$0: bool; var Gamma_y_old: bool; - var R0_2: bv64; - var R1_1: bv32; - var R1_2: bv64; - var R29_3: bv64; - var R30_3: bv64; var x_old: bv32; $main$__0__$~dme1bffThCZlg_upQTe8w: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - call R0_2, Gamma_R0_2 := zero(); + assume {:captureState "$main$__0__$~dme1bffThCZlg_upQTe8w"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$0, R29), gamma_store64(Gamma_stack, Cse0__5$1$0, Gamma_R29); + assume {:captureState "1820$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$0, 8bv64), Gamma_R30); + assume {:captureState "1820$2"} true; + R31, Gamma_R31 := Cse0__5$1$0, Gamma_Cse0__5$1$0; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1828$0"} true; + R30, Gamma_R30 := 1836bv64, true; + call zero(); goto $main$__1__$4QSzcV2tT5urJoQQ7JLeVA; $main$__1__$4QSzcV2tT5urJoQQ7JLeVA: - R1_1, Gamma_R1_1 := R0_2[32:0], Gamma_R0_2; + assume {:captureState "$main$__1__$4QSzcV2tT5urJoQQ7JLeVA"} true; + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_1), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_1); - assert ((69652bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "1848$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, R1_2[32:0]), gamma_store32(Gamma_mem, 69656bv64, Gamma_R1_2); - assert ((69656bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "1864$0"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_2, R29_3, R30_3, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } -procedure zero() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1900bv64) == 1bv8); - free requires (memory_load8_le(mem, 1901bv64) == 0bv8); - free requires (memory_load8_le(mem, 1902bv64) == 2bv8); - free requires (memory_load8_le(mem, 1903bv64) == 0bv8); +procedure zero(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1900bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1820bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - ensures ((R0_out[32:0] == 0bv32) && Gamma_R0_out); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + ensures ((R0[32:0] == 0bv32) && Gamma_R0); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1820bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation zero() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation zero() { $zero$__0__$DyyShWZ6Q~qk7gwUxVGJdA: + assume {:captureState "$zero$__0__$DyyShWZ6Q~qk7gwUxVGJdA"} true; + R0, Gamma_R0 := 0bv64, true; goto zero_basil_return; zero_basil_return: - R0_out := 0bv64; - Gamma_R0_out := true; + assume {:captureState "zero_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/gcc_O2/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/gcc_O2/basic_function_call_caller.expected index 0fca04a41..19ed4fbb5 100644 --- a/src/test/correct/basic_function_call_caller/gcc_O2/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/gcc_O2/basic_function_call_caller.expected @@ -1,33 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +33,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -52,10 +43,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -89,56 +77,53 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool); - modifies Gamma_mem, mem; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_R3, Gamma_mem, R0, R1, R2, R3, mem; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1916bv64) == 1bv8); - free requires (memory_load8_le(mem, 1917bv64) == 0bv8); - free requires (memory_load8_le(mem, 1918bv64) == 2bv8); - free requires (memory_load8_le(mem, 1919bv64) == 0bv8); + free requires (memory_load32_le(mem, 1916bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool) +implementation main() { - var Gamma_R3_1: bool; var Gamma_y_old: bool; - var R3_1: bv64; var x_old: bv32; lmain: - R3_1, Gamma_R3_1 := zero_extend32_32(R0_in[32:0]), Gamma_R0_in; + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R3, Gamma_R3 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> true); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 0bv32), gamma_store32(Gamma_mem, 69652bv64, true); - assert ((69652bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), true); + assert ((bvadd64(R1, 20bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%000001d7"} true; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R3_1); + assert (L(mem, bvadd64(R2, 4bv64)) ==> Gamma_R3); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, R3_1[32:0]), gamma_store32(Gamma_mem, 69656bv64, Gamma_R3_1); - assert ((69656bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 4bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R2, 4bv64), Gamma_R3); + assert ((bvadd64(R2, 4bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%000001df"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out, R3_out := 0bv64, 69632bv64, 69652bv64, R3_1; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out, Gamma_R3_out := true, true, true, Gamma_R3_1; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/gcc_O2/basic_function_call_caller_gtirb.expected b/src/test/correct/basic_function_call_caller/gcc_O2/basic_function_call_caller_gtirb.expected index 4767d9ef8..e86cb65ba 100644 --- a/src/test/correct/basic_function_call_caller/gcc_O2/basic_function_call_caller_gtirb.expected +++ b/src/test/correct/basic_function_call_caller/gcc_O2/basic_function_call_caller_gtirb.expected @@ -1,33 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +33,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -52,10 +43,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -89,56 +77,53 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool); - modifies Gamma_mem, mem; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_R3, Gamma_mem, R0, R1, R2, R3, mem; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1916bv64) == 1bv8); - free requires (memory_load8_le(mem, 1917bv64) == 0bv8); - free requires (memory_load8_le(mem, 1918bv64) == 2bv8); - free requires (memory_load8_le(mem, 1919bv64) == 0bv8); + free requires (memory_load32_le(mem, 1916bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool) +implementation main() { - var Gamma_R3_1: bool; var Gamma_y_old: bool; - var R3_1: bv64; var x_old: bv32; $main$__0__$dv_jMrrYTUatcbBqfNbC1Q: - R3_1, Gamma_R3_1 := zero_extend32_32(R0_in[32:0]), Gamma_R0_in; + assume {:captureState "$main$__0__$dv_jMrrYTUatcbBqfNbC1Q"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R3, Gamma_R3 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> true); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 0bv32), gamma_store32(Gamma_mem, 69652bv64, true); - assert ((69652bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), true); + assert ((bvadd64(R1, 20bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "1552$0"} true; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R3_1); + assert (L(mem, bvadd64(R2, 4bv64)) ==> Gamma_R3); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, R3_1[32:0]), gamma_store32(Gamma_mem, 69656bv64, Gamma_R3_1); - assert ((69656bv64 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 4bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R2, 4bv64), Gamma_R3); + assert ((bvadd64(R2, 4bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "1556$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out, R3_out := 0bv64, 69632bv64, 69652bv64, R3_1; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out, Gamma_R3_out := true, true, true, Gamma_R3_1; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/gcc_pic/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/gcc_pic/basic_function_call_caller.expected index 432038392..14f153a77 100644 --- a/src/test/correct/basic_function_call_caller/gcc_pic/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/gcc_pic/basic_function_call_caller.expected @@ -1,30 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,15 +30,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -53,16 +45,12 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -71,16 +59,13 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -110,118 +95,114 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R29, R30, R31, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1884bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1884bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_4: bool; - var Gamma_R0_6: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; + var #4: bv64; + var Gamma_#4: bool; var Gamma_y_old: bool; - var R0_2: bv64; - var R0_4: bv64; - var R0_6: bv64; - var R1_1: bv32; - var R1_2: bv64; - var R29_3: bv64; - var R30_3: bv64; var x_old: bv32; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - call R0_2, Gamma_R0_2 := zero(); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000302"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000308"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000031a"} true; + R30, Gamma_R30 := 1900bv64, true; + call zero(); goto l00000323; l00000323: - R1_1, Gamma_R1_1 := R0_2[32:0], Gamma_R0_2; + assume {:captureState "l00000323"} true; + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_4, Gamma_R0_4 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_4) ==> Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_4, R1_1), gamma_store32(Gamma_mem, R0_4, Gamma_R1_1); - assert ((R0_4 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%0000033b"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_6, Gamma_R0_6 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); call rely(); - assert (L(mem, R0_6) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_6, R1_2[32:0]), gamma_store32(Gamma_mem, R0_6, Gamma_R1_2); - assert ((R0_6 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "%00000356"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_2, R29_3, R30_3, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } -procedure zero() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1884bv64); +procedure zero(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - ensures ((R0_out[32:0] == 0bv32) && Gamma_R0_out); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1884bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + ensures ((R0[32:0] == 0bv32) && Gamma_R0); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation zero() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation zero() { lzero: + assume {:captureState "lzero"} true; + R0, Gamma_R0 := 0bv64, true; goto zero_basil_return; zero_basil_return: - R0_out := 0bv64; - Gamma_R0_out := true; + assume {:captureState "zero_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/gcc_pic/basic_function_call_caller_gtirb.expected b/src/test/correct/basic_function_call_caller/gcc_pic/basic_function_call_caller_gtirb.expected index 769731aa0..1bfcdb325 100644 --- a/src/test/correct/basic_function_call_caller/gcc_pic/basic_function_call_caller_gtirb.expected +++ b/src/test/correct/basic_function_call_caller/gcc_pic/basic_function_call_caller_gtirb.expected @@ -1,30 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,15 +30,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -53,16 +45,12 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -71,16 +59,13 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -110,118 +95,114 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure zero() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1884bv64); +procedure zero(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - ensures ((R0_out[32:0] == 0bv32) && Gamma_R0_out); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1884bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + ensures ((R0[32:0] == 0bv32) && Gamma_R0); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation zero() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation zero() { $zero$__0__$nVyNTgcoQL~JpXdKnhkukw: + assume {:captureState "$zero$__0__$nVyNTgcoQL~JpXdKnhkukw"} true; + R0, Gamma_R0 := 0bv64, true; goto zero_basil_return; zero_basil_return: - R0_out := 0bv64; - Gamma_R0_out := true; + assume {:captureState "zero_basil_return"} true; return; } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R29, R30, R31, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1884bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1884bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_4: bool; - var Gamma_R0_6: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; + var Cse0__5$0$0: bv64; + var Gamma_Cse0__5$0$0: bool; var Gamma_y_old: bool; - var R0_2: bv64; - var R0_4: bv64; - var R0_6: bv64; - var R1_1: bv32; - var R1_2: bv64; - var R29_3: bv64; - var R30_3: bv64; var x_old: bv32; $main$__0__$iMp8MpTATOSyA~733MU0cQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - call R0_2, Gamma_R0_2 := zero(); + assume {:captureState "$main$__0__$iMp8MpTATOSyA~733MU0cQ"} true; + Cse0__5$0$0, Gamma_Cse0__5$0$0 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$0, R29), gamma_store64(Gamma_stack, Cse0__5$0$0, Gamma_R29); + assume {:captureState "1884$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$0, 8bv64), Gamma_R30); + assume {:captureState "1884$2"} true; + R31, Gamma_R31 := Cse0__5$0$0, Gamma_Cse0__5$0$0; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1892$0"} true; + R30, Gamma_R30 := 1900bv64, true; + call zero(); goto $main$__1__$uwC_i~q7SI~k8CryvMw8eg; $main$__1__$uwC_i~q7SI~k8CryvMw8eg: - R1_1, Gamma_R1_1 := R0_2[32:0], Gamma_R0_2; + assume {:captureState "$main$__1__$uwC_i~q7SI~k8CryvMw8eg"} true; + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_4, Gamma_R0_4 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_4) ==> Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_4, R1_1), gamma_store32(Gamma_mem, R0_4, Gamma_R1_1); - assert ((R0_4 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "1912$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_6, Gamma_R0_6 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); call rely(); - assert (L(mem, R0_6) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); Gamma_y_old := (gamma_load32(Gamma_mem, $y_addr) || L(mem, $y_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_6, R1_2[32:0]), gamma_store32(Gamma_mem, R0_6, Gamma_R1_2); - assert ((R0_6 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "1928$0"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_2, R29_3, R30_3, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/clang/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/clang/basic_function_call_reader.expected index b8c57eaec..04f4f6581 100644 --- a/src/test/correct/basic_function_call_reader/clang/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/clang/basic_function_call_reader.expected @@ -1,35 +1,42 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,24 +47,19 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - free ensures (memory_load8_le(mem, 1908bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1909bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1910bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1911bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1908bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -91,78 +93,97 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1908bv64) == 1bv8); - free requires (memory_load8_le(mem, 1909bv64) == 0bv8); - free requires (memory_load8_le(mem, 1910bv64) == 2bv8); - free requires (memory_load8_le(mem, 1911bv64) == 0bv8); + free requires (memory_load32_le(mem, 1908bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1908bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1909bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1910bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1911bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1908bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_12: bool; - var Gamma_R8_2: bool; - var Gamma_R8_4: bool; - var Gamma_R8_9: bool; - var R0_1: bv64; - var R8_11: bv64; - var R8_12: bv64; - var R8_2: bv32; - var R8_4: bv32; - var R8_9: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000301"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_2), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_2); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000315"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_4, Gamma_R8_4 := memory_load32_le(mem, 69688bv64), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - assert Gamma_R8_4; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000342, lmain_goto_l00000345; - lmain_goto_l00000345: - assume (!(R8_4 == 0bv32)); - R8_9, Gamma_R8_9 := 1bv64, true; + l00000345: + assume {:captureState "l00000345"} true; + R8, Gamma_R8 := 1bv64, true; goto l00000348; - lmain_goto_l00000342: - assume (R8_4 == 0bv32); - R8_9, Gamma_R8_9 := 0bv64, true; + l00000342: + assume {:captureState "l00000342"} true; + R8, Gamma_R8 := 0bv64, true; goto l00000348; l00000348: - assert Gamma_R8_9; + assume {:captureState "l00000348"} true; + assert Gamma_R8; goto l00000348_goto_l00000350, l00000348_goto_l0000037a; - l00000348_goto_l0000037a: - assume (!(R8_9[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_12, Gamma_R8_12 := R8_9, Gamma_R8_9; + l00000350: + assume {:captureState "l00000350"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000362"} true; goto l00000365; - l00000348_goto_l00000350: - assume (R8_9[1:0] == 1bv1); - R8_11, Gamma_R8_11 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R8_11[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R8_11); - R8_12, Gamma_R8_12 := R8_11, Gamma_R8_11; + l0000037a: + assume {:captureState "l0000037a"} true; + goto l0000037b; + l0000037b: + assume {:captureState "l0000037b"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000383"} true; goto l00000365; l00000365: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l00000365"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000342: + assume {:captureState "lmain_goto_l00000342"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l00000342; + lmain_goto_l00000345: + assume {:captureState "lmain_goto_l00000345"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l00000345; + l00000348_goto_l00000350: + assume {:captureState "l00000348_goto_l00000350"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l00000350; + l00000348_goto_l0000037a: + assume {:captureState "l00000348_goto_l0000037a"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l0000037a; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_12; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_12; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/clang/basic_function_call_reader_gtirb.expected b/src/test/correct/basic_function_call_reader/clang/basic_function_call_reader_gtirb.expected index 07d1c2486..ee71f1b77 100644 --- a/src/test/correct/basic_function_call_reader/clang/basic_function_call_reader_gtirb.expected +++ b/src/test/correct/basic_function_call_reader/clang/basic_function_call_reader_gtirb.expected @@ -1,35 +1,41 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,24 +46,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - free ensures (memory_load8_le(mem, 1908bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1909bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1910bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1911bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1908bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -91,91 +91,89 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1908bv64) == 1bv8); - free requires (memory_load8_le(mem, 1909bv64) == 0bv8); - free requires (memory_load8_le(mem, 1910bv64) == 2bv8); - free requires (memory_load8_le(mem, 1911bv64) == 0bv8); + free requires (memory_load32_le(mem, 1908bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1908bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1909bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1910bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1911bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1908bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_12: bool; - var Gamma_R8_13: bool; - var Gamma_R8_14: bool; - var Gamma_R8_2: bool; - var Gamma_R8_4: bool; - var R0_1: bv64; - var R8_10: bv64; - var R8_12: bv64; - var R8_13: bv64; - var R8_14: bv64; - var R8_2: bv32; - var R8_4: bv32; + var Cse0__5$0$7: bv32; + var Gamma_Cse0__5$0$7: bool; $main$__0__$p64I2ZUnTxGzbzeacDZqwg: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$p64I2ZUnTxGzbzeacDZqwg"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1816$0"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_2), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_2); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1828$0"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_4, Gamma_R8_4 := memory_load32_le(mem, 69688bv64), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - assert Gamma_R8_4; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + Cse0__5$0$7, Gamma_Cse0__5$0$7 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$7, Cse0__5$0$7)), Gamma_Cse0__5$0$7; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$7), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$0$7); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$7, 0bv32), Gamma_Cse0__5$0$7; + NF, Gamma_NF := Cse0__5$0$7[32:31], Gamma_Cse0__5$0$7; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$0$7), Gamma_Cse0__5$0$7; + assert Gamma_ZF; goto $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__0, $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__1; - $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__1: - assume (!(R8_4 == 0bv32)); - goto $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__1_phi_$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ_phi_back_$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ, $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__1_phi_$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ_phi_back_$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ; - $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__1_phi_$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ_phi_back_$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ: - R8_10, Gamma_R8_10 := 1bv64, true; - assert Gamma_R8_10; - goto $main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ; - $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__1_phi_$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ_phi_back_$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ: - R8_12, Gamma_R8_12 := 1bv64, true; - assert Gamma_R8_12; - goto $main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ; - $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__0: - assume (R8_4 == 0bv32); - goto $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__0_phi_back_$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ, $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__0_phi_back_$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ; - $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__0_phi_back_$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ: - R8_12, Gamma_R8_12 := 0bv64, true; - assert Gamma_R8_12; - goto $main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ; - $main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ: - assume (R8_12[1:0] == 1bv1); - R8_13, Gamma_R8_13 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R8_13[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R8_13); - R8_14, Gamma_R8_14 := R8_13, Gamma_R8_13; + $main$__1__$bKbuo5TmTwOMb5a3DV3xHQ: + assume {:captureState "$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ"} true; + goto $main$__2__$aBEoJbwOSm2rHPYmBa6e_A; + $main$__2__$aBEoJbwOSm2rHPYmBa6e_A: + assume {:captureState "$main$__2__$aBEoJbwOSm2rHPYmBa6e_A"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1856$0"} true; goto $main$__4__$rZXVe~PNSWyDYBX4vnXb~w; - $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__0_phi_back_$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ: - R8_10, Gamma_R8_10 := 0bv64, true; - assert Gamma_R8_10; - goto $main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ; - $main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ: - assume (!(R8_10[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_14, Gamma_R8_14 := R8_10, Gamma_R8_10; + $main$__3__$NTeZmOi8Sy2TG2_DQEytfQ: + assume {:captureState "$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1868$0"} true; goto $main$__4__$rZXVe~PNSWyDYBX4vnXb~w; $main$__4__$rZXVe~PNSWyDYBX4vnXb~w: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__4__$rZXVe~PNSWyDYBX4vnXb~w"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ: + assume {:captureState "$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$NTeZmOi8Sy2TG2_DQEytfQ; + $main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ: + assume {:captureState "$main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$bKbuo5TmTwOMb5a3DV3xHQ; + $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__0: + assume {:captureState "$main$__0__$p64I2ZUnTxGzbzeacDZqwg$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ, $main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ; + $main$__0__$p64I2ZUnTxGzbzeacDZqwg$__1: + assume {:captureState "$main$__0__$p64I2ZUnTxGzbzeacDZqwg$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__3__$NTeZmOi8Sy2TG2_DQEytfQ, $main$__0__$p64I2ZUnTxGzbzeacDZqwg_goto_$main$__1__$bKbuo5TmTwOMb5a3DV3xHQ; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_14; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_14; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader.expected index 790fb2bbb..4e8bfd232 100644 --- a/src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader.expected @@ -1,14 +1,34 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -21,20 +41,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -68,61 +83,61 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R8, R9, VF, ZF, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R0_2: bool; - var Gamma_R0_4: bool; - var Gamma_R8_3: bool; - var Gamma_R9_3: bool; - var R0_1: bv64; - var R0_2: bv64; - var R0_4: bv64; - var R8_3: bv64; - var R9_3: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); call rely(); - R9_3, Gamma_R9_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_3; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l000002f9, lmain_goto_l000002fd; - lmain_goto_l000002fd: - assume (!(R8_3[32:0] == 0bv32)); - R0_1, Gamma_R0_1 := zero_extend32_32(R9_3[32:0]), Gamma_R9_3; - R0_2, Gamma_R0_2 := R0_1, Gamma_R0_1; - R0_4, Gamma_R0_4 := R0_2, Gamma_R0_2; + l000002fd: + assume {:captureState "l000002fd"} true; + R0, Gamma_R0 := zero_extend32_32(R9[32:0]), Gamma_R9; goto l00000300; - lmain_goto_l000002f9: - assume (R8_3[32:0] == 0bv32); - R0_4, Gamma_R0_4 := 0bv64, true; + l000002f9: + assume {:captureState "l000002f9"} true; + R0, Gamma_R0 := 0bv64, true; goto l00000300; l00000300: + assume {:captureState "l00000300"} true; goto main_basil_return; + lmain_goto_l000002f9: + assume {:captureState "lmain_goto_l000002f9"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l000002f9; + lmain_goto_l000002fd: + assume {:captureState "lmain_goto_l000002fd"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l000002fd; main_basil_return: - R0_out, R8_out, R9_out := R0_4, R8_3, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_4, Gamma_R8_3, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader_gtirb.expected b/src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader_gtirb.expected index 082a9b06c..e49a87798 100644 --- a/src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader_gtirb.expected +++ b/src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader_gtirb.expected @@ -1,14 +1,33 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -21,20 +40,14 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -68,59 +81,52 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R8, R9, VF, ZF, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R0_2: bool; - var Gamma_R0_4: bool; - var Gamma_R8_3: bool; - var Gamma_R9_3: bool; - var R0_1: bv64; - var R0_2: bv64; - var R0_4: bv64; - var R8_3: bv64; - var R9_3: bv64; + var Cse0__5$0$4: bv32; + var Gamma_Cse0__5$0$4: bool; $main$__0__$ztKlXzTjTY~0ueqt2irBFw: + assume {:captureState "$main$__0__$ztKlXzTjTY~0ueqt2irBFw"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); call rely(); - R9_3, Gamma_R9_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_3; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); + Cse0__5$0$4, Gamma_Cse0__5$0$4 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$4, Cse0__5$0$4)), Gamma_Cse0__5$0$4; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$4), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$0$4); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$4, 0bv32), Gamma_Cse0__5$0$4; + NF, Gamma_NF := Cse0__5$0$4[32:31], Gamma_Cse0__5$0$4; + assert Gamma_ZF; goto $main$__0__$ztKlXzTjTY~0ueqt2irBFw$__0, $main$__0__$ztKlXzTjTY~0ueqt2irBFw$__1; - $main$__0__$ztKlXzTjTY~0ueqt2irBFw$__1: - assume (!(R8_3[32:0] == 0bv32)); - R0_1, Gamma_R0_1 := zero_extend32_32(R9_3[32:0]), Gamma_R9_3; - R0_2, Gamma_R0_2 := R0_1, Gamma_R0_1; - R0_4, Gamma_R0_4 := R0_2, Gamma_R0_2; - goto main_basil_return; $main$__0__$ztKlXzTjTY~0ueqt2irBFw$__0: - assume (R8_3[32:0] == 0bv32); - R0_4, Gamma_R0_4 := 0bv64, true; + assume {:captureState "$main$__0__$ztKlXzTjTY~0ueqt2irBFw$__0"} true; + assume (ZF == 1bv1); + R0, Gamma_R0 := 0bv64, true; + goto main_basil_return; + $main$__0__$ztKlXzTjTY~0ueqt2irBFw$__1: + assume {:captureState "$main$__0__$ztKlXzTjTY~0ueqt2irBFw$__1"} true; + assume (!(ZF == 1bv1)); + R0, Gamma_R0 := zero_extend32_32(R9[32:0]), Gamma_R9; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := R0_4, R8_3, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_4, Gamma_R8_3, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader.expected index 7f5bbfec7..1e3a52e27 100644 --- a/src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader.expected @@ -1,25 +1,36 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +40,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,30 +51,25 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -97,90 +99,105 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1980bv64) == 1bv8); - free requires (memory_load8_le(mem, 1981bv64) == 0bv8); - free requires (memory_load8_le(mem, 1982bv64) == 2bv8); - free requires (memory_load8_le(mem, 1983bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load32_le(mem, 1980bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_13: bool; - var Gamma_R8_14: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_5: bool; - var Gamma_R8_6: bool; - var R0_1: bv64; - var R8_11: bv64; - var R8_13: bv64; - var R8_14: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_5: bv64; - var R8_6: bv32; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000309"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_3); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000324"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_5, Gamma_R8_5 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - R8_6, Gamma_R8_6 := memory_load32_le(mem, R8_5), (gamma_load32(Gamma_mem, R8_5) || L(mem, R8_5)); - assert Gamma_R8_6; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000358, lmain_goto_l0000035b; - lmain_goto_l0000035b: - assume (!(R8_6 == 0bv32)); - R8_11, Gamma_R8_11 := 1bv64, true; + l0000035b: + assume {:captureState "l0000035b"} true; + R8, Gamma_R8 := 1bv64, true; goto l0000035e; - lmain_goto_l00000358: - assume (R8_6 == 0bv32); - R8_11, Gamma_R8_11 := 0bv64, true; + l00000358: + assume {:captureState "l00000358"} true; + R8, Gamma_R8 := 0bv64, true; goto l0000035e; l0000035e: - assert Gamma_R8_11; + assume {:captureState "l0000035e"} true; + assert Gamma_R8; goto l0000035e_goto_l00000366, l0000035e_goto_l00000390; - l0000035e_goto_l00000390: - assume (!(R8_11[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_14, Gamma_R8_14 := R8_11, Gamma_R8_11; + l00000366: + assume {:captureState "l00000366"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000378"} true; goto l0000037b; - l0000035e_goto_l00000366: - assume (R8_11[1:0] == 1bv1); - R8_13, Gamma_R8_13 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R8_13[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R8_13); - R8_14, Gamma_R8_14 := R8_13, Gamma_R8_13; + l00000390: + assume {:captureState "l00000390"} true; + goto l00000391; + l00000391: + assume {:captureState "l00000391"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000399"} true; goto l0000037b; l0000037b: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l0000037b"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000358: + assume {:captureState "lmain_goto_l00000358"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l00000358; + lmain_goto_l0000035b: + assume {:captureState "lmain_goto_l0000035b"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l0000035b; + l0000035e_goto_l00000366: + assume {:captureState "l0000035e_goto_l00000366"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l00000366; + l0000035e_goto_l00000390: + assume {:captureState "l0000035e_goto_l00000390"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000390; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_14; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_14; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader_gtirb.expected b/src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader_gtirb.expected index 10df7f41f..2cfb9fb78 100644 --- a/src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader_gtirb.expected +++ b/src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader_gtirb.expected @@ -1,25 +1,35 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +39,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,30 +50,24 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -97,103 +97,97 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1980bv64) == 1bv8); - free requires (memory_load8_le(mem, 1981bv64) == 0bv8); - free requires (memory_load8_le(mem, 1982bv64) == 2bv8); - free requires (memory_load8_le(mem, 1983bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load32_le(mem, 1980bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_12: bool; - var Gamma_R8_14: bool; - var Gamma_R8_15: bool; - var Gamma_R8_16: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_5: bool; - var Gamma_R8_6: bool; - var R0_1: bv64; - var R8_12: bv64; - var R8_14: bv64; - var R8_15: bv64; - var R8_16: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_5: bv64; - var R8_6: bv32; + var Cse0__5$4$9: bv32; + var Gamma_Cse0__5$4$9: bool; $main$__0__$3bYHxhsFQt~mkKcsNIgm0w: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$3bYHxhsFQt~mkKcsNIgm0w"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1880$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_3); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1896$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_5, Gamma_R8_5 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - R8_6, Gamma_R8_6 := memory_load32_le(mem, R8_5), (gamma_load32(Gamma_mem, R8_5) || L(mem, R8_5)); - assert Gamma_R8_6; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + Cse0__5$4$9, Gamma_Cse0__5$4$9 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$4$9, Cse0__5$4$9)), Gamma_Cse0__5$4$9; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$4$9), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$4$9); + ZF, Gamma_ZF := bvcomp32(Cse0__5$4$9, 0bv32), Gamma_Cse0__5$4$9; + NF, Gamma_NF := Cse0__5$4$9[32:31], Gamma_Cse0__5$4$9; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$4$9), Gamma_Cse0__5$4$9; + assert Gamma_ZF; goto $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__0, $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__1; - $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__1: - assume (!(R8_6 == 0bv32)); - goto $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__1_phi_$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__3__$q8ChuC7qRLCKpfOONmUiBw_phi_back_$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__3__$q8ChuC7qRLCKpfOONmUiBw, $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__1_phi_$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__1__$GliKhCDsS8OAMmKtmD1BCA_phi_back_$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__1__$GliKhCDsS8OAMmKtmD1BCA; - $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__1_phi_$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__1__$GliKhCDsS8OAMmKtmD1BCA_phi_back_$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__1__$GliKhCDsS8OAMmKtmD1BCA: - R8_12, Gamma_R8_12 := 1bv64, true; - assert Gamma_R8_12; - goto $main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__1__$GliKhCDsS8OAMmKtmD1BCA; - $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__1_phi_$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__3__$q8ChuC7qRLCKpfOONmUiBw_phi_back_$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__3__$q8ChuC7qRLCKpfOONmUiBw: - R8_14, Gamma_R8_14 := 1bv64, true; - assert Gamma_R8_14; - goto $main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__3__$q8ChuC7qRLCKpfOONmUiBw; - $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__0: - assume (R8_6 == 0bv32); - goto $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__0_phi_back_$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__1__$GliKhCDsS8OAMmKtmD1BCA, $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__0_phi_back_$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__3__$q8ChuC7qRLCKpfOONmUiBw; - $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__0_phi_back_$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__3__$q8ChuC7qRLCKpfOONmUiBw: - R8_14, Gamma_R8_14 := 0bv64, true; - assert Gamma_R8_14; - goto $main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__3__$q8ChuC7qRLCKpfOONmUiBw; - $main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__3__$q8ChuC7qRLCKpfOONmUiBw: - assume (R8_14[1:0] == 1bv1); - R8_15, Gamma_R8_15 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R8_15[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R8_15); - R8_16, Gamma_R8_16 := R8_15, Gamma_R8_15; + $main$__1__$GliKhCDsS8OAMmKtmD1BCA: + assume {:captureState "$main$__1__$GliKhCDsS8OAMmKtmD1BCA"} true; + goto $main$__2__$ixbm2b9SSu2JGcfJ0RoL5A; + $main$__2__$ixbm2b9SSu2JGcfJ0RoL5A: + assume {:captureState "$main$__2__$ixbm2b9SSu2JGcfJ0RoL5A"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1928$0"} true; goto $main$__4__$YaQJkGOMQVCrlScvBt8WoA; - $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__0_phi_back_$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__1__$GliKhCDsS8OAMmKtmD1BCA: - R8_12, Gamma_R8_12 := 0bv64, true; - assert Gamma_R8_12; - goto $main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__1__$GliKhCDsS8OAMmKtmD1BCA; - $main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__1__$GliKhCDsS8OAMmKtmD1BCA: - assume (!(R8_12[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_16, Gamma_R8_16 := R8_12, Gamma_R8_12; + $main$__3__$q8ChuC7qRLCKpfOONmUiBw: + assume {:captureState "$main$__3__$q8ChuC7qRLCKpfOONmUiBw"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1940$0"} true; goto $main$__4__$YaQJkGOMQVCrlScvBt8WoA; $main$__4__$YaQJkGOMQVCrlScvBt8WoA: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__4__$YaQJkGOMQVCrlScvBt8WoA"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__3__$q8ChuC7qRLCKpfOONmUiBw: + assume {:captureState "$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__3__$q8ChuC7qRLCKpfOONmUiBw"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$q8ChuC7qRLCKpfOONmUiBw; + $main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__1__$GliKhCDsS8OAMmKtmD1BCA: + assume {:captureState "$main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__1__$GliKhCDsS8OAMmKtmD1BCA"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$GliKhCDsS8OAMmKtmD1BCA; + $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__0: + assume {:captureState "$main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__3__$q8ChuC7qRLCKpfOONmUiBw, $main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__1__$GliKhCDsS8OAMmKtmD1BCA; + $main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__1: + assume {:captureState "$main$__0__$3bYHxhsFQt~mkKcsNIgm0w$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__3__$q8ChuC7qRLCKpfOONmUiBw, $main$__0__$3bYHxhsFQt~mkKcsNIgm0w_goto_$main$__1__$GliKhCDsS8OAMmKtmD1BCA; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_16; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_16; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/gcc/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/gcc/basic_function_call_reader.expected index f95f8340c..0298d6790 100644 --- a/src/test/correct/basic_function_call_reader/gcc/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/gcc/basic_function_call_reader.expected @@ -1,35 +1,40 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,24 +45,19 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -91,59 +91,69 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1892bv64) == 1bv8); - free requires (memory_load8_le(mem, 1893bv64) == 0bv8); - free requires (memory_load8_le(mem, 1894bv64) == 2bv8); - free requires (memory_load8_le(mem, 1895bv64) == 0bv8); + free requires (memory_load32_le(mem, 1892bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_3: bool; - var Gamma_R0_6: bool; - var Gamma_R0_9: bool; - var R0_10: bv64; - var R0_3: bv32; - var R0_6: bv32; - var R0_9: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69656bv64), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_3); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000304"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000332, lmain_goto_l00000349; - lmain_goto_l00000349: - assume (R0_6 == 0bv32); - R0_10, Gamma_R0_10 := 0bv64, true; + l00000332: + assume {:captureState "l00000332"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); goto l0000033e; - lmain_goto_l00000332: - assume (!(R0_6 == 0bv32)); - R0_9, Gamma_R0_9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - R0_10, Gamma_R0_10 := R0_9, Gamma_R0_9; + l00000349: + assume {:captureState "l00000349"} true; + R0, Gamma_R0 := 0bv64, true; goto l0000033e; l0000033e: + assume {:captureState "l0000033e"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000332: + assume {:captureState "lmain_goto_l00000332"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000332; + lmain_goto_l00000349: + assume {:captureState "lmain_goto_l00000349"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000349; main_basil_return: - R0_out, R31_out := R0_10, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_10, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/gcc/basic_function_call_reader_gtirb.expected b/src/test/correct/basic_function_call_reader/gcc/basic_function_call_reader_gtirb.expected index fd4fa71a4..6c7a57163 100644 --- a/src/test/correct/basic_function_call_reader/gcc/basic_function_call_reader_gtirb.expected +++ b/src/test/correct/basic_function_call_reader/gcc/basic_function_call_reader_gtirb.expected @@ -1,35 +1,39 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,24 +44,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -91,59 +89,69 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1892bv64) == 1bv8); - free requires (memory_load8_le(mem, 1893bv64) == 0bv8); - free requires (memory_load8_le(mem, 1894bv64) == 2bv8); - free requires (memory_load8_le(mem, 1895bv64) == 0bv8); + free requires (memory_load32_le(mem, 1892bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_3: bool; - var Gamma_R0_6: bool; - var Gamma_R0_9: bool; - var R0_10: bv64; - var R0_3: bv32; - var R0_6: bv32; - var R0_9: bv64; + var Cse0__5$3$8: bv32; + var Gamma_Cse0__5$3$8: bool; $main$__0__$Ux0Q3SQCTAWbVjaRM4YV_w: + assume {:captureState "$main$__0__$Ux0Q3SQCTAWbVjaRM4YV_w"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69656bv64), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_3); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1828$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$3$8, Gamma_Cse0__5$3$8 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$3$8, Cse0__5$3$8)), Gamma_Cse0__5$3$8; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$8), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$3$8); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$8, 0bv32), Gamma_Cse0__5$3$8; + NF, Gamma_NF := Cse0__5$3$8[32:31], Gamma_Cse0__5$3$8; + assert Gamma_ZF; goto $main$__0__$Ux0Q3SQCTAWbVjaRM4YV_w_goto_$main$__2__$MdKjK9_tS4CwsqOHpUajFA, $main$__0__$Ux0Q3SQCTAWbVjaRM4YV_w_goto_$main$__1__$HbG3EzSzT7SHv80IyKeGnw; - $main$__0__$Ux0Q3SQCTAWbVjaRM4YV_w_goto_$main$__1__$HbG3EzSzT7SHv80IyKeGnw: - assume (R0_6 == 0bv32); - R0_10, Gamma_R0_10 := 0bv64, true; + $main$__1__$HbG3EzSzT7SHv80IyKeGnw: + assume {:captureState "$main$__1__$HbG3EzSzT7SHv80IyKeGnw"} true; + R0, Gamma_R0 := 0bv64, true; goto $main$__3__$ArZKC0sNSe6_xTDy3J32hw; - $main$__0__$Ux0Q3SQCTAWbVjaRM4YV_w_goto_$main$__2__$MdKjK9_tS4CwsqOHpUajFA: - assume (!(R0_6 == 0bv32)); - R0_9, Gamma_R0_9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - R0_10, Gamma_R0_10 := R0_9, Gamma_R0_9; + $main$__2__$MdKjK9_tS4CwsqOHpUajFA: + assume {:captureState "$main$__2__$MdKjK9_tS4CwsqOHpUajFA"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); goto $main$__3__$ArZKC0sNSe6_xTDy3J32hw; $main$__3__$ArZKC0sNSe6_xTDy3J32hw: + assume {:captureState "$main$__3__$ArZKC0sNSe6_xTDy3J32hw"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$Ux0Q3SQCTAWbVjaRM4YV_w_goto_$main$__2__$MdKjK9_tS4CwsqOHpUajFA: + assume {:captureState "$main$__0__$Ux0Q3SQCTAWbVjaRM4YV_w_goto_$main$__2__$MdKjK9_tS4CwsqOHpUajFA"} true; + assume (!(ZF == 1bv1)); + goto $main$__2__$MdKjK9_tS4CwsqOHpUajFA; + $main$__0__$Ux0Q3SQCTAWbVjaRM4YV_w_goto_$main$__1__$HbG3EzSzT7SHv80IyKeGnw: + assume {:captureState "$main$__0__$Ux0Q3SQCTAWbVjaRM4YV_w_goto_$main$__1__$HbG3EzSzT7SHv80IyKeGnw"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__1__$HbG3EzSzT7SHv80IyKeGnw; main_basil_return: - R0_out, R31_out := R0_10, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_10, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/gcc_O2/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/gcc_O2/basic_function_call_reader.expected index ed7b56d68..24b255d49 100644 --- a/src/test/correct/basic_function_call_reader/gcc_O2/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/gcc_O2/basic_function_call_reader.expected @@ -1,14 +1,19 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -21,20 +26,13 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -68,55 +66,49 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_6: bool; - var R0_3: bv64; - var R0_4: bv64; - var R0_6: bv64; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R1, Gamma_R1 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := zero_extend32_32(memory_load32_le(mem, 69652bv64)), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R0, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R0, 20bv64)) || L(mem, bvadd64(R0, 20bv64))); + assert Gamma_R0; goto lmain_goto_l000001bc, lmain_goto_l00000398; - lmain_goto_l00000398: - assume (!(R0_3[32:0] == 0bv32)); + l00000398: + assume {:captureState "l00000398"} true; call rely(); - R0_4, Gamma_R0_4 := zero_extend32_32(memory_load32_le(mem, 69656bv64)), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - R0_6, Gamma_R0_6 := R0_4, Gamma_R0_4; - goto l000001bc; - lmain_goto_l000001bc: - assume (R0_3[32:0] == 0bv32); - R0_6, Gamma_R0_6 := R0_3, Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 4bv64)) || L(mem, bvadd64(R1, 4bv64))); goto l000001bc; l000001bc: + assume {:captureState "l000001bc"} true; goto main_basil_return; + lmain_goto_l000001bc: + assume {:captureState "lmain_goto_l000001bc"} true; + assume (bvcomp32(R0[32:0], 0bv32) != 0bv1); + goto l000001bc; + lmain_goto_l00000398: + assume {:captureState "lmain_goto_l00000398"} true; + assume (bvcomp32(R0[32:0], 0bv32) == 0bv1); + goto l00000398; main_basil_return: - R0_out, R1_out := R0_6, 69652bv64; - Gamma_R0_out, Gamma_R1_out := Gamma_R0_6, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/gcc_O2/basic_function_call_reader_gtirb.expected b/src/test/correct/basic_function_call_reader/gcc_O2/basic_function_call_reader_gtirb.expected index 9360fade4..e70c005df 100644 --- a/src/test/correct/basic_function_call_reader/gcc_O2/basic_function_call_reader_gtirb.expected +++ b/src/test/correct/basic_function_call_reader/gcc_O2/basic_function_call_reader_gtirb.expected @@ -1,11 +1,15 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); @@ -21,20 +25,13 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -68,55 +65,49 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_6: bool; - var R0_3: bv64; - var R0_4: bv64; - var R0_6: bv64; $main$__0__$dHiJQHnYTpm65oMaN9oFgA: + assume {:captureState "$main$__0__$dHiJQHnYTpm65oMaN9oFgA"} true; + R0, Gamma_R0 := 69632bv64, true; + R1, Gamma_R1 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := zero_extend32_32(memory_load32_le(mem, 69652bv64)), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R0, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R0, 20bv64)) || L(mem, bvadd64(R0, 20bv64))); + assert Gamma_R0; goto $main$__0__$dHiJQHnYTpm65oMaN9oFgA_goto_$main$__2__$5XEKQ4igS9uTmAyY~2l26Q, $main$__0__$dHiJQHnYTpm65oMaN9oFgA_goto_$main$__1__$_i5~WMZiQtmSmwJkk1py6w; - $main$__0__$dHiJQHnYTpm65oMaN9oFgA_goto_$main$__1__$_i5~WMZiQtmSmwJkk1py6w: - assume (!(R0_3[32:0] == 0bv32)); + $main$__1__$_i5~WMZiQtmSmwJkk1py6w: + assume {:captureState "$main$__1__$_i5~WMZiQtmSmwJkk1py6w"} true; call rely(); - R0_4, Gamma_R0_4 := zero_extend32_32(memory_load32_le(mem, 69656bv64)), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - R0_6, Gamma_R0_6 := R0_4, Gamma_R0_4; - goto $main$__2__$5XEKQ4igS9uTmAyY~2l26Q; - $main$__0__$dHiJQHnYTpm65oMaN9oFgA_goto_$main$__2__$5XEKQ4igS9uTmAyY~2l26Q: - assume (R0_3[32:0] == 0bv32); - R0_6, Gamma_R0_6 := R0_3, Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 4bv64)) || L(mem, bvadd64(R1, 4bv64))); goto $main$__2__$5XEKQ4igS9uTmAyY~2l26Q; $main$__2__$5XEKQ4igS9uTmAyY~2l26Q: + assume {:captureState "$main$__2__$5XEKQ4igS9uTmAyY~2l26Q"} true; goto main_basil_return; + $main$__0__$dHiJQHnYTpm65oMaN9oFgA_goto_$main$__2__$5XEKQ4igS9uTmAyY~2l26Q: + assume {:captureState "$main$__0__$dHiJQHnYTpm65oMaN9oFgA_goto_$main$__2__$5XEKQ4igS9uTmAyY~2l26Q"} true; + assume (R0[32:0] == 0bv32); + goto $main$__2__$5XEKQ4igS9uTmAyY~2l26Q; + $main$__0__$dHiJQHnYTpm65oMaN9oFgA_goto_$main$__1__$_i5~WMZiQtmSmwJkk1py6w: + assume {:captureState "$main$__0__$dHiJQHnYTpm65oMaN9oFgA_goto_$main$__1__$_i5~WMZiQtmSmwJkk1py6w"} true; + assume (!(R0[32:0] == 0bv32)); + goto $main$__1__$_i5~WMZiQtmSmwJkk1py6w; main_basil_return: - R0_out, R1_out := R0_6, 69652bv64; - Gamma_R0_out, Gamma_R1_out := Gamma_R0_6, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/gcc_pic/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/gcc_pic/basic_function_call_reader.expected index ee3a6e29f..8b7fd2872 100644 --- a/src/test/correct/basic_function_call_reader/gcc_pic/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/gcc_pic/basic_function_call_reader.expected @@ -1,25 +1,34 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +38,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,30 +49,25 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -97,71 +97,75 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1956bv64) == 1bv8); - free requires (memory_load8_le(mem, 1957bv64) == 0bv8); - free requires (memory_load8_le(mem, 1958bv64) == 2bv8); - free requires (memory_load8_le(mem, 1959bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1956bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_9: bool; - var R0_10: bv64; - var R0_2: bv64; - var R0_3: bv32; - var R0_5: bv64; - var R0_6: bv32; - var R0_9: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, R0_2), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_3); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000305"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, R0_5), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000334, lmain_goto_l0000034b; - lmain_goto_l0000034b: - assume (R0_6 == 0bv32); - R0_10, Gamma_R0_10 := 0bv64, true; + l00000334: + assume {:captureState "l00000334"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); goto l00000340; - lmain_goto_l00000334: - assume (!(R0_6 == 0bv32)); - R0_9, Gamma_R0_9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - R0_10, Gamma_R0_10 := R0_9, Gamma_R0_9; + l0000034b: + assume {:captureState "l0000034b"} true; + R0, Gamma_R0 := 0bv64, true; goto l00000340; l00000340: + assume {:captureState "l00000340"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000334: + assume {:captureState "lmain_goto_l00000334"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000334; + lmain_goto_l0000034b: + assume {:captureState "lmain_goto_l0000034b"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l0000034b; main_basil_return: - R0_out, R31_out := R0_10, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_10, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/gcc_pic/basic_function_call_reader_gtirb.expected b/src/test/correct/basic_function_call_reader/gcc_pic/basic_function_call_reader_gtirb.expected index 8eb2aa73f..fece62d2b 100644 --- a/src/test/correct/basic_function_call_reader/gcc_pic/basic_function_call_reader_gtirb.expected +++ b/src/test/correct/basic_function_call_reader/gcc_pic/basic_function_call_reader_gtirb.expected @@ -1,25 +1,33 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $y_addr) then (memory_load32_le(mem$in, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +37,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,30 +48,24 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -97,71 +95,75 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1956bv64) == 1bv8); - free requires (memory_load8_le(mem, 1957bv64) == 0bv8); - free requires (memory_load8_le(mem, 1958bv64) == 2bv8); - free requires (memory_load8_le(mem, 1959bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1956bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_9: bool; - var R0_10: bv64; - var R0_2: bv64; - var R0_3: bv32; - var R0_5: bv64; - var R0_6: bv32; - var R0_9: bv64; + var Cse0__5$1$8: bv32; + var Gamma_Cse0__5$1$8: bool; $main$__0__$XPSYuwk~QqCXXYlfch0U8A: + assume {:captureState "$main$__0__$XPSYuwk~QqCXXYlfch0U8A"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, R0_2), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_3); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1892$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, R0_5), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$1$8, Gamma_Cse0__5$1$8 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$1$8, Cse0__5$1$8)), Gamma_Cse0__5$1$8; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$1$8), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$1$8); + ZF, Gamma_ZF := bvcomp32(Cse0__5$1$8, 0bv32), Gamma_Cse0__5$1$8; + NF, Gamma_NF := Cse0__5$1$8[32:31], Gamma_Cse0__5$1$8; + assert Gamma_ZF; goto $main$__0__$XPSYuwk~QqCXXYlfch0U8A_goto_$main$__2__$YV9HrAzzRPueIlS9B6wdEg, $main$__0__$XPSYuwk~QqCXXYlfch0U8A_goto_$main$__1__$tezFaGT_RC6b4e~6~Bd7zA; - $main$__0__$XPSYuwk~QqCXXYlfch0U8A_goto_$main$__1__$tezFaGT_RC6b4e~6~Bd7zA: - assume (R0_6 == 0bv32); - R0_10, Gamma_R0_10 := 0bv64, true; + $main$__1__$tezFaGT_RC6b4e~6~Bd7zA: + assume {:captureState "$main$__1__$tezFaGT_RC6b4e~6~Bd7zA"} true; + R0, Gamma_R0 := 0bv64, true; goto $main$__3__$BzeSfzsYQfagBIn19G60Ng; - $main$__0__$XPSYuwk~QqCXXYlfch0U8A_goto_$main$__2__$YV9HrAzzRPueIlS9B6wdEg: - assume (!(R0_6 == 0bv32)); - R0_9, Gamma_R0_9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - R0_10, Gamma_R0_10 := R0_9, Gamma_R0_9; + $main$__2__$YV9HrAzzRPueIlS9B6wdEg: + assume {:captureState "$main$__2__$YV9HrAzzRPueIlS9B6wdEg"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); goto $main$__3__$BzeSfzsYQfagBIn19G60Ng; $main$__3__$BzeSfzsYQfagBIn19G60Ng: + assume {:captureState "$main$__3__$BzeSfzsYQfagBIn19G60Ng"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$XPSYuwk~QqCXXYlfch0U8A_goto_$main$__2__$YV9HrAzzRPueIlS9B6wdEg: + assume {:captureState "$main$__0__$XPSYuwk~QqCXXYlfch0U8A_goto_$main$__2__$YV9HrAzzRPueIlS9B6wdEg"} true; + assume (!(ZF == 1bv1)); + goto $main$__2__$YV9HrAzzRPueIlS9B6wdEg; + $main$__0__$XPSYuwk~QqCXXYlfch0U8A_goto_$main$__1__$tezFaGT_RC6b4e~6~Bd7zA: + assume {:captureState "$main$__0__$XPSYuwk~QqCXXYlfch0U8A_goto_$main$__1__$tezFaGT_RC6b4e~6~Bd7zA"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__1__$tezFaGT_RC6b4e~6~Bd7zA; main_basil_return: - R0_out, R31_out := R0_10, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_10, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_read/clang/basic_lock_read.expected b/src/test/correct/basic_lock_read/clang/basic_lock_read.expected index 4d66cf94e..318bf0e75 100644 --- a/src/test/correct/basic_lock_read/clang/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/clang/basic_lock_read.expected @@ -1,35 +1,42 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +47,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -87,81 +89,99 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1900bv64) == 1bv8); - free requires (memory_load8_le(mem, 1901bv64) == 0bv8); - free requires (memory_load8_le(mem, 1902bv64) == 2bv8); - free requires (memory_load8_le(mem, 1903bv64) == 0bv8); + free requires (memory_load32_le(mem, 1900bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - ensures (R0_out[32:0] == 0bv32); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + ensures (R0[32:0] == 0bv32); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_2: bool; - var Gamma_R8_7: bool; - var Gamma_R8_9: bool; - var R0_1: bv64; - var R8_11: bv64; - var R8_2: bv32; - var R8_7: bv64; - var R8_9: bv64; + var #4: bv32; + var Gamma_#4: bool; var z_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f9"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000300"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l0000032d, lmain_goto_l00000330; - lmain_goto_l00000330: - assume (!(R8_2 == 0bv32)); - R8_7, Gamma_R8_7 := 1bv64, true; + l00000330: + assume {:captureState "l00000330"} true; + R8, Gamma_R8 := 1bv64, true; goto l00000333; - lmain_goto_l0000032d: - assume (R8_2 == 0bv32); - R8_7, Gamma_R8_7 := 0bv64, true; + l0000032d: + assume {:captureState "l0000032d"} true; + R8, Gamma_R8 := 0bv64, true; goto l00000333; l00000333: - assert Gamma_R8_7; + assume {:captureState "l00000333"} true; + assert Gamma_R8; goto l00000333_goto_l0000033b, l00000333_goto_l00000352; - l00000333_goto_l00000352: - assume (!(R8_7[1:0] == 1bv1)); + l00000352: + assume {:captureState "l00000352"} true; + goto l00000353; + l00000353: + assume {:captureState "l00000353"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); + assert (L(mem, bvadd64(R8, 56bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 0bv32), gamma_store32(Gamma_mem, 69688bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "%00000360"} true; call rely(); - R8_9, Gamma_R8_9 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_9[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_9); - R8_11, Gamma_R8_11 := R8_9, Gamma_R8_9; - goto l0000033b; - l00000333_goto_l0000033b: - assume (R8_7[1:0] == 1bv1); - R8_11, Gamma_R8_11 := R8_7, Gamma_R8_7; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000036f"} true; goto l0000033b; l0000033b: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "l0000033b"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l0000032d: + assume {:captureState "lmain_goto_l0000032d"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l0000032d; + lmain_goto_l00000330: + assume {:captureState "lmain_goto_l00000330"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l00000330; + l00000333_goto_l0000033b: + assume {:captureState "l00000333_goto_l0000033b"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l0000033b; + l00000333_goto_l00000352: + assume {:captureState "l00000333_goto_l00000352"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000352; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_11; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_11; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_read/clang/basic_lock_read_gtirb.expected b/src/test/correct/basic_lock_read/clang/basic_lock_read_gtirb.expected index 87df30def..e4f7d61f9 100644 --- a/src/test/correct/basic_lock_read/clang/basic_lock_read_gtirb.expected +++ b/src/test/correct/basic_lock_read/clang/basic_lock_read_gtirb.expected @@ -1,35 +1,41 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +46,17 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -87,94 +87,91 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1900bv64) == 1bv8); - free requires (memory_load8_le(mem, 1901bv64) == 0bv8); - free requires (memory_load8_le(mem, 1902bv64) == 2bv8); - free requires (memory_load8_le(mem, 1903bv64) == 0bv8); + free requires (memory_load32_le(mem, 1900bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - ensures (R0_out[32:0] == 0bv32); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + ensures (R0[32:0] == 0bv32); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_12: bool; - var Gamma_R8_13: bool; - var Gamma_R8_2: bool; - var Gamma_R8_8: bool; - var R0_1: bv64; - var R8_10: bv64; - var R8_12: bv64; - var R8_13: bv64; - var R8_2: bv32; - var R8_8: bv64; + var Cse0__5$2$5: bv32; + var Gamma_Cse0__5$2$5: bool; var z_old: bv32; $main$__0__$rFLbTMieRHaXyRDy_WM9nA: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + assume {:captureState "$main$__0__$rFLbTMieRHaXyRDy_WM9nA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1816$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "1820$0"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + Cse0__5$2$5, Gamma_Cse0__5$2$5 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$2$5, Cse0__5$2$5)), Gamma_Cse0__5$2$5; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$2$5), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$2$5); + ZF, Gamma_ZF := bvcomp32(Cse0__5$2$5, 0bv32), Gamma_Cse0__5$2$5; + NF, Gamma_NF := Cse0__5$2$5[32:31], Gamma_Cse0__5$2$5; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$2$5), Gamma_Cse0__5$2$5; + assert Gamma_ZF; goto $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__0, $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__1; - $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__1: - assume (!(R8_2 == 0bv32)); - goto $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__1_phi_$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__3__$cw51Ok56RY~0vRv0O7D67Q_phi_back_$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__3__$cw51Ok56RY~0vRv0O7D67Q, $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__1_phi_$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__1__$24kG8YkCTZOdLFRKQWWeuQ_phi_back_$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__1__$24kG8YkCTZOdLFRKQWWeuQ; - $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__1_phi_$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__1__$24kG8YkCTZOdLFRKQWWeuQ_phi_back_$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__1__$24kG8YkCTZOdLFRKQWWeuQ: - R8_8, Gamma_R8_8 := 1bv64, true; - assert Gamma_R8_8; - goto $main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__1__$24kG8YkCTZOdLFRKQWWeuQ; - $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__1_phi_$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__3__$cw51Ok56RY~0vRv0O7D67Q_phi_back_$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__3__$cw51Ok56RY~0vRv0O7D67Q: - R8_12, Gamma_R8_12 := 1bv64, true; - assert Gamma_R8_12; - goto $main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__3__$cw51Ok56RY~0vRv0O7D67Q; - $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__0: - assume (R8_2 == 0bv32); - goto $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__0_phi_back_$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__1__$24kG8YkCTZOdLFRKQWWeuQ, $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__0_phi_back_$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__3__$cw51Ok56RY~0vRv0O7D67Q; - $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__0_phi_back_$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__3__$cw51Ok56RY~0vRv0O7D67Q: - R8_12, Gamma_R8_12 := 0bv64, true; - assert Gamma_R8_12; - goto $main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__3__$cw51Ok56RY~0vRv0O7D67Q; - $main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__3__$cw51Ok56RY~0vRv0O7D67Q: - assume (R8_12[1:0] == 1bv1); - R8_13, Gamma_R8_13 := R8_12, Gamma_R8_12; - goto $main$__3__$cw51Ok56RY~0vRv0O7D67Q; - $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__0_phi_back_$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__1__$24kG8YkCTZOdLFRKQWWeuQ: - R8_8, Gamma_R8_8 := 0bv64, true; - assert Gamma_R8_8; - goto $main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__1__$24kG8YkCTZOdLFRKQWWeuQ; - $main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__1__$24kG8YkCTZOdLFRKQWWeuQ: - assume (!(R8_8[1:0] == 1bv1)); + $main$__1__$24kG8YkCTZOdLFRKQWWeuQ: + assume {:captureState "$main$__1__$24kG8YkCTZOdLFRKQWWeuQ"} true; + goto $main$__2__$Uq6ddtMrQtqVC9c4DWnGkw; + $main$__2__$Uq6ddtMrQtqVC9c4DWnGkw: + assume {:captureState "$main$__2__$Uq6ddtMrQtqVC9c4DWnGkw"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); + assert (L(mem, bvadd64(R8, 56bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 0bv32), gamma_store32(Gamma_mem, 69688bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "1852$0"} true; call rely(); - R8_10, Gamma_R8_10 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_10[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_10); - R8_13, Gamma_R8_13 := R8_10, Gamma_R8_10; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1860$0"} true; goto $main$__3__$cw51Ok56RY~0vRv0O7D67Q; $main$__3__$cw51Ok56RY~0vRv0O7D67Q: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__3__$cw51Ok56RY~0vRv0O7D67Q"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__3__$cw51Ok56RY~0vRv0O7D67Q: + assume {:captureState "$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__3__$cw51Ok56RY~0vRv0O7D67Q"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$cw51Ok56RY~0vRv0O7D67Q; + $main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__1__$24kG8YkCTZOdLFRKQWWeuQ: + assume {:captureState "$main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__1__$24kG8YkCTZOdLFRKQWWeuQ"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$24kG8YkCTZOdLFRKQWWeuQ; + $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__0: + assume {:captureState "$main$__0__$rFLbTMieRHaXyRDy_WM9nA$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__3__$cw51Ok56RY~0vRv0O7D67Q, $main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__1__$24kG8YkCTZOdLFRKQWWeuQ; + $main$__0__$rFLbTMieRHaXyRDy_WM9nA$__1: + assume {:captureState "$main$__0__$rFLbTMieRHaXyRDy_WM9nA$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__3__$cw51Ok56RY~0vRv0O7D67Q, $main$__0__$rFLbTMieRHaXyRDy_WM9nA_goto_$main$__1__$24kG8YkCTZOdLFRKQWWeuQ; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_13; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_13; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_read/clang_O2/basic_lock_read.expected b/src/test/correct/basic_lock_read/clang_O2/basic_lock_read.expected index 5d574858b..2391ae1ea 100644 --- a/src/test/correct/basic_lock_read/clang_O2/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/clang_O2/basic_lock_read.expected @@ -1,33 +1,25 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +30,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +39,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -85,56 +70,57 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_mem, R0, R8, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - ensures (R0_out[32:0] == 0bv32); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + ensures (R0[32:0] == 0bv32); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var Gamma_R8_6: bool; - var R8_3: bv64; - var R8_6: bv64; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + assert Gamma_R8; goto lmain_goto_l000002dc, lmain_goto_l000002f7; - lmain_goto_l000002f7: - assume (!(R8_3[32:0] == 0bv32)); - R8_6, Gamma_R8_6 := R8_3, Gamma_R8_3; - goto main_basil_return; - lmain_goto_l000002dc: - assume (R8_3[32:0] == 0bv32); + l000002dc: + assume {:captureState "l000002dc"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); + assert (L(mem, bvadd64(R8, 56bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 0bv32), gamma_store32(Gamma_mem, 69688bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert (memory_load32_le(mem, $z_addr) == z_old); - R8_6, Gamma_R8_6 := 69632bv64, true; + assume {:captureState "%000002eb"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + l000002f7: + assume {:captureState "l000002f7"} true; + R0, Gamma_R0 := 0bv64, true; + goto main_basil_return; + lmain_goto_l000002dc: + assume {:captureState "lmain_goto_l000002dc"} true; + assume (bvcomp32(R8[32:0], 0bv32) != 0bv1); + goto l000002dc; + lmain_goto_l000002f7: + assume {:captureState "lmain_goto_l000002f7"} true; + assume (bvcomp32(R8[32:0], 0bv32) == 0bv1); + goto l000002f7; main_basil_return: - R0_out, R8_out := 0bv64, R8_6; - Gamma_R0_out, Gamma_R8_out := true, Gamma_R8_6; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_read/clang_O2/basic_lock_read_gtirb.expected b/src/test/correct/basic_lock_read/clang_O2/basic_lock_read_gtirb.expected index e62be1a55..117b59484 100644 --- a/src/test/correct/basic_lock_read/clang_O2/basic_lock_read_gtirb.expected +++ b/src/test/correct/basic_lock_read/clang_O2/basic_lock_read_gtirb.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +29,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +38,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -85,56 +69,57 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_mem, R0, R8, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - ensures (R0_out[32:0] == 0bv32); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + ensures (R0[32:0] == 0bv32); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var Gamma_R8_6: bool; - var R8_3: bv64; - var R8_6: bv64; var z_old: bv32; $main$__0__$WS3unIRvQP~HMbu0zRO9Wg: + assume {:captureState "$main$__0__$WS3unIRvQP~HMbu0zRO9Wg"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + assert Gamma_R8; goto $main$__0__$WS3unIRvQP~HMbu0zRO9Wg_goto_$main$__2__$lHXxwUQYROKiGyY65vpP1Q, $main$__0__$WS3unIRvQP~HMbu0zRO9Wg_goto_$main$__1__$VRrOrprpRgq70GRGqvu1TQ; - $main$__0__$WS3unIRvQP~HMbu0zRO9Wg_goto_$main$__1__$VRrOrprpRgq70GRGqvu1TQ: - assume (!(R8_3[32:0] == 0bv32)); - R8_6, Gamma_R8_6 := R8_3, Gamma_R8_3; + $main$__1__$VRrOrprpRgq70GRGqvu1TQ: + assume {:captureState "$main$__1__$VRrOrprpRgq70GRGqvu1TQ"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; - $main$__0__$WS3unIRvQP~HMbu0zRO9Wg_goto_$main$__2__$lHXxwUQYROKiGyY65vpP1Q: - assume (R8_3[32:0] == 0bv32); + $main$__2__$lHXxwUQYROKiGyY65vpP1Q: + assume {:captureState "$main$__2__$lHXxwUQYROKiGyY65vpP1Q"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); + assert (L(mem, bvadd64(R8, 56bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 0bv32), gamma_store32(Gamma_mem, 69688bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert (memory_load32_le(mem, $z_addr) == z_old); - R8_6, Gamma_R8_6 := 69632bv64, true; + assume {:captureState "1836$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + $main$__0__$WS3unIRvQP~HMbu0zRO9Wg_goto_$main$__2__$lHXxwUQYROKiGyY65vpP1Q: + assume {:captureState "$main$__0__$WS3unIRvQP~HMbu0zRO9Wg_goto_$main$__2__$lHXxwUQYROKiGyY65vpP1Q"} true; + assume (R8[32:0] == 0bv32); + goto $main$__2__$lHXxwUQYROKiGyY65vpP1Q; + $main$__0__$WS3unIRvQP~HMbu0zRO9Wg_goto_$main$__1__$VRrOrprpRgq70GRGqvu1TQ: + assume {:captureState "$main$__0__$WS3unIRvQP~HMbu0zRO9Wg_goto_$main$__1__$VRrOrprpRgq70GRGqvu1TQ"} true; + assume (!(R8[32:0] == 0bv32)); + goto $main$__1__$VRrOrprpRgq70GRGqvu1TQ; main_basil_return: - R0_out, R8_out := 0bv64, R8_6; - Gamma_R0_out, Gamma_R8_out := true, Gamma_R8_6; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_read/clang_pic/basic_lock_read.expected b/src/test/correct/basic_lock_read/clang_pic/basic_lock_read.expected index 426ccf12f..a46a23494 100644 --- a/src/test/correct/basic_lock_read/clang_pic/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/clang_pic/basic_lock_read.expected @@ -1,25 +1,36 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +40,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,29 +51,24 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1972bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1973bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1974bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1975bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1972bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,93 +95,107 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1972bv64) == 1bv8); - free requires (memory_load8_le(mem, 1973bv64) == 0bv8); - free requires (memory_load8_le(mem, 1974bv64) == 2bv8); - free requires (memory_load8_le(mem, 1975bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1972bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - ensures (R0_out[32:0] == 0bv32); - free ensures (memory_load8_le(mem, 1972bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1973bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1974bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1975bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + ensures (R0[32:0] == 0bv32); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1972bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_11: bool; - var Gamma_R8_13: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_8: bool; - var R0_1: bv64; - var R8_10: bv64; - var R8_11: bv64; - var R8_13: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_8: bv64; + var #4: bv32; + var Gamma_#4: bool; var z_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000301"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000308"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l0000033c, lmain_goto_l0000033f; - lmain_goto_l0000033f: - assume (!(R8_3 == 0bv32)); - R8_8, Gamma_R8_8 := 1bv64, true; + l0000033f: + assume {:captureState "l0000033f"} true; + R8, Gamma_R8 := 1bv64, true; goto l00000342; - lmain_goto_l0000033c: - assume (R8_3 == 0bv32); - R8_8, Gamma_R8_8 := 0bv64, true; + l0000033c: + assume {:captureState "l0000033c"} true; + R8, Gamma_R8 := 0bv64, true; goto l00000342; l00000342: - assert Gamma_R8_8; + assume {:captureState "l00000342"} true; + assert Gamma_R8; goto l00000342_goto_l0000034a, l00000342_goto_l00000361; - l00000342_goto_l00000361: - assume (!(R8_8[1:0] == 1bv1)); + l00000361: + assume {:captureState "l00000361"} true; + goto l00000362; + l00000362: + assume {:captureState "l00000362"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_10, Gamma_R8_10 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); - assert (L(mem, R8_10) ==> true); + assert (L(mem, R8) ==> true); z_old := memory_load32_le(mem, $z_addr); - mem, Gamma_mem := memory_store32_le(mem, R8_10, 0bv32), gamma_store32(Gamma_mem, R8_10, true); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "%00000376"} true; call rely(); - R8_11, Gamma_R8_11 := zero_extend32_32(memory_load32_le(mem, R8_10)), (gamma_load32(Gamma_mem, R8_10) || L(mem, R8_10)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_11[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_11); - R8_13, Gamma_R8_13 := R8_11, Gamma_R8_11; - goto l0000034a; - l00000342_goto_l0000034a: - assume (R8_8[1:0] == 1bv1); - R8_13, Gamma_R8_13 := R8_8, Gamma_R8_8; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000385"} true; goto l0000034a; l0000034a: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "l0000034a"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l0000033c: + assume {:captureState "lmain_goto_l0000033c"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l0000033c; + lmain_goto_l0000033f: + assume {:captureState "lmain_goto_l0000033f"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l0000033f; + l00000342_goto_l0000034a: + assume {:captureState "l00000342_goto_l0000034a"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l0000034a; + l00000342_goto_l00000361: + assume {:captureState "l00000342_goto_l00000361"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000361; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_13; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_13; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_read/clang_pic/basic_lock_read_gtirb.expected b/src/test/correct/basic_lock_read/clang_pic/basic_lock_read_gtirb.expected index 147b4600b..141222e9a 100644 --- a/src/test/correct/basic_lock_read/clang_pic/basic_lock_read_gtirb.expected +++ b/src/test/correct/basic_lock_read/clang_pic/basic_lock_read_gtirb.expected @@ -1,25 +1,35 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +39,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,29 +50,23 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1972bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1973bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1974bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1975bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1972bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,106 +93,99 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1972bv64) == 1bv8); - free requires (memory_load8_le(mem, 1973bv64) == 0bv8); - free requires (memory_load8_le(mem, 1974bv64) == 2bv8); - free requires (memory_load8_le(mem, 1975bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1972bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - ensures (R0_out[32:0] == 0bv32); - free ensures (memory_load8_le(mem, 1972bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1973bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1974bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1975bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + ensures (R0[32:0] == 0bv32); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1972bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_12: bool; - var Gamma_R8_14: bool; - var Gamma_R8_15: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_9: bool; - var R0_1: bv64; - var R8_11: bv64; - var R8_12: bv64; - var R8_14: bv64; - var R8_15: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_9: bv64; + var Cse0__5$2$6: bv32; + var Gamma_Cse0__5$2$6: bool; var z_old: bv32; $main$__0__$sDgL5ErbRei_PI97mOM34Q: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + assume {:captureState "$main$__0__$sDgL5ErbRei_PI97mOM34Q"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1880$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "1884$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + Cse0__5$2$6, Gamma_Cse0__5$2$6 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$2$6, Cse0__5$2$6)), Gamma_Cse0__5$2$6; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$2$6), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$2$6); + ZF, Gamma_ZF := bvcomp32(Cse0__5$2$6, 0bv32), Gamma_Cse0__5$2$6; + NF, Gamma_NF := Cse0__5$2$6[32:31], Gamma_Cse0__5$2$6; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$2$6), Gamma_Cse0__5$2$6; + assert Gamma_ZF; goto $main$__0__$sDgL5ErbRei_PI97mOM34Q$__0, $main$__0__$sDgL5ErbRei_PI97mOM34Q$__1; - $main$__0__$sDgL5ErbRei_PI97mOM34Q$__1: - assume (!(R8_3 == 0bv32)); - goto $main$__0__$sDgL5ErbRei_PI97mOM34Q$__1_phi_$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__3__$txO5s~pWRamQAjZH4_ZIww_phi_back_$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__3__$txO5s~pWRamQAjZH4_ZIww, $main$__0__$sDgL5ErbRei_PI97mOM34Q$__1_phi_$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ_phi_back_$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ; - $main$__0__$sDgL5ErbRei_PI97mOM34Q$__1_phi_$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ_phi_back_$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ: - R8_9, Gamma_R8_9 := 1bv64, true; - assert Gamma_R8_9; - goto $main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ; - $main$__0__$sDgL5ErbRei_PI97mOM34Q$__1_phi_$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__3__$txO5s~pWRamQAjZH4_ZIww_phi_back_$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__3__$txO5s~pWRamQAjZH4_ZIww: - R8_14, Gamma_R8_14 := 1bv64, true; - assert Gamma_R8_14; - goto $main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__3__$txO5s~pWRamQAjZH4_ZIww; - $main$__0__$sDgL5ErbRei_PI97mOM34Q$__0: - assume (R8_3 == 0bv32); - goto $main$__0__$sDgL5ErbRei_PI97mOM34Q$__0_phi_back_$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ, $main$__0__$sDgL5ErbRei_PI97mOM34Q$__0_phi_back_$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__3__$txO5s~pWRamQAjZH4_ZIww; - $main$__0__$sDgL5ErbRei_PI97mOM34Q$__0_phi_back_$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__3__$txO5s~pWRamQAjZH4_ZIww: - R8_14, Gamma_R8_14 := 0bv64, true; - assert Gamma_R8_14; - goto $main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__3__$txO5s~pWRamQAjZH4_ZIww; - $main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__3__$txO5s~pWRamQAjZH4_ZIww: - assume (R8_14[1:0] == 1bv1); - R8_15, Gamma_R8_15 := R8_14, Gamma_R8_14; - goto $main$__3__$txO5s~pWRamQAjZH4_ZIww; - $main$__0__$sDgL5ErbRei_PI97mOM34Q$__0_phi_back_$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ: - R8_9, Gamma_R8_9 := 0bv64, true; - assert Gamma_R8_9; - goto $main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ; - $main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ: - assume (!(R8_9[1:0] == 1bv1)); + $main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ: + assume {:captureState "$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ"} true; + goto $main$__2__$gV96_A0qQxOx5WBiTMjRhw; + $main$__2__$gV96_A0qQxOx5WBiTMjRhw: + assume {:captureState "$main$__2__$gV96_A0qQxOx5WBiTMjRhw"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_11, Gamma_R8_11 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); - assert (L(mem, R8_11) ==> true); + assert (L(mem, R8) ==> true); z_old := memory_load32_le(mem, $z_addr); - mem, Gamma_mem := memory_store32_le(mem, R8_11, 0bv32), gamma_store32(Gamma_mem, R8_11, true); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "1924$0"} true; call rely(); - R8_12, Gamma_R8_12 := zero_extend32_32(memory_load32_le(mem, R8_11)), (gamma_load32(Gamma_mem, R8_11) || L(mem, R8_11)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_12[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_12); - R8_15, Gamma_R8_15 := R8_12, Gamma_R8_12; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1932$0"} true; goto $main$__3__$txO5s~pWRamQAjZH4_ZIww; $main$__3__$txO5s~pWRamQAjZH4_ZIww: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__3__$txO5s~pWRamQAjZH4_ZIww"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__3__$txO5s~pWRamQAjZH4_ZIww: + assume {:captureState "$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__3__$txO5s~pWRamQAjZH4_ZIww"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$txO5s~pWRamQAjZH4_ZIww; + $main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ: + assume {:captureState "$main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ; + $main$__0__$sDgL5ErbRei_PI97mOM34Q$__0: + assume {:captureState "$main$__0__$sDgL5ErbRei_PI97mOM34Q$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__3__$txO5s~pWRamQAjZH4_ZIww, $main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ; + $main$__0__$sDgL5ErbRei_PI97mOM34Q$__1: + assume {:captureState "$main$__0__$sDgL5ErbRei_PI97mOM34Q$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__3__$txO5s~pWRamQAjZH4_ZIww, $main$__0__$sDgL5ErbRei_PI97mOM34Q_goto_$main$__1__$Fh8Bafn_SSyRCR_S9MtmNQ; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_15; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_15; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_read/gcc/basic_lock_read.expected b/src/test/correct/basic_lock_read/gcc/basic_lock_read.expected index 99cab38e4..c4a5478c8 100644 --- a/src/test/correct/basic_lock_read/gcc/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/gcc/basic_lock_read.expected @@ -1,35 +1,40 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +45,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -87,63 +87,77 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1900bv64) == 1bv8); - free requires (memory_load8_le(mem, 1901bv64) == 0bv8); - free requires (memory_load8_le(mem, 1902bv64) == 2bv8); - free requires (memory_load8_le(mem, 1903bv64) == 0bv8); + free requires (memory_load32_le(mem, 1900bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - ensures (R0_out[32:0] == 0bv32); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + ensures (R0[32:0] == 0bv32); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_8: bool; - var Gamma_R0_9: bool; - var R0_3: bv32; - var R0_8: bv32; - var R0_9: bv64; + var #4: bv32; + var Gamma_#4: bool; var z_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f9"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69656bv64), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - assert Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000327, lmain_goto_l0000033e; - lmain_goto_l0000033e: - assume (R0_3 == 0bv32); + l0000033e: + assume {:captureState "l0000033e"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 0bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "%0000034e"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_8, Gamma_R0_8 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_8), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_8); - goto l00000327; - lmain_goto_l00000327: - assume (!(R0_3 == 0bv32)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000368"} true; goto l00000327; l00000327: - R0_9, Gamma_R0_9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l00000327"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000327: + assume {:captureState "lmain_goto_l00000327"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000327; + lmain_goto_l0000033e: + assume {:captureState "lmain_goto_l0000033e"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l0000033e; main_basil_return: - R0_out, R31_out := R0_9, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_9, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_read/gcc/basic_lock_read_gtirb.expected b/src/test/correct/basic_lock_read/gcc/basic_lock_read_gtirb.expected index a29da722d..79302e24b 100644 --- a/src/test/correct/basic_lock_read/gcc/basic_lock_read_gtirb.expected +++ b/src/test/correct/basic_lock_read/gcc/basic_lock_read_gtirb.expected @@ -1,35 +1,39 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +44,17 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -87,63 +85,77 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1900bv64) == 1bv8); - free requires (memory_load8_le(mem, 1901bv64) == 0bv8); - free requires (memory_load8_le(mem, 1902bv64) == 2bv8); - free requires (memory_load8_le(mem, 1903bv64) == 0bv8); + free requires (memory_load32_le(mem, 1900bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - ensures (R0_out[32:0] == 0bv32); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + ensures (R0[32:0] == 0bv32); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_8: bool; - var Gamma_R0_9: bool; - var R0_3: bv32; - var R0_8: bv32; - var R0_9: bv64; + var Cse0__5$0$5: bv32; + var Gamma_Cse0__5$0$5: bool; var z_old: bv32; $main$__0__$CCtRsxbhQvGXpnMRl7qS2g: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$CCtRsxbhQvGXpnMRl7qS2g"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1816$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69656bv64), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - assert Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$0$5, Gamma_Cse0__5$0$5 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$5, Cse0__5$0$5)), Gamma_Cse0__5$0$5; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$5), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$0$5); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$5, 0bv32), Gamma_Cse0__5$0$5; + NF, Gamma_NF := Cse0__5$0$5[32:31], Gamma_Cse0__5$0$5; + assert Gamma_ZF; goto $main$__0__$CCtRsxbhQvGXpnMRl7qS2g_goto_$main$__2__$4eAAAye2Sq21c9DcyPaaBA, $main$__0__$CCtRsxbhQvGXpnMRl7qS2g_goto_$main$__1__$h_~YJv9RRmGHTPS4vJZEVA; - $main$__0__$CCtRsxbhQvGXpnMRl7qS2g_goto_$main$__1__$h_~YJv9RRmGHTPS4vJZEVA: - assume (R0_3 == 0bv32); + $main$__1__$h_~YJv9RRmGHTPS4vJZEVA: + assume {:captureState "$main$__1__$h_~YJv9RRmGHTPS4vJZEVA"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 0bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "1848$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_8, Gamma_R0_8 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_8), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_8); - goto $main$__2__$4eAAAye2Sq21c9DcyPaaBA; - $main$__0__$CCtRsxbhQvGXpnMRl7qS2g_goto_$main$__2__$4eAAAye2Sq21c9DcyPaaBA: - assume (!(R0_3 == 0bv32)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1864$0"} true; goto $main$__2__$4eAAAye2Sq21c9DcyPaaBA; $main$__2__$4eAAAye2Sq21c9DcyPaaBA: - R0_9, Gamma_R0_9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__2__$4eAAAye2Sq21c9DcyPaaBA"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$CCtRsxbhQvGXpnMRl7qS2g_goto_$main$__2__$4eAAAye2Sq21c9DcyPaaBA: + assume {:captureState "$main$__0__$CCtRsxbhQvGXpnMRl7qS2g_goto_$main$__2__$4eAAAye2Sq21c9DcyPaaBA"} true; + assume (!(ZF == 1bv1)); + goto $main$__2__$4eAAAye2Sq21c9DcyPaaBA; + $main$__0__$CCtRsxbhQvGXpnMRl7qS2g_goto_$main$__1__$h_~YJv9RRmGHTPS4vJZEVA: + assume {:captureState "$main$__0__$CCtRsxbhQvGXpnMRl7qS2g_goto_$main$__1__$h_~YJv9RRmGHTPS4vJZEVA"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__1__$h_~YJv9RRmGHTPS4vJZEVA; main_basil_return: - R0_out, R31_out := R0_9, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_9, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_read/gcc_O2/basic_lock_read.expected b/src/test/correct/basic_lock_read/gcc_O2/basic_lock_read.expected index 909a32d75..4a49039ba 100644 --- a/src/test/correct/basic_lock_read/gcc_O2/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/gcc_O2/basic_lock_read.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,22 +31,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -84,54 +71,56 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - ensures (R0_out[32:0] == 0bv32); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (R0[32:0] == 0bv32); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var R0_3: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R1, Gamma_R1 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R0, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R0, 20bv64)) || L(mem, bvadd64(R0, 20bv64))); + assert Gamma_R0; goto lmain_goto_l000001bd, lmain_goto_l0000039c; - lmain_goto_l0000039c: - assume (R0_3 == 0bv32); + l0000039c: + assume {:captureState "l0000039c"} true; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, bvadd64(R1, 4bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 0bv32), gamma_store32(Gamma_mem, 69656bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 4bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R1, 4bv64), true); assert (memory_load32_le(mem, $z_addr) == z_old); - goto l000001bd; - lmain_goto_l000001bd: - assume (!(R0_3 == 0bv32)); + assume {:captureState "%000003a1"} true; goto l000001bd; l000001bd: + assume {:captureState "l000001bd"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + lmain_goto_l000001bd: + assume {:captureState "lmain_goto_l000001bd"} true; + assume (bvnot1(bvcomp32(R0[32:0], 0bv32)) != 0bv1); + goto l000001bd; + lmain_goto_l0000039c: + assume {:captureState "lmain_goto_l0000039c"} true; + assume (bvnot1(bvcomp32(R0[32:0], 0bv32)) == 0bv1); + goto l0000039c; main_basil_return: - R0_out, R1_out := 0bv64, 69652bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_read/gcc_O2/basic_lock_read_gtirb.expected b/src/test/correct/basic_lock_read/gcc_O2/basic_lock_read_gtirb.expected index 3d5141499..0376b9c06 100644 --- a/src/test/correct/basic_lock_read/gcc_O2/basic_lock_read_gtirb.expected +++ b/src/test/correct/basic_lock_read/gcc_O2/basic_lock_read_gtirb.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,22 +29,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -84,54 +69,56 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - ensures (R0_out[32:0] == 0bv32); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (R0[32:0] == 0bv32); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var R0_3: bv32; var z_old: bv32; $main$__0__$FF2SjjvqSsOWEiG9v2p92Q: + assume {:captureState "$main$__0__$FF2SjjvqSsOWEiG9v2p92Q"} true; + R0, Gamma_R0 := 69632bv64, true; + R1, Gamma_R1 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R0, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R0, 20bv64)) || L(mem, bvadd64(R0, 20bv64))); + assert Gamma_R0; goto $main$__0__$FF2SjjvqSsOWEiG9v2p92Q_goto_$main$__2__$MYSV1omOQM2b08Jj~q4Iuw, $main$__0__$FF2SjjvqSsOWEiG9v2p92Q_goto_$main$__1__$5dIr9jyaTQaHqLa9MRdoFQ; - $main$__0__$FF2SjjvqSsOWEiG9v2p92Q_goto_$main$__1__$5dIr9jyaTQaHqLa9MRdoFQ: - assume (R0_3 == 0bv32); + $main$__1__$5dIr9jyaTQaHqLa9MRdoFQ: + assume {:captureState "$main$__1__$5dIr9jyaTQaHqLa9MRdoFQ"} true; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, bvadd64(R1, 4bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 0bv32), gamma_store32(Gamma_mem, 69656bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 4bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R1, 4bv64), true); assert (memory_load32_le(mem, $z_addr) == z_old); - goto $main$__2__$MYSV1omOQM2b08Jj~q4Iuw; - $main$__0__$FF2SjjvqSsOWEiG9v2p92Q_goto_$main$__2__$MYSV1omOQM2b08Jj~q4Iuw: - assume (!(R0_3 == 0bv32)); + assume {:captureState "1552$0"} true; goto $main$__2__$MYSV1omOQM2b08Jj~q4Iuw; $main$__2__$MYSV1omOQM2b08Jj~q4Iuw: + assume {:captureState "$main$__2__$MYSV1omOQM2b08Jj~q4Iuw"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + $main$__0__$FF2SjjvqSsOWEiG9v2p92Q_goto_$main$__2__$MYSV1omOQM2b08Jj~q4Iuw: + assume {:captureState "$main$__0__$FF2SjjvqSsOWEiG9v2p92Q_goto_$main$__2__$MYSV1omOQM2b08Jj~q4Iuw"} true; + assume ((R0[32:0] == 0bv32) == false); + goto $main$__2__$MYSV1omOQM2b08Jj~q4Iuw; + $main$__0__$FF2SjjvqSsOWEiG9v2p92Q_goto_$main$__1__$5dIr9jyaTQaHqLa9MRdoFQ: + assume {:captureState "$main$__0__$FF2SjjvqSsOWEiG9v2p92Q_goto_$main$__1__$5dIr9jyaTQaHqLa9MRdoFQ"} true; + assume (!((R0[32:0] == 0bv32) == false)); + goto $main$__1__$5dIr9jyaTQaHqLa9MRdoFQ; main_basil_return: - R0_out, R1_out := 0bv64, 69652bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_read/gcc_pic/basic_lock_read.expected b/src/test/correct/basic_lock_read/gcc_pic/basic_lock_read.expected index b2930d5a5..857950775 100644 --- a/src/test/correct/basic_lock_read/gcc_pic/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/gcc_pic/basic_lock_read.expected @@ -1,25 +1,34 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +38,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,29 +49,24 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,79 +93,84 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - ensures (R0_out[32:0] == 0bv32); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + ensures (R0[32:0] == 0bv32); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R0_9: bool; - var R0_2: bv64; - var R0_3: bv32; - var R0_5: bv64; - var R0_7: bv64; - var R0_8: bv32; - var R0_9: bv64; + var #4: bv32; + var Gamma_#4: bool; var z_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f9"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, R0_2), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - assert Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000328, lmain_goto_l0000033f; - lmain_goto_l0000033f: - assume (R0_3 == 0bv32); + l0000033f: + assume {:captureState "l0000033f"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - assert (L(mem, R0_5) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_5, 0bv32), gamma_store32(Gamma_mem, R0_5, true); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "%00000350"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_8, Gamma_R0_8 := memory_load32_le(mem, R0_7), (gamma_load32(Gamma_mem, R0_7) || L(mem, R0_7)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_8), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_8); - goto l00000328; - lmain_goto_l00000328: - assume (!(R0_3 == 0bv32)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000036b"} true; goto l00000328; l00000328: - R0_9, Gamma_R0_9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l00000328"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000328: + assume {:captureState "lmain_goto_l00000328"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000328; + lmain_goto_l0000033f: + assume {:captureState "lmain_goto_l0000033f"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l0000033f; main_basil_return: - R0_out, R31_out := R0_9, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_9, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_read/gcc_pic/basic_lock_read_gtirb.expected b/src/test/correct/basic_lock_read/gcc_pic/basic_lock_read_gtirb.expected index b1473873c..7234dcc85 100644 --- a/src/test/correct/basic_lock_read/gcc_pic/basic_lock_read_gtirb.expected +++ b/src/test/correct/basic_lock_read/gcc_pic/basic_lock_read_gtirb.expected @@ -1,25 +1,33 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +37,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,29 +48,23 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,79 +91,84 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - ensures (R0_out[32:0] == 0bv32); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + ensures (R0[32:0] == 0bv32); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R0_9: bool; - var R0_2: bv64; - var R0_3: bv32; - var R0_5: bv64; - var R0_7: bv64; - var R0_8: bv32; - var R0_9: bv64; + var Cse0__5$0$5: bv32; + var Gamma_Cse0__5$0$5: bool; var z_old: bv32; $main$__0__$Gs_ZZWu2SiejIc_00eklZA: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$Gs_ZZWu2SiejIc_00eklZA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1880$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, R0_2), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - assert Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$0$5, Gamma_Cse0__5$0$5 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$5, Cse0__5$0$5)), Gamma_Cse0__5$0$5; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$5), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$0$5); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$5, 0bv32), Gamma_Cse0__5$0$5; + NF, Gamma_NF := Cse0__5$0$5[32:31], Gamma_Cse0__5$0$5; + assert Gamma_ZF; goto $main$__0__$Gs_ZZWu2SiejIc_00eklZA_goto_$main$__2__$zWtL6ov7R~OhQ~Y6jkCfIg, $main$__0__$Gs_ZZWu2SiejIc_00eklZA_goto_$main$__1__$3vOWy9QvQo6ElHgnmXugdw; - $main$__0__$Gs_ZZWu2SiejIc_00eklZA_goto_$main$__1__$3vOWy9QvQo6ElHgnmXugdw: - assume (R0_3 == 0bv32); + $main$__1__$3vOWy9QvQo6ElHgnmXugdw: + assume {:captureState "$main$__1__$3vOWy9QvQo6ElHgnmXugdw"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - assert (L(mem, R0_5) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_5, 0bv32), gamma_store32(Gamma_mem, R0_5, true); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "1912$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_8, Gamma_R0_8 := memory_load32_le(mem, R0_7), (gamma_load32(Gamma_mem, R0_7) || L(mem, R0_7)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_8), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_8); - goto $main$__2__$zWtL6ov7R~OhQ~Y6jkCfIg; - $main$__0__$Gs_ZZWu2SiejIc_00eklZA_goto_$main$__2__$zWtL6ov7R~OhQ~Y6jkCfIg: - assume (!(R0_3 == 0bv32)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1928$0"} true; goto $main$__2__$zWtL6ov7R~OhQ~Y6jkCfIg; $main$__2__$zWtL6ov7R~OhQ~Y6jkCfIg: - R0_9, Gamma_R0_9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__2__$zWtL6ov7R~OhQ~Y6jkCfIg"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$Gs_ZZWu2SiejIc_00eklZA_goto_$main$__2__$zWtL6ov7R~OhQ~Y6jkCfIg: + assume {:captureState "$main$__0__$Gs_ZZWu2SiejIc_00eklZA_goto_$main$__2__$zWtL6ov7R~OhQ~Y6jkCfIg"} true; + assume (!(ZF == 1bv1)); + goto $main$__2__$zWtL6ov7R~OhQ~Y6jkCfIg; + $main$__0__$Gs_ZZWu2SiejIc_00eklZA_goto_$main$__1__$3vOWy9QvQo6ElHgnmXugdw: + assume {:captureState "$main$__0__$Gs_ZZWu2SiejIc_00eklZA_goto_$main$__1__$3vOWy9QvQo6ElHgnmXugdw"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__1__$3vOWy9QvQo6ElHgnmXugdw; main_basil_return: - R0_out, R31_out := R0_9, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_9, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/clang/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/clang/basic_lock_security_read.expected index f33d9854e..0bc9f6c39 100644 --- a/src/test/correct/basic_lock_security_read/clang/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/clang/basic_lock_security_read.expected @@ -1,35 +1,42 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +47,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -87,74 +89,91 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_2: bool; - var Gamma_R8_7: bool; - var Gamma_R8_9: bool; - var R0_1: bv64; - var R8_11: bv64; - var R8_2: bv32; - var R8_7: bv64; - var R8_9: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f5"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%000002fc"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000329, lmain_goto_l0000032c; - lmain_goto_l0000032c: - assume (!(R8_2 == 0bv32)); - R8_7, Gamma_R8_7 := 1bv64, true; + l0000032c: + assume {:captureState "l0000032c"} true; + R8, Gamma_R8 := 1bv64, true; goto l0000032f; - lmain_goto_l00000329: - assume (R8_2 == 0bv32); - R8_7, Gamma_R8_7 := 0bv64, true; + l00000329: + assume {:captureState "l00000329"} true; + R8, Gamma_R8 := 0bv64, true; goto l0000032f; l0000032f: - assert Gamma_R8_7; + assume {:captureState "l0000032f"} true; + assert Gamma_R8; goto l0000032f_goto_l00000337, l0000032f_goto_l0000034e; - l0000032f_goto_l0000034e: - assume (!(R8_7[1:0] == 1bv1)); + l0000034e: + assume {:captureState "l0000034e"} true; + goto l0000034f; + l0000034f: + assume {:captureState "l0000034f"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_9, Gamma_R8_9 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_9[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_9); - R8_11, Gamma_R8_11 := R8_9, Gamma_R8_9; - goto l00000337; - l0000032f_goto_l00000337: - assume (R8_7[1:0] == 1bv1); - R8_11, Gamma_R8_11 := R8_7, Gamma_R8_7; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000364"} true; goto l00000337; l00000337: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "l00000337"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000329: + assume {:captureState "lmain_goto_l00000329"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l00000329; + lmain_goto_l0000032c: + assume {:captureState "lmain_goto_l0000032c"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l0000032c; + l0000032f_goto_l00000337: + assume {:captureState "l0000032f_goto_l00000337"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l00000337; + l0000032f_goto_l0000034e: + assume {:captureState "l0000032f_goto_l0000034e"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l0000034e; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_11; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_11; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/clang/basic_lock_security_read_gtirb.expected b/src/test/correct/basic_lock_security_read/clang/basic_lock_security_read_gtirb.expected index 622556a36..689765c63 100644 --- a/src/test/correct/basic_lock_security_read/clang/basic_lock_security_read_gtirb.expected +++ b/src/test/correct/basic_lock_security_read/clang/basic_lock_security_read_gtirb.expected @@ -1,35 +1,41 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +46,17 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -87,87 +87,83 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_12: bool; - var Gamma_R8_13: bool; - var Gamma_R8_2: bool; - var Gamma_R8_8: bool; - var R0_1: bv64; - var R8_10: bv64; - var R8_12: bv64; - var R8_13: bv64; - var R8_2: bv32; - var R8_8: bv64; + var Cse0__5$3$5: bv32; + var Gamma_Cse0__5$3$5: bool; $main$__0__$9r6UOwhWT0e4r_v5VvoQOg: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + assume {:captureState "$main$__0__$9r6UOwhWT0e4r_v5VvoQOg"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1816$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "1820$0"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + Cse0__5$3$5, Gamma_Cse0__5$3$5 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$3$5, Cse0__5$3$5)), Gamma_Cse0__5$3$5; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$5), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$3$5); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$5, 0bv32), Gamma_Cse0__5$3$5; + NF, Gamma_NF := Cse0__5$3$5[32:31], Gamma_Cse0__5$3$5; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$3$5), Gamma_Cse0__5$3$5; + assert Gamma_ZF; goto $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__0, $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__1; - $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__1: - assume (!(R8_2 == 0bv32)); - goto $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__1_phi_$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ_phi_back_$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ, $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__1_phi_$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__1__$cbw8VJ_4TNWMhitLYT_zHw_phi_back_$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__1__$cbw8VJ_4TNWMhitLYT_zHw; - $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__1_phi_$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__1__$cbw8VJ_4TNWMhitLYT_zHw_phi_back_$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__1__$cbw8VJ_4TNWMhitLYT_zHw: - R8_8, Gamma_R8_8 := 1bv64, true; - assert Gamma_R8_8; - goto $main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__1__$cbw8VJ_4TNWMhitLYT_zHw; - $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__1_phi_$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ_phi_back_$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ: - R8_12, Gamma_R8_12 := 1bv64, true; - assert Gamma_R8_12; - goto $main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ; - $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__0: - assume (R8_2 == 0bv32); - goto $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__0_phi_back_$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__1__$cbw8VJ_4TNWMhitLYT_zHw, $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__0_phi_back_$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ; - $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__0_phi_back_$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ: - R8_12, Gamma_R8_12 := 0bv64, true; - assert Gamma_R8_12; - goto $main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ; - $main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ: - assume (R8_12[1:0] == 1bv1); - R8_13, Gamma_R8_13 := R8_12, Gamma_R8_12; - goto $main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ; - $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__0_phi_back_$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__1__$cbw8VJ_4TNWMhitLYT_zHw: - R8_8, Gamma_R8_8 := 0bv64, true; - assert Gamma_R8_8; - goto $main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__1__$cbw8VJ_4TNWMhitLYT_zHw; - $main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__1__$cbw8VJ_4TNWMhitLYT_zHw: - assume (!(R8_8[1:0] == 1bv1)); + $main$__1__$cbw8VJ_4TNWMhitLYT_zHw: + assume {:captureState "$main$__1__$cbw8VJ_4TNWMhitLYT_zHw"} true; + goto $main$__2__$u39p8w6rTnOZAd6DunNDgQ; + $main$__2__$u39p8w6rTnOZAd6DunNDgQ: + assume {:captureState "$main$__2__$u39p8w6rTnOZAd6DunNDgQ"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_10, Gamma_R8_10 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_10[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_10); - R8_13, Gamma_R8_13 := R8_10, Gamma_R8_10; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1856$0"} true; goto $main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ; $main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ: + assume {:captureState "$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ; + $main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__1__$cbw8VJ_4TNWMhitLYT_zHw: + assume {:captureState "$main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__1__$cbw8VJ_4TNWMhitLYT_zHw"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$cbw8VJ_4TNWMhitLYT_zHw; + $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__0: + assume {:captureState "$main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ, $main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__1__$cbw8VJ_4TNWMhitLYT_zHw; + $main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__1: + assume {:captureState "$main$__0__$9r6UOwhWT0e4r_v5VvoQOg$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__3__$hMq94Gt8Rsi1RNq0G5~fMQ, $main$__0__$9r6UOwhWT0e4r_v5VvoQOg_goto_$main$__1__$cbw8VJ_4TNWMhitLYT_zHw; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_13; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_13; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read.expected index 426252116..1732e2d7d 100644 --- a/src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read.expected @@ -1,14 +1,34 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -21,19 +41,14 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -64,58 +79,61 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R8, R9, VF, ZF, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R8_3: bool; - var Gamma_R9_3: bool; - var R0_3: bv64; - var R0_4: bv64; - var R8_3: bv64; - var R9_3: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); call rely(); - R9_3, Gamma_R9_3 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - assert Gamma_R8_3; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 56bv64)) || L(mem, bvadd64(R9, 56bv64))); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l000002fa, lmain_goto_l000002fd; - lmain_goto_l000002fd: - assume (!(R8_3[32:0] == 0bv32)); - R0_4, Gamma_R0_4 := 0bv64, true; + l000002fd: + assume {:captureState "l000002fd"} true; + R0, Gamma_R0 := 0bv64, true; goto l00000300; - lmain_goto_l000002fa: - assume (R8_3[32:0] == 0bv32); - R0_3, Gamma_R0_3 := zero_extend32_32(R9_3[32:0]), Gamma_R9_3; - R0_4, Gamma_R0_4 := R0_3, Gamma_R0_3; + l000002fa: + assume {:captureState "l000002fa"} true; + R0, Gamma_R0 := zero_extend32_32(R9[32:0]), Gamma_R9; goto l00000300; l00000300: + assume {:captureState "l00000300"} true; goto main_basil_return; + lmain_goto_l000002fa: + assume {:captureState "lmain_goto_l000002fa"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l000002fa; + lmain_goto_l000002fd: + assume {:captureState "lmain_goto_l000002fd"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l000002fd; main_basil_return: - R0_out, R8_out, R9_out := R0_4, R8_3, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_4, Gamma_R8_3, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read_gtirb.expected b/src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read_gtirb.expected index 4deb36b20..5f851e084 100644 --- a/src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read_gtirb.expected +++ b/src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read_gtirb.expected @@ -1,14 +1,33 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -21,19 +40,13 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -64,56 +77,52 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R8, R9, VF, ZF, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R8_3: bool; - var Gamma_R9_3: bool; - var R0_3: bv64; - var R0_4: bv64; - var R8_3: bv64; - var R9_3: bv64; + var Cse0__5$0$4: bv32; + var Gamma_Cse0__5$0$4: bool; $main$__0__$pquulxeLTn6ZdHAVNHAErw: + assume {:captureState "$main$__0__$pquulxeLTn6ZdHAVNHAErw"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); call rely(); - R9_3, Gamma_R9_3 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - assert Gamma_R8_3; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 56bv64)) || L(mem, bvadd64(R9, 56bv64))); + Cse0__5$0$4, Gamma_Cse0__5$0$4 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$4, Cse0__5$0$4)), Gamma_Cse0__5$0$4; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$4), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$0$4); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$4, 0bv32), Gamma_Cse0__5$0$4; + NF, Gamma_NF := Cse0__5$0$4[32:31], Gamma_Cse0__5$0$4; + assert Gamma_ZF; goto $main$__0__$pquulxeLTn6ZdHAVNHAErw$__0, $main$__0__$pquulxeLTn6ZdHAVNHAErw$__1; - $main$__0__$pquulxeLTn6ZdHAVNHAErw$__1: - assume (!(R8_3[32:0] == 0bv32)); - R0_4, Gamma_R0_4 := 0bv64, true; - goto main_basil_return; $main$__0__$pquulxeLTn6ZdHAVNHAErw$__0: - assume (R8_3[32:0] == 0bv32); - R0_3, Gamma_R0_3 := zero_extend32_32(R9_3[32:0]), Gamma_R9_3; - R0_4, Gamma_R0_4 := R0_3, Gamma_R0_3; + assume {:captureState "$main$__0__$pquulxeLTn6ZdHAVNHAErw$__0"} true; + assume (ZF == 1bv1); + R0, Gamma_R0 := zero_extend32_32(R9[32:0]), Gamma_R9; + goto main_basil_return; + $main$__0__$pquulxeLTn6ZdHAVNHAErw$__1: + assume {:captureState "$main$__0__$pquulxeLTn6ZdHAVNHAErw$__1"} true; + assume (!(ZF == 1bv1)); + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := R0_4, R8_3, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_4, Gamma_R8_3, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read.expected index 478c6f746..72842e0fe 100644 --- a/src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read.expected @@ -1,25 +1,36 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +40,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,29 +51,24 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,86 +95,99 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1968bv64) == 1bv8); - free requires (memory_load8_le(mem, 1969bv64) == 0bv8); - free requires (memory_load8_le(mem, 1970bv64) == 2bv8); - free requires (memory_load8_le(mem, 1971bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1968bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_11: bool; - var Gamma_R8_13: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_8: bool; - var R0_1: bv64; - var R8_10: bv64; - var R8_11: bv64; - var R8_13: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_8: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002fd"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000304"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000338, lmain_goto_l0000033b; - lmain_goto_l0000033b: - assume (!(R8_3 == 0bv32)); - R8_8, Gamma_R8_8 := 1bv64, true; + l0000033b: + assume {:captureState "l0000033b"} true; + R8, Gamma_R8 := 1bv64, true; goto l0000033e; - lmain_goto_l00000338: - assume (R8_3 == 0bv32); - R8_8, Gamma_R8_8 := 0bv64, true; + l00000338: + assume {:captureState "l00000338"} true; + R8, Gamma_R8 := 0bv64, true; goto l0000033e; l0000033e: - assert Gamma_R8_8; + assume {:captureState "l0000033e"} true; + assert Gamma_R8; goto l0000033e_goto_l00000346, l0000033e_goto_l0000035d; - l0000033e_goto_l0000035d: - assume (!(R8_8[1:0] == 1bv1)); + l0000035d: + assume {:captureState "l0000035d"} true; + goto l0000035e; + l0000035e: + assume {:captureState "l0000035e"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_10, Gamma_R8_10 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); - R8_11, Gamma_R8_11 := zero_extend32_32(memory_load32_le(mem, R8_10)), (gamma_load32(Gamma_mem, R8_10) || L(mem, R8_10)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_11[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_11); - R8_13, Gamma_R8_13 := R8_11, Gamma_R8_11; - goto l00000346; - l0000033e_goto_l00000346: - assume (R8_8[1:0] == 1bv1); - R8_13, Gamma_R8_13 := R8_8, Gamma_R8_8; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000037a"} true; goto l00000346; l00000346: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "l00000346"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000338: + assume {:captureState "lmain_goto_l00000338"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l00000338; + lmain_goto_l0000033b: + assume {:captureState "lmain_goto_l0000033b"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l0000033b; + l0000033e_goto_l00000346: + assume {:captureState "l0000033e_goto_l00000346"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l00000346; + l0000033e_goto_l0000035d: + assume {:captureState "l0000033e_goto_l0000035d"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l0000035d; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_13; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_13; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read_gtirb.expected b/src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read_gtirb.expected index e32b4beda..ec5b9443d 100644 --- a/src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read_gtirb.expected +++ b/src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read_gtirb.expected @@ -1,25 +1,35 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +39,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,29 +50,23 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,99 +93,91 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1968bv64) == 1bv8); - free requires (memory_load8_le(mem, 1969bv64) == 0bv8); - free requires (memory_load8_le(mem, 1970bv64) == 2bv8); - free requires (memory_load8_le(mem, 1971bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1968bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_12: bool; - var Gamma_R8_14: bool; - var Gamma_R8_15: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_9: bool; - var R0_1: bv64; - var R8_11: bv64; - var R8_12: bv64; - var R8_14: bv64; - var R8_15: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_9: bv64; + var Cse0__5$0$6: bv32; + var Gamma_Cse0__5$0$6: bool; $main$__0__$GWWZBuKKQM26VofqjYL7Vw: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + assume {:captureState "$main$__0__$GWWZBuKKQM26VofqjYL7Vw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1880$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "1884$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + Cse0__5$0$6, Gamma_Cse0__5$0$6 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$6, Cse0__5$0$6)), Gamma_Cse0__5$0$6; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$6), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$0$6); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$6, 0bv32), Gamma_Cse0__5$0$6; + NF, Gamma_NF := Cse0__5$0$6[32:31], Gamma_Cse0__5$0$6; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$0$6), Gamma_Cse0__5$0$6; + assert Gamma_ZF; goto $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__0, $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__1; - $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__1: - assume (!(R8_3 == 0bv32)); - goto $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__1_phi_$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg_phi_back_$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg, $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__1_phi_$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__1__$~AKjztrcRfKvIDu38BnCGQ_phi_back_$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__1__$~AKjztrcRfKvIDu38BnCGQ; - $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__1_phi_$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__1__$~AKjztrcRfKvIDu38BnCGQ_phi_back_$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__1__$~AKjztrcRfKvIDu38BnCGQ: - R8_9, Gamma_R8_9 := 1bv64, true; - assert Gamma_R8_9; - goto $main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__1__$~AKjztrcRfKvIDu38BnCGQ; - $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__1_phi_$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg_phi_back_$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg: - R8_14, Gamma_R8_14 := 1bv64, true; - assert Gamma_R8_14; - goto $main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg; - $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__0: - assume (R8_3 == 0bv32); - goto $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__0_phi_back_$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__1__$~AKjztrcRfKvIDu38BnCGQ, $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__0_phi_back_$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg; - $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__0_phi_back_$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg: - R8_14, Gamma_R8_14 := 0bv64, true; - assert Gamma_R8_14; - goto $main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg; - $main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg: - assume (R8_14[1:0] == 1bv1); - R8_15, Gamma_R8_15 := R8_14, Gamma_R8_14; - goto $main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg; - $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__0_phi_back_$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__1__$~AKjztrcRfKvIDu38BnCGQ: - R8_9, Gamma_R8_9 := 0bv64, true; - assert Gamma_R8_9; - goto $main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__1__$~AKjztrcRfKvIDu38BnCGQ; - $main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__1__$~AKjztrcRfKvIDu38BnCGQ: - assume (!(R8_9[1:0] == 1bv1)); + $main$__1__$~AKjztrcRfKvIDu38BnCGQ: + assume {:captureState "$main$__1__$~AKjztrcRfKvIDu38BnCGQ"} true; + goto $main$__2__$baAsuX2xSiqbUG_8VReSNg; + $main$__2__$baAsuX2xSiqbUG_8VReSNg: + assume {:captureState "$main$__2__$baAsuX2xSiqbUG_8VReSNg"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_11, Gamma_R8_11 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); - R8_12, Gamma_R8_12 := zero_extend32_32(memory_load32_le(mem, R8_11)), (gamma_load32(Gamma_mem, R8_11) || L(mem, R8_11)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_12[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_12); - R8_15, Gamma_R8_15 := R8_12, Gamma_R8_12; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1928$0"} true; goto $main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg; $main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg: + assume {:captureState "$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg; + $main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__1__$~AKjztrcRfKvIDu38BnCGQ: + assume {:captureState "$main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__1__$~AKjztrcRfKvIDu38BnCGQ"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$~AKjztrcRfKvIDu38BnCGQ; + $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__0: + assume {:captureState "$main$__0__$GWWZBuKKQM26VofqjYL7Vw$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg, $main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__1__$~AKjztrcRfKvIDu38BnCGQ; + $main$__0__$GWWZBuKKQM26VofqjYL7Vw$__1: + assume {:captureState "$main$__0__$GWWZBuKKQM26VofqjYL7Vw$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__3__$Tg~76Xl4R9iLF7N7aFS1Lg, $main$__0__$GWWZBuKKQM26VofqjYL7Vw_goto_$main$__1__$~AKjztrcRfKvIDu38BnCGQ; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_15; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_15; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/gcc/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/gcc/basic_lock_security_read.expected index ebc3781bb..2c29e93fa 100644 --- a/src/test/correct/basic_lock_security_read/gcc/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/gcc/basic_lock_security_read.expected @@ -1,35 +1,40 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +45,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -87,56 +87,67 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1888bv64) == 1bv8); - free requires (memory_load8_le(mem, 1889bv64) == 0bv8); - free requires (memory_load8_le(mem, 1890bv64) == 2bv8); - free requires (memory_load8_le(mem, 1891bv64) == 0bv8); + free requires (memory_load32_le(mem, 1888bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var R0_3: bv32; - var R0_6: bv32; - var R0_7: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002ed"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69656bv64), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - assert Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l0000031b, lmain_goto_l00000332; - lmain_goto_l00000332: - assume (R0_3 == 0bv32); + l00000332: + assume {:captureState "l00000332"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_6), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_6); - goto l0000031b; - lmain_goto_l0000031b: - assume (!(R0_3 == 0bv32)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000034a"} true; goto l0000031b; l0000031b: - R0_7, Gamma_R0_7 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l0000031b"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l0000031b: + assume {:captureState "lmain_goto_l0000031b"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l0000031b; + lmain_goto_l00000332: + assume {:captureState "lmain_goto_l00000332"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000332; main_basil_return: - R0_out, R31_out := R0_7, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_7, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/gcc/basic_lock_security_read_gtirb.expected b/src/test/correct/basic_lock_security_read/gcc/basic_lock_security_read_gtirb.expected index a59e236eb..0fba39a39 100644 --- a/src/test/correct/basic_lock_security_read/gcc/basic_lock_security_read_gtirb.expected +++ b/src/test/correct/basic_lock_security_read/gcc/basic_lock_security_read_gtirb.expected @@ -1,35 +1,39 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +44,17 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -87,56 +85,67 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1888bv64) == 1bv8); - free requires (memory_load8_le(mem, 1889bv64) == 0bv8); - free requires (memory_load8_le(mem, 1890bv64) == 2bv8); - free requires (memory_load8_le(mem, 1891bv64) == 0bv8); + free requires (memory_load32_le(mem, 1888bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var R0_3: bv32; - var R0_6: bv32; - var R0_7: bv64; + var Cse0__5$0$5: bv32; + var Gamma_Cse0__5$0$5: bool; $main$__0__$A6BkCpHoRvCUlmC~AxLCrg: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$A6BkCpHoRvCUlmC~AxLCrg"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1816$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69656bv64), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - assert Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$0$5, Gamma_Cse0__5$0$5 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$5, Cse0__5$0$5)), Gamma_Cse0__5$0$5; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$5), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$0$5); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$5, 0bv32), Gamma_Cse0__5$0$5; + NF, Gamma_NF := Cse0__5$0$5[32:31], Gamma_Cse0__5$0$5; + assert Gamma_ZF; goto $main$__0__$A6BkCpHoRvCUlmC~AxLCrg_goto_$main$__2__$R75hxt8lSuS~GSZvHdnsxA, $main$__0__$A6BkCpHoRvCUlmC~AxLCrg_goto_$main$__1__$iUKQJOs9SUeP0UPwnOWoOA; - $main$__0__$A6BkCpHoRvCUlmC~AxLCrg_goto_$main$__1__$iUKQJOs9SUeP0UPwnOWoOA: - assume (R0_3 == 0bv32); + $main$__1__$iUKQJOs9SUeP0UPwnOWoOA: + assume {:captureState "$main$__1__$iUKQJOs9SUeP0UPwnOWoOA"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_6), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_6); - goto $main$__2__$R75hxt8lSuS~GSZvHdnsxA; - $main$__0__$A6BkCpHoRvCUlmC~AxLCrg_goto_$main$__2__$R75hxt8lSuS~GSZvHdnsxA: - assume (!(R0_3 == 0bv32)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1852$0"} true; goto $main$__2__$R75hxt8lSuS~GSZvHdnsxA; $main$__2__$R75hxt8lSuS~GSZvHdnsxA: - R0_7, Gamma_R0_7 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__2__$R75hxt8lSuS~GSZvHdnsxA"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$A6BkCpHoRvCUlmC~AxLCrg_goto_$main$__2__$R75hxt8lSuS~GSZvHdnsxA: + assume {:captureState "$main$__0__$A6BkCpHoRvCUlmC~AxLCrg_goto_$main$__2__$R75hxt8lSuS~GSZvHdnsxA"} true; + assume (!(ZF == 1bv1)); + goto $main$__2__$R75hxt8lSuS~GSZvHdnsxA; + $main$__0__$A6BkCpHoRvCUlmC~AxLCrg_goto_$main$__1__$iUKQJOs9SUeP0UPwnOWoOA: + assume {:captureState "$main$__0__$A6BkCpHoRvCUlmC~AxLCrg_goto_$main$__1__$iUKQJOs9SUeP0UPwnOWoOA"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__1__$iUKQJOs9SUeP0UPwnOWoOA; main_basil_return: - R0_out, R31_out := R0_7, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_7, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/gcc_O2/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/gcc_O2/basic_lock_security_read.expected index b0cc72aea..c05476c3a 100644 --- a/src/test/correct/basic_lock_security_read/gcc_O2/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/gcc_O2/basic_lock_security_read.expected @@ -1,14 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -21,19 +29,12 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -64,55 +65,50 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_4: bool; - var Gamma_R1_3: bool; - var R0_2: bv64; - var R0_4: bv64; - var R1_3: bv64; lmain: + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R0, Gamma_R0 := 0bv64, true; call rely(); - R1_3, Gamma_R1_3 := zero_extend32_32(memory_load32_le(mem, 69652bv64)), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R1_3; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 20bv64)) || L(mem, bvadd64(R1, 20bv64))); + assert Gamma_R1; goto lmain_goto_l000001c2, lmain_goto_l0000039c; - lmain_goto_l0000039c: - assume (R1_3[32:0] == 0bv32); + l0000039c: + assume {:captureState "l0000039c"} true; call rely(); - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(mem, 69656bv64)), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - R0_4, Gamma_R0_4 := R0_2, Gamma_R0_2; - goto l000001c2; - lmain_goto_l000001c2: - assume (!(R1_3[32:0] == 0bv32)); - R0_4, Gamma_R0_4 := 0bv64, true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 4bv64)) || L(mem, bvadd64(R2, 4bv64))); goto l000001c2; l000001c2: + assume {:captureState "l000001c2"} true; goto main_basil_return; + lmain_goto_l000001c2: + assume {:captureState "lmain_goto_l000001c2"} true; + assume (bvnot1(bvcomp32(R1[32:0], 0bv32)) != 0bv1); + goto l000001c2; + lmain_goto_l0000039c: + assume {:captureState "lmain_goto_l0000039c"} true; + assume (bvnot1(bvcomp32(R1[32:0], 0bv32)) == 0bv1); + goto l0000039c; main_basil_return: - R0_out, R1_out, R2_out := R0_4, R1_3, 69652bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := Gamma_R0_4, Gamma_R1_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/gcc_O2/basic_lock_security_read_gtirb.expected b/src/test/correct/basic_lock_security_read/gcc_O2/basic_lock_security_read_gtirb.expected index 42dbf22e7..33d8384af 100644 --- a/src/test/correct/basic_lock_security_read/gcc_O2/basic_lock_security_read_gtirb.expected +++ b/src/test/correct/basic_lock_security_read/gcc_O2/basic_lock_security_read_gtirb.expected @@ -1,11 +1,17 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); @@ -21,19 +27,12 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -64,55 +63,50 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_4: bool; - var Gamma_R1_3: bool; - var R0_2: bv64; - var R0_4: bv64; - var R1_3: bv64; $main$__0__$NPnP15ImRqqyNleAnPQz~w: + assume {:captureState "$main$__0__$NPnP15ImRqqyNleAnPQz~w"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R0, Gamma_R0 := 0bv64, true; call rely(); - R1_3, Gamma_R1_3 := zero_extend32_32(memory_load32_le(mem, 69652bv64)), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R1_3; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 20bv64)) || L(mem, bvadd64(R1, 20bv64))); + assert Gamma_R1; goto $main$__0__$NPnP15ImRqqyNleAnPQz~w_goto_$main$__2__$OHqj~6C8Tc6ePz3jNp~0Hg, $main$__0__$NPnP15ImRqqyNleAnPQz~w_goto_$main$__1__$3ldkocbySLOQC5WZlsP7tA; - $main$__0__$NPnP15ImRqqyNleAnPQz~w_goto_$main$__1__$3ldkocbySLOQC5WZlsP7tA: - assume (R1_3[32:0] == 0bv32); + $main$__1__$3ldkocbySLOQC5WZlsP7tA: + assume {:captureState "$main$__1__$3ldkocbySLOQC5WZlsP7tA"} true; call rely(); - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(mem, 69656bv64)), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - R0_4, Gamma_R0_4 := R0_2, Gamma_R0_2; - goto $main$__2__$OHqj~6C8Tc6ePz3jNp~0Hg; - $main$__0__$NPnP15ImRqqyNleAnPQz~w_goto_$main$__2__$OHqj~6C8Tc6ePz3jNp~0Hg: - assume (!(R1_3[32:0] == 0bv32)); - R0_4, Gamma_R0_4 := 0bv64, true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 4bv64)) || L(mem, bvadd64(R2, 4bv64))); goto $main$__2__$OHqj~6C8Tc6ePz3jNp~0Hg; $main$__2__$OHqj~6C8Tc6ePz3jNp~0Hg: + assume {:captureState "$main$__2__$OHqj~6C8Tc6ePz3jNp~0Hg"} true; goto main_basil_return; + $main$__0__$NPnP15ImRqqyNleAnPQz~w_goto_$main$__2__$OHqj~6C8Tc6ePz3jNp~0Hg: + assume {:captureState "$main$__0__$NPnP15ImRqqyNleAnPQz~w_goto_$main$__2__$OHqj~6C8Tc6ePz3jNp~0Hg"} true; + assume ((R1[32:0] == 0bv32) == false); + goto $main$__2__$OHqj~6C8Tc6ePz3jNp~0Hg; + $main$__0__$NPnP15ImRqqyNleAnPQz~w_goto_$main$__1__$3ldkocbySLOQC5WZlsP7tA: + assume {:captureState "$main$__0__$NPnP15ImRqqyNleAnPQz~w_goto_$main$__1__$3ldkocbySLOQC5WZlsP7tA"} true; + assume (!((R1[32:0] == 0bv32) == false)); + goto $main$__1__$3ldkocbySLOQC5WZlsP7tA; main_basil_return: - R0_out, R1_out, R2_out := R0_4, R1_3, 69652bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := Gamma_R0_4, Gamma_R1_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/gcc_pic/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/gcc_pic/basic_lock_security_read.expected index 6781e2135..f3c6100fa 100644 --- a/src/test/correct/basic_lock_security_read/gcc_pic/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/gcc_pic/basic_lock_security_read.expected @@ -1,25 +1,34 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +38,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,29 +49,24 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1952bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1953bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1954bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1955bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 1952bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,68 +93,73 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1952bv64) == 1bv8); - free requires (memory_load8_le(mem, 1953bv64) == 0bv8); - free requires (memory_load8_le(mem, 1954bv64) == 2bv8); - free requires (memory_load8_le(mem, 1955bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 1952bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1952bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1953bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1954bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1955bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1952bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var R0_2: bv64; - var R0_3: bv32; - var R0_5: bv64; - var R0_6: bv32; - var R0_7: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002ed"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, R0_2), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - assert Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l0000031c, lmain_goto_l00000333; - lmain_goto_l00000333: - assume (R0_3 == 0bv32); + l00000333: + assume {:captureState "l00000333"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, R0_5), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_6), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_6); - goto l0000031c; - lmain_goto_l0000031c: - assume (!(R0_3 == 0bv32)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000034c"} true; goto l0000031c; l0000031c: - R0_7, Gamma_R0_7 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l0000031c"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l0000031c: + assume {:captureState "lmain_goto_l0000031c"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l0000031c; + lmain_goto_l00000333: + assume {:captureState "lmain_goto_l00000333"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000333; main_basil_return: - R0_out, R31_out := R0_7, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_7, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/gcc_pic/basic_lock_security_read_gtirb.expected b/src/test/correct/basic_lock_security_read/gcc_pic/basic_lock_security_read_gtirb.expected index 497d6028d..ad9c37b62 100644 --- a/src/test/correct/basic_lock_security_read/gcc_pic/basic_lock_security_read_gtirb.expected +++ b/src/test/correct/basic_lock_security_read/gcc_pic/basic_lock_security_read_gtirb.expected @@ -1,25 +1,33 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +37,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,29 +48,23 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); - free ensures (memory_load8_le(mem, 1952bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1953bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1954bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1955bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 1952bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,68 +91,73 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1952bv64) == 1bv8); - free requires (memory_load8_le(mem, 1953bv64) == 0bv8); - free requires (memory_load8_le(mem, 1954bv64) == 2bv8); - free requires (memory_load8_le(mem, 1955bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 1952bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1952bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1953bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1954bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1955bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1952bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var R0_2: bv64; - var R0_3: bv32; - var R0_5: bv64; - var R0_6: bv32; - var R0_7: bv64; + var Cse0__5$2$5: bv32; + var Gamma_Cse0__5$2$5: bool; $main$__0__$kxbde5aJTTep7x_NHw4tDw: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$kxbde5aJTTep7x_NHw4tDw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1880$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, R0_2), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - assert Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$2$5, Gamma_Cse0__5$2$5 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$2$5, Cse0__5$2$5)), Gamma_Cse0__5$2$5; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$2$5), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$2$5); + ZF, Gamma_ZF := bvcomp32(Cse0__5$2$5, 0bv32), Gamma_Cse0__5$2$5; + NF, Gamma_NF := Cse0__5$2$5[32:31], Gamma_Cse0__5$2$5; + assert Gamma_ZF; goto $main$__0__$kxbde5aJTTep7x_NHw4tDw_goto_$main$__2__$ENOb69xvTsOc7YJFk65Gug, $main$__0__$kxbde5aJTTep7x_NHw4tDw_goto_$main$__1__$MrPOp6w3Rd2CG29w9Oykog; - $main$__0__$kxbde5aJTTep7x_NHw4tDw_goto_$main$__1__$MrPOp6w3Rd2CG29w9Oykog: - assume (R0_3 == 0bv32); + $main$__1__$MrPOp6w3Rd2CG29w9Oykog: + assume {:captureState "$main$__1__$MrPOp6w3Rd2CG29w9Oykog"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, R0_5), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_6), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_6); - goto $main$__2__$ENOb69xvTsOc7YJFk65Gug; - $main$__0__$kxbde5aJTTep7x_NHw4tDw_goto_$main$__2__$ENOb69xvTsOc7YJFk65Gug: - assume (!(R0_3 == 0bv32)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1916$0"} true; goto $main$__2__$ENOb69xvTsOc7YJFk65Gug; $main$__2__$ENOb69xvTsOc7YJFk65Gug: - R0_7, Gamma_R0_7 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__2__$ENOb69xvTsOc7YJFk65Gug"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$kxbde5aJTTep7x_NHw4tDw_goto_$main$__2__$ENOb69xvTsOc7YJFk65Gug: + assume {:captureState "$main$__0__$kxbde5aJTTep7x_NHw4tDw_goto_$main$__2__$ENOb69xvTsOc7YJFk65Gug"} true; + assume (!(ZF == 1bv1)); + goto $main$__2__$ENOb69xvTsOc7YJFk65Gug; + $main$__0__$kxbde5aJTTep7x_NHw4tDw_goto_$main$__1__$MrPOp6w3Rd2CG29w9Oykog: + assume {:captureState "$main$__0__$kxbde5aJTTep7x_NHw4tDw_goto_$main$__1__$MrPOp6w3Rd2CG29w9Oykog"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__1__$MrPOp6w3Rd2CG29w9Oykog; main_basil_return: - R0_out, R31_out := R0_7, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_7, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_write/clang/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/clang/basic_lock_security_write.expected index 059c8e972..c44be0179 100644 --- a/src/test/correct/basic_lock_security_write/clang/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/clang/basic_lock_security_write.expected @@ -1,35 +1,32 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +46,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); - free ensures (memory_load8_le(mem, 1884bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1885bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1886bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1887bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1884bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -87,75 +77,80 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; requires (memory_load32_le(mem, $z_addr) != 0bv32); - requires (Gamma_R0_in == false); + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1884bv64) == 1bv8); - free requires (memory_load8_le(mem, 1885bv64) == 0bv8); - free requires (memory_load8_le(mem, 1886bv64) == 2bv8); - free requires (memory_load8_le(mem, 1887bv64) == 0bv8); + free requires (memory_load32_le(mem, 1884bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1884bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1885bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1886bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1887bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1884bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; var Gamma_x_old: bool; - var R10_1: bv64; var x_old: bv32; var z_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002ea"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assert ((bvadd64(R8, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "%000002fc"} true; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R10_1); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R10_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R10_1); - assert ((69688bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R10); + assert ((bvadd64(R9, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000310"} true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); + assert (L(mem, bvadd64(R9, 56bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 0bv32), gamma_store32(Gamma_mem, 69688bv64, true); - assert ((69688bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), true); + assert ((bvadd64(R9, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%0000031c"} true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R8, 52bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 0bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), true); + assert ((bvadd64(R8, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000323"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, 69632bv64, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_write/clang/basic_lock_security_write_gtirb.expected b/src/test/correct/basic_lock_security_write/clang/basic_lock_security_write_gtirb.expected index d156e24e3..3e3676047 100644 --- a/src/test/correct/basic_lock_security_write/clang/basic_lock_security_write_gtirb.expected +++ b/src/test/correct/basic_lock_security_write/clang/basic_lock_security_write_gtirb.expected @@ -1,35 +1,32 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +46,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); - free ensures (memory_load8_le(mem, 1884bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1885bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1886bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1887bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1884bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -87,75 +77,80 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; requires (memory_load32_le(mem, $z_addr) != 0bv32); - requires (Gamma_R0_in == false); + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1884bv64) == 1bv8); - free requires (memory_load8_le(mem, 1885bv64) == 0bv8); - free requires (memory_load8_le(mem, 1886bv64) == 2bv8); - free requires (memory_load8_le(mem, 1887bv64) == 0bv8); + free requires (memory_load32_le(mem, 1884bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1884bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1885bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1886bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1887bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1884bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; var Gamma_x_old: bool; - var R10_1: bv64; var x_old: bv32; var z_old: bv32; $main$__0__$FB2GGPd7Q9mrOdXSs0peag: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "$main$__0__$FB2GGPd7Q9mrOdXSs0peag"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1816$0"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assert ((bvadd64(R8, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "1828$0"} true; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R10_1); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R10_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R10_1); - assert ((69688bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R10); + assert ((bvadd64(R9, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1840$0"} true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); + assert (L(mem, bvadd64(R9, 56bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 0bv32), gamma_store32(Gamma_mem, 69688bv64, true); - assert ((69688bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), true); + assert ((bvadd64(R9, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1848$0"} true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R8, 52bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 0bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), true); + assert ((bvadd64(R8, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1852$0"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, 69632bv64, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write.expected index ee50b1b52..9696e1c13 100644 --- a/src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write.expected @@ -10,8 +10,8 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); @@ -31,10 +31,6 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } @@ -43,10 +39,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -83,18 +76,12 @@ procedure main(); requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); diff --git a/src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write_gtirb.expected b/src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write_gtirb.expected index a0d345a2e..95b42776d 100644 --- a/src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write_gtirb.expected +++ b/src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write_gtirb.expected @@ -10,8 +10,8 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); @@ -31,10 +31,6 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } @@ -43,10 +39,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -83,18 +76,12 @@ procedure main(); requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); diff --git a/src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write.expected index 728a7ae92..7760307dc 100644 --- a/src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write.expected @@ -1,25 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +30,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,12 +41,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,16 +50,13 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,87 +83,88 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; requires (memory_load32_le(mem, $z_addr) != 0bv32); - requires (Gamma_R0_in == false); + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1956bv64) == 1bv8); - free requires (memory_load8_le(mem, 1957bv64) == 0bv8); - free requires (memory_load8_le(mem, 1958bv64) == 2bv8); - free requires (memory_load8_le(mem, 1959bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1956bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R9_3: bool; var Gamma_x_old: bool; - var R10_1: bv64; - var R8_2: bv64; - var R9_3: bv64; var x_old: bv32; var z_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002f2"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); + R9, Gamma_R9 := 1bv64, true; call rely(); - assert (L(mem, R8_2) ==> true); + assert (L(mem, R8) ==> Gamma_R9); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_2, 1bv32), gamma_store32(Gamma_mem, R8_2, true); - assert ((R8_2 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, R9[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R9); + assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "%0000030b"} true; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); call rely(); - assert (L(mem, R9_3) ==> Gamma_R10_1); + assert (L(mem, R9) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R10_1[32:0]), gamma_store32(Gamma_mem, R9_3, Gamma_R10_1); - assert ((R9_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, R10[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R10); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000326"} true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> true); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 0bv32), gamma_store32(Gamma_mem, R9_3, true); - assert ((R9_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, 0bv32), gamma_store32(Gamma_mem, R9, true); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000332"} true; call rely(); - assert (L(mem, R8_2) ==> true); + assert (L(mem, R8) ==> true); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_2, 0bv32), gamma_store32(Gamma_mem, R8_2, true); - assert ((R8_2 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); + assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000339"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_2, R9_3; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_2, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write_gtirb.expected b/src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write_gtirb.expected index 77b115794..be7dfc3fa 100644 --- a/src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write_gtirb.expected +++ b/src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write_gtirb.expected @@ -1,25 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +30,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,12 +41,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,16 +50,13 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,87 +83,88 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; requires (memory_load32_le(mem, $z_addr) != 0bv32); - requires (Gamma_R0_in == false); + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1956bv64) == 1bv8); - free requires (memory_load8_le(mem, 1957bv64) == 0bv8); - free requires (memory_load8_le(mem, 1958bv64) == 2bv8); - free requires (memory_load8_le(mem, 1959bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1956bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R9_3: bool; var Gamma_x_old: bool; - var R10_1: bv64; - var R8_2: bv64; - var R9_3: bv64; var x_old: bv32; var z_old: bv32; $main$__0__$cNrtTmfQST221cdIXFneVA: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "$main$__0__$cNrtTmfQST221cdIXFneVA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1880$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); + R9, Gamma_R9 := 1bv64, true; call rely(); - assert (L(mem, R8_2) ==> true); + assert (L(mem, R8) ==> Gamma_R9); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_2, 1bv32), gamma_store32(Gamma_mem, R8_2, true); - assert ((R8_2 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, R9[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R9); + assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "1896$0"} true; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); call rely(); - assert (L(mem, R9_3) ==> Gamma_R10_1); + assert (L(mem, R9) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R10_1[32:0]), gamma_store32(Gamma_mem, R9_3, Gamma_R10_1); - assert ((R9_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, R10[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R10); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1912$0"} true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> true); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 0bv32), gamma_store32(Gamma_mem, R9_3, true); - assert ((R9_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, 0bv32), gamma_store32(Gamma_mem, R9, true); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1920$0"} true; call rely(); - assert (L(mem, R8_2) ==> true); + assert (L(mem, R8) ==> true); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_2, 0bv32), gamma_store32(Gamma_mem, R8_2, true); - assert ((R8_2 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); + assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1924$0"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_2, R9_3; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_2, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_write/gcc/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/gcc/basic_lock_security_write.expected index 0b55ea73c..2429e5c62 100644 --- a/src/test/correct/basic_lock_security_write/gcc/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/gcc/basic_lock_security_write.expected @@ -1,35 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +33,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +42,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); - free ensures (memory_load8_le(mem, 1908bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1909bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1910bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1911bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1908bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -87,75 +73,86 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; requires (memory_load32_le(mem, $z_addr) != 0bv32); - requires (Gamma_R0_in == false); + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1908bv64) == 1bv8); - free requires (memory_load8_le(mem, 1909bv64) == 0bv8); - free requires (memory_load8_le(mem, 1910bv64) == 2bv8); - free requires (memory_load8_le(mem, 1911bv64) == 0bv8); + free requires (memory_load32_le(mem, 1908bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1908bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1909bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1910bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1911bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1908bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R1_2: bool; var Gamma_x_old: bool; - var R1_2: bv64; var x_old: bv32; var z_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000302"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 1bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "%0000031a"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_2); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_2[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_2); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000334"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> true); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 0bv32), gamma_store32(Gamma_mem, 69652bv64, true); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000346"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> true); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 0bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000358"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_write/gcc/basic_lock_security_write_gtirb.expected b/src/test/correct/basic_lock_security_write/gcc/basic_lock_security_write_gtirb.expected index 37eb25a58..376db824c 100644 --- a/src/test/correct/basic_lock_security_write/gcc/basic_lock_security_write_gtirb.expected +++ b/src/test/correct/basic_lock_security_write/gcc/basic_lock_security_write_gtirb.expected @@ -1,35 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +33,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +42,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); - free ensures (memory_load8_le(mem, 1908bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1909bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1910bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1911bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1908bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -87,75 +73,86 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; requires (memory_load32_le(mem, $z_addr) != 0bv32); - requires (Gamma_R0_in == false); + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1908bv64) == 1bv8); - free requires (memory_load8_le(mem, 1909bv64) == 0bv8); - free requires (memory_load8_le(mem, 1910bv64) == 2bv8); - free requires (memory_load8_le(mem, 1911bv64) == 0bv8); + free requires (memory_load32_le(mem, 1908bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1908bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1909bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1910bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1911bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1908bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R1_2: bool; var Gamma_x_old: bool; - var R1_2: bv64; var x_old: bv32; var z_old: bv32; $main$__0__$XOlsS5A6TQOpBXsOQtuFIA: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "$main$__0__$XOlsS5A6TQOpBXsOQtuFIA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1816$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 1bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "1832$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_2); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_2[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_2); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1848$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> true); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 0bv32), gamma_store32(Gamma_mem, 69652bv64, true); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1860$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> true); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 0bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1872$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_write/gcc_O2/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/gcc_O2/basic_lock_security_write.expected index 142ca8ac7..4c3d6f081 100644 --- a/src/test/correct/basic_lock_security_write/gcc_O2/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/gcc_O2/basic_lock_security_write.expected @@ -10,8 +10,8 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); @@ -31,10 +31,6 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } @@ -43,10 +39,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -83,18 +76,12 @@ procedure main(); requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -112,8 +99,8 @@ implementation main() R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, bvadd64(R1, 20bv64)) ==> true); - z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), true); assert ((bvadd64(R1, 20bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); @@ -121,8 +108,8 @@ implementation main() assume {:captureState "%000001bd"} true; call rely(); assert (L(mem, bvadd64(R2, 4bv64)) ==> true); - z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 4bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R2, 4bv64), true); assert ((bvadd64(R2, 4bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); diff --git a/src/test/correct/basic_lock_security_write/gcc_O2/basic_lock_security_write_gtirb.expected b/src/test/correct/basic_lock_security_write/gcc_O2/basic_lock_security_write_gtirb.expected index 346670a0f..d70a6810b 100644 --- a/src/test/correct/basic_lock_security_write/gcc_O2/basic_lock_security_write_gtirb.expected +++ b/src/test/correct/basic_lock_security_write/gcc_O2/basic_lock_security_write_gtirb.expected @@ -10,8 +10,8 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); @@ -31,10 +31,6 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } @@ -43,10 +39,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -83,18 +76,12 @@ procedure main(); requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -112,8 +99,8 @@ implementation main() R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, bvadd64(R1, 20bv64)) ==> true); - z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), true); assert ((bvadd64(R1, 20bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); @@ -121,8 +108,8 @@ implementation main() assume {:captureState "1548$0"} true; call rely(); assert (L(mem, bvadd64(R2, 4bv64)) ==> true); - z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 4bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R2, 4bv64), true); assert ((bvadd64(R2, 4bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); diff --git a/src/test/correct/basic_lock_security_write/gcc_pic/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/gcc_pic/basic_lock_security_write.expected index 72b354a05..91e7850ba 100644 --- a/src/test/correct/basic_lock_security_write/gcc_pic/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/gcc_pic/basic_lock_security_write.expected @@ -1,25 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +26,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,16 +46,13 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); - free ensures (memory_load8_le(mem, 1972bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1973bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1974bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1975bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 1972bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,95 +79,94 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; requires (memory_load32_le(mem, $z_addr) != 0bv32); - requires (Gamma_R0_in == false); + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1972bv64) == 1bv8); - free requires (memory_load8_le(mem, 1973bv64) == 0bv8); - free requires (memory_load8_le(mem, 1974bv64) == 2bv8); - free requires (memory_load8_le(mem, 1975bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 1972bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1972bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1973bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1974bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1975bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1972bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_9: bool; - var Gamma_R1_2: bool; var Gamma_x_old: bool; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_9: bv64; - var R1_2: bv64; var x_old: bv32; var z_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000302"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); - assert ((R0_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%0000031b"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_2); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_2[32:0]), gamma_store32(Gamma_mem, R0_5, Gamma_R1_2); - assert ((R0_5 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000336"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - assert (L(mem, R0_7) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> true); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_7, 0bv32), gamma_store32(Gamma_mem, R0_7, true); - assert ((R0_7 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000349"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_9, Gamma_R0_9 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_9) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> true); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_9, 0bv32), gamma_store32(Gamma_mem, R0_9, true); - assert ((R0_9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%0000035c"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_security_write/gcc_pic/basic_lock_security_write_gtirb.expected b/src/test/correct/basic_lock_security_write/gcc_pic/basic_lock_security_write_gtirb.expected index e0a0dc41f..28daee648 100644 --- a/src/test/correct/basic_lock_security_write/gcc_pic/basic_lock_security_write_gtirb.expected +++ b/src/test/correct/basic_lock_security_write/gcc_pic/basic_lock_security_write_gtirb.expected @@ -1,25 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +26,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,16 +46,13 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); - free ensures (memory_load8_le(mem, 1972bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1973bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1974bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1975bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 1972bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,95 +79,94 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; requires (memory_load32_le(mem, $z_addr) != 0bv32); - requires (Gamma_R0_in == false); + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1972bv64) == 1bv8); - free requires (memory_load8_le(mem, 1973bv64) == 0bv8); - free requires (memory_load8_le(mem, 1974bv64) == 2bv8); - free requires (memory_load8_le(mem, 1975bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 1972bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1972bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1973bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1974bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1975bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1972bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_9: bool; - var Gamma_R1_2: bool; var Gamma_x_old: bool; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_9: bv64; - var R1_2: bv64; var x_old: bv32; var z_old: bv32; $main$__0__$j~RmZ1FYSBm9ctVNQYcBtw: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "$main$__0__$j~RmZ1FYSBm9ctVNQYcBtw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1880$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); - assert ((R0_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1896$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_2); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_2[32:0]), gamma_store32(Gamma_mem, R0_5, Gamma_R1_2); - assert ((R0_5 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1912$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - assert (L(mem, R0_7) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> true); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_7, 0bv32), gamma_store32(Gamma_mem, R0_7, true); - assert ((R0_7 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1924$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_9, Gamma_R0_9 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_9) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> true); x_old := memory_load32_le(mem, $x_addr); + z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_9, 0bv32), gamma_store32(Gamma_mem, R0_9, true); - assert ((R0_9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1936$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/clang/basic_lock_unlock.expected b/src/test/correct/basic_lock_unlock/clang/basic_lock_unlock.expected index f06e0a147..29577149e 100644 --- a/src/test/correct/basic_lock_unlock/clang/basic_lock_unlock.expected +++ b/src/test/correct/basic_lock_unlock/clang/basic_lock_unlock.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -80,49 +66,49 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $z_addr) == 1bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002d6"} true; + R8, Gamma_R8 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, bvadd64(R8, 56bv64)) ==> true); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 0bv32), gamma_store32(Gamma_mem, 69688bv64, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002e7"} true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 69632bv64, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/clang/basic_lock_unlock_gtirb.expected b/src/test/correct/basic_lock_unlock/clang/basic_lock_unlock_gtirb.expected index a580b1b3c..bf9abb037 100644 --- a/src/test/correct/basic_lock_unlock/clang/basic_lock_unlock_gtirb.expected +++ b/src/test/correct/basic_lock_unlock/clang/basic_lock_unlock_gtirb.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -80,49 +66,49 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $z_addr) == 1bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var x_old: bv32; var z_old: bv32; $main$__0__$coGSV8OXQlKjGr7fs6hIYw: + assume {:captureState "$main$__0__$coGSV8OXQlKjGr7fs6hIYw"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1820$0"} true; + R8, Gamma_R8 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, bvadd64(R8, 56bv64)) ==> true); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 0bv32), gamma_store32(Gamma_mem, 69688bv64, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1832$0"} true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 69632bv64, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock.expected b/src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock.expected index 63d9058f6..2cee414a8 100644 --- a/src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock.expected +++ b/src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,28 +31,21 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -86,61 +72,57 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $z_addr) == 1bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_4: bool; - var Gamma_R9_3: bool; - var R8_4: bv64; - var R9_3: bv64; var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R9) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 1bv32), gamma_store32(Gamma_mem, R9_3, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002e5"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_4, Gamma_R8_4 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, R8_4) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R8) ==> true); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R8_4, 0bv32), gamma_store32(Gamma_mem, R8_4, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002fd"} true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_4, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_4, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock_gtirb.expected b/src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock_gtirb.expected index 3edecb5a7..d4173aa27 100644 --- a/src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock_gtirb.expected +++ b/src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock_gtirb.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,28 +31,21 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -86,61 +72,57 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $z_addr) == 1bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_4: bool; - var Gamma_R9_3: bool; - var R8_4: bv64; - var R9_3: bv64; var x_old: bv32; var z_old: bv32; $main$__0__$o1i8tH7ZQJKzGeXslZGxww: + assume {:captureState "$main$__0__$o1i8tH7ZQJKzGeXslZGxww"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R9) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 1bv32), gamma_store32(Gamma_mem, R9_3, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1888$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_4, Gamma_R8_4 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, R8_4) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R8) ==> true); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R8_4, 0bv32), gamma_store32(Gamma_mem, R8_4, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1904$0"} true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_4, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_4, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/gcc/basic_lock_unlock.expected b/src/test/correct/basic_lock_unlock/gcc/basic_lock_unlock.expected index b49481955..3b4d7df9b 100644 --- a/src/test/correct/basic_lock_unlock/gcc/basic_lock_unlock.expected +++ b/src/test/correct/basic_lock_unlock/gcc/basic_lock_unlock.expected @@ -1,29 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +25,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -80,49 +64,51 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $z_addr) == 1bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002e4"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> true); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 0bv32), gamma_store32(Gamma_mem, 69656bv64, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002f6"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/gcc/basic_lock_unlock_gtirb.expected b/src/test/correct/basic_lock_unlock/gcc/basic_lock_unlock_gtirb.expected index 5b96b742c..0e359f034 100644 --- a/src/test/correct/basic_lock_unlock/gcc/basic_lock_unlock_gtirb.expected +++ b/src/test/correct/basic_lock_unlock/gcc/basic_lock_unlock_gtirb.expected @@ -1,29 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +25,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -80,49 +64,51 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $z_addr) == 1bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { var x_old: bv32; var z_old: bv32; $main$__0__$Rto88S8uQGavFIfjSKtjNg: + assume {:captureState "$main$__0__$Rto88S8uQGavFIfjSKtjNg"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> true); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 0bv32), gamma_store32(Gamma_mem, 69656bv64, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1836$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/gcc_O2/basic_lock_unlock.expected b/src/test/correct/basic_lock_unlock/gcc_O2/basic_lock_unlock.expected index 159056e96..eec3701a1 100644 --- a/src/test/correct/basic_lock_unlock/gcc_O2/basic_lock_unlock.expected +++ b/src/test/correct/basic_lock_unlock/gcc_O2/basic_lock_unlock.expected @@ -1,29 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +29,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -80,49 +68,49 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_R3, Gamma_mem, R0, R1, R2, R3, mem; requires (memory_load32_le(mem, $z_addr) == 1bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool) +implementation main() { var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R3, Gamma_R3 := 1bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R3); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R3); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000001c3"} true; call rely(); - assert (L(mem, 69656bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, bvadd64(R2, 4bv64)) ==> true); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 0bv32), gamma_store32(Gamma_mem, 69656bv64, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 4bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R2, 4bv64), true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000001ca"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out, R3_out := 0bv64, 69632bv64, 69652bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out, Gamma_R3_out := true, true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/gcc_O2/basic_lock_unlock_gtirb.expected b/src/test/correct/basic_lock_unlock/gcc_O2/basic_lock_unlock_gtirb.expected index 702cdf96e..00dbd52b5 100644 --- a/src/test/correct/basic_lock_unlock/gcc_O2/basic_lock_unlock_gtirb.expected +++ b/src/test/correct/basic_lock_unlock/gcc_O2/basic_lock_unlock_gtirb.expected @@ -1,29 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +29,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -80,49 +68,49 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_R3, Gamma_mem, R0, R1, R2, R3, mem; requires (memory_load32_le(mem, $z_addr) == 1bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool) +implementation main() { var x_old: bv32; var z_old: bv32; $main$__0__$THM0T_BARlWyFvHws4y5Sw: + assume {:captureState "$main$__0__$THM0T_BARlWyFvHws4y5Sw"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R3, Gamma_R3 := 1bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R3); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R3); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1552$0"} true; call rely(); - assert (L(mem, 69656bv64) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, bvadd64(R2, 4bv64)) ==> true); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 0bv32), gamma_store32(Gamma_mem, 69656bv64, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 4bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R2, 4bv64), true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1556$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out, R3_out := 0bv64, 69632bv64, 69652bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out, Gamma_R3_out := true, true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/gcc_pic/basic_lock_unlock.expected b/src/test/correct/basic_lock_unlock/gcc_pic/basic_lock_unlock.expected index c80bf993a..da9677480 100644 --- a/src/test/correct/basic_lock_unlock/gcc_pic/basic_lock_unlock.expected +++ b/src/test/correct/basic_lock_unlock/gcc_pic/basic_lock_unlock.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,28 +29,21 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -86,61 +70,57 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $z_addr) == 1bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var R0_3: bv64; - var R0_5: bv64; var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002e5"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_5) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> true); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_5, 0bv32), gamma_store32(Gamma_mem, R0_5, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002f8"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/gcc_pic/basic_lock_unlock_gtirb.expected b/src/test/correct/basic_lock_unlock/gcc_pic/basic_lock_unlock_gtirb.expected index b04de88e8..65c38fdf8 100644 --- a/src/test/correct/basic_lock_unlock/gcc_pic/basic_lock_unlock_gtirb.expected +++ b/src/test/correct/basic_lock_unlock/gcc_pic/basic_lock_unlock_gtirb.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,28 +29,21 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -86,61 +70,57 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $z_addr) == 1bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var R0_3: bv64; - var R0_5: bv64; var x_old: bv32; var z_old: bv32; $main$__0__$hORBC0L8TymPxLxjwBXKWQ: + assume {:captureState "$main$__0__$hORBC0L8TymPxLxjwBXKWQ"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1888$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_5) ==> true); - z_old := memory_load32_le(mem, $z_addr); + assert (L(mem, R0) ==> true); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_5, 0bv32), gamma_store32(Gamma_mem, R0_5, true); + z_old := memory_load32_le(mem, $z_addr); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "1900$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_loop_assign/clang/basic_loop_assign.expected b/src/test/correct/basic_loop_assign/clang/basic_loop_assign.expected index e65b0e38a..ee929dc6b 100644 --- a/src/test/correct/basic_loop_assign/clang/basic_loop_assign.expected +++ b/src/test/correct/basic_loop_assign/clang/basic_loop_assign.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -80,42 +66,40 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures ((memory_load32_le(mem, $x_addr) == 20bv32) || (memory_load32_le(mem, $x_addr) == 21bv32)); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 20bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 20bv32), gamma_store32(Gamma_mem, 69684bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "%000002ce"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 20bv64, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_loop_assign/clang/basic_loop_assign_gtirb.expected b/src/test/correct/basic_loop_assign/clang/basic_loop_assign_gtirb.expected index f8dbb8758..1360f86d7 100644 --- a/src/test/correct/basic_loop_assign/clang/basic_loop_assign_gtirb.expected +++ b/src/test/correct/basic_loop_assign/clang/basic_loop_assign_gtirb.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -80,42 +66,40 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures ((memory_load32_le(mem, $x_addr) == 20bv32) || (memory_load32_le(mem, $x_addr) == 21bv32)); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var x_old: bv32; $main$__0__$L_e50MLRSa~d2P~wAEs2UA: + assume {:captureState "$main$__0__$L_e50MLRSa~d2P~wAEs2UA"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 20bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 20bv32), gamma_store32(Gamma_mem, 69684bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "1820$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 20bv64, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign.expected b/src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign.expected index 1e15f00b4..83c27b684 100644 --- a/src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign.expected +++ b/src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,27 +31,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -85,48 +71,44 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures ((memory_load32_le(mem, $x_addr) == 20bv32) || (memory_load32_le(mem, $x_addr) == 21bv32)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R9_3: bool; - var R9_3: bv64; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); + R8, Gamma_R8 := 20bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 20bv32), gamma_store32(Gamma_mem, R9_3, true); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "%000002d9"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 20bv64, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign_gtirb.expected b/src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign_gtirb.expected index 7cd51fcf8..f0747770f 100644 --- a/src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign_gtirb.expected +++ b/src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign_gtirb.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,27 +31,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -85,48 +71,44 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures ((memory_load32_le(mem, $x_addr) == 20bv32) || (memory_load32_le(mem, $x_addr) == 21bv32)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R9_3: bool; - var R9_3: bv64; var x_old: bv32; $main$__0__$MX_GEJThQOiJAxGVoE4EUA: + assume {:captureState "$main$__0__$MX_GEJThQOiJAxGVoE4EUA"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); + R8, Gamma_R8 := 20bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 20bv32), gamma_store32(Gamma_mem, R9_3, true); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "1888$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 20bv64, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_loop_assign/gcc/basic_loop_assign.expected b/src/test/correct/basic_loop_assign/gcc/basic_loop_assign.expected index a05d312a5..e0062a835 100644 --- a/src/test/correct/basic_loop_assign/gcc/basic_loop_assign.expected +++ b/src/test/correct/basic_loop_assign/gcc/basic_loop_assign.expected @@ -1,29 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +25,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -80,42 +64,41 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures ((memory_load32_le(mem, $x_addr) == 20bv32) || (memory_load32_le(mem, $x_addr) == 21bv32)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 20bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 20bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "%000002d8"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 20bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_loop_assign/gcc/basic_loop_assign_gtirb.expected b/src/test/correct/basic_loop_assign/gcc/basic_loop_assign_gtirb.expected index 528330881..0af511b16 100644 --- a/src/test/correct/basic_loop_assign/gcc/basic_loop_assign_gtirb.expected +++ b/src/test/correct/basic_loop_assign/gcc/basic_loop_assign_gtirb.expected @@ -1,29 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +25,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -80,42 +64,41 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures ((memory_load32_le(mem, $x_addr) == 20bv32) || (memory_load32_le(mem, $x_addr) == 21bv32)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { var x_old: bv32; $main$__0__$p4UERrmhRwu7KcaoTRPNUg: + assume {:captureState "$main$__0__$p4UERrmhRwu7KcaoTRPNUg"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 20bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 20bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 20bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_loop_assign/gcc_O2/basic_loop_assign.expected b/src/test/correct/basic_loop_assign/gcc_O2/basic_loop_assign.expected index aeddf3d0e..ba3a372d4 100644 --- a/src/test/correct/basic_loop_assign/gcc_O2/basic_loop_assign.expected +++ b/src/test/correct/basic_loop_assign/gcc_O2/basic_loop_assign.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -80,42 +66,40 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures ((memory_load32_le(mem, $x_addr) == 20bv32) || (memory_load32_le(mem, $x_addr) == 21bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := 20bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 20bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "%000001bd"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, 20bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_loop_assign/gcc_O2/basic_loop_assign_gtirb.expected b/src/test/correct/basic_loop_assign/gcc_O2/basic_loop_assign_gtirb.expected index 59ace4afa..a6dc84191 100644 --- a/src/test/correct/basic_loop_assign/gcc_O2/basic_loop_assign_gtirb.expected +++ b/src/test/correct/basic_loop_assign/gcc_O2/basic_loop_assign_gtirb.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -80,42 +66,40 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures ((memory_load32_le(mem, $x_addr) == 20bv32) || (memory_load32_le(mem, $x_addr) == 21bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { var x_old: bv32; $main$__0__$tffdqh2YTRCyJnOTdD6cPQ: + assume {:captureState "$main$__0__$tffdqh2YTRCyJnOTdD6cPQ"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := 20bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 20bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "1548$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, 20bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_loop_assign/gcc_pic/basic_loop_assign.expected b/src/test/correct/basic_loop_assign/gcc_pic/basic_loop_assign.expected index dce72a965..17b1df7e3 100644 --- a/src/test/correct/basic_loop_assign/gcc_pic/basic_loop_assign.expected +++ b/src/test/correct/basic_loop_assign/gcc_pic/basic_loop_assign.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,27 +29,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -85,48 +69,44 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures ((memory_load32_le(mem, $x_addr) == 20bv32) || (memory_load32_le(mem, $x_addr) == 21bv32)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var R0_3: bv64; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := 20bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 20bv32), gamma_store32(Gamma_mem, R0_3, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "%000002d9"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 20bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_loop_assign/gcc_pic/basic_loop_assign_gtirb.expected b/src/test/correct/basic_loop_assign/gcc_pic/basic_loop_assign_gtirb.expected index 6219f4716..399b13120 100644 --- a/src/test/correct/basic_loop_assign/gcc_pic/basic_loop_assign_gtirb.expected +++ b/src/test/correct/basic_loop_assign/gcc_pic/basic_loop_assign_gtirb.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,27 +29,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -85,48 +69,44 @@ implementation {:extern} guarantee_reflexive() assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (memory_load32_le(mem, $x_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures ((memory_load32_le(mem, $x_addr) == 20bv32) || (memory_load32_le(mem, $x_addr) == 21bv32)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var R0_3: bv64; var x_old: bv32; $main$__0__$~IFbIe1LSOiw4wk6mEI7Ig: + assume {:captureState "$main$__0__$~IFbIe1LSOiw4wk6mEI7Ig"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := 20bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 20bv32), gamma_store32(Gamma_mem, R0_3, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "1888$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 20bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation.expected b/src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation.expected index aa0cbc1e6..97c370685 100644 --- a/src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation.expected +++ b/src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation.expected @@ -1,43 +1,50 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1952bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvneg"} bvneg32(bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); function {:extern} {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); function {:extern} {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -48,28 +55,22 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1952bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1953bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1954bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1955bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1952bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -77,8 +78,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -91,93 +92,98 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R0, R10, R31, R8, R9, VF, ZF, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1952bv64) == 1bv8); - free requires (memory_load8_le(mem, 1953bv64) == 0bv8); - free requires (memory_load8_le(mem, 1954bv64) == 2bv8); - free requires (memory_load8_le(mem, 1955bv64) == 0bv8); + free requires (memory_load32_le(mem, 1952bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1952bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1953bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1954bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1955bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1952bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_13: bool; - var Gamma_R8_4: bool; - var Gamma_R8_5: bool; - var Gamma_R8_6: bool; - var Gamma_R8_7: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var Gamma_R9_6: bool; - var Gamma_R9_7: bool; - var R10_1: bv64; - var R8_1: bv32; - var R8_10: bv32; - var R8_13: bv64; - var R8_4: bv32; - var R8_5: bv32; - var R8_6: bv32; - var R8_7: bv32; - var R9_1: bv32; - var R9_2: bv32; - var R9_3: bv64; - var R9_6: bv64; - var R9_7: bv64; + var #4: bv32; + var #5: bv32; + var Gamma_#4: bool; + var Gamma_#5: bool; lmain: - R8_1, Gamma_R8_1 := R0_in[32:0], Gamma_R0_in; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_1), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_1); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R1_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 2bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), true); - R8_4, Gamma_R8_4 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - R9_1, Gamma_R9_1 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - R8_5, Gamma_R8_5 := bvxor32(R8_4, R9_1), (Gamma_R9_1 && Gamma_R8_4); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551588bv64), R8_5), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64), Gamma_R8_5); - R8_6, Gamma_R8_6 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - R9_2, Gamma_R9_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551588bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64)); - R8_7, Gamma_R8_7 := bvor32(R8_6, R9_2), (Gamma_R9_2 && Gamma_R8_6); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R8_7), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R8_7); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 30bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), 17bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), true); - R8_10, Gamma_R8_10 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - assert Gamma_R10_1; + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + R8, Gamma_R8 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%00000338"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R8); + assume {:captureState "%00000340"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%00000348"} true; + R8, Gamma_R8 := 2bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000355"} true; + R8, Gamma_R8 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000362"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R8, Gamma_R8 := zero_extend32_32(bvxor32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%0000037f"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); + R8, Gamma_R8 := zero_extend32_32(bvor32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000039c"} true; + R8, Gamma_R8 := 30bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%000003a9"} true; + R8, Gamma_R8 := 17bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%000003b6"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + assert Gamma_R10; goto lmain_goto_l000003c9, lmain_goto_l000003ce; - lmain_goto_l000003ce: - assume (!(R10_1[32:0] == 0bv32)); - R9_3, Gamma_R9_3 := zero_extend32_32(bvsdiv33(sign_extend1_32(R8_10), sign_extend1_32(R10_1[32:0]))[32:0]), (Gamma_R10_1 && Gamma_R8_10); - R9_6, Gamma_R9_6 := R9_3, Gamma_R9_3; + l000003ce: + assume {:captureState "l000003ce"} true; + R9, Gamma_R9 := zero_extend32_32(bvsdiv33(sign_extend1_32(R8[32:0]), sign_extend1_32(R10[32:0]))[32:0]), (Gamma_R10 && Gamma_R8); goto l000003d1; - lmain_goto_l000003c9: - assume (R10_1[32:0] == 0bv32); - R9_6, Gamma_R9_6 := 0bv64, true; + l000003c9: + assume {:captureState "l000003c9"} true; + R9, Gamma_R9 := 0bv64, true; goto l000003d1; l000003d1: - R9_7, Gamma_R9_7 := zero_extend32_32(bvmul64(zero_extend32_32(R9_6[32:0]), zero_extend32_32(R10_1[32:0]))[32:0]), (Gamma_R10_1 && Gamma_R9_6); - R8_13, Gamma_R8_13 := zero_extend32_32(bvadd32(R8_10, bvneg32(R9_7[32:0]))), (Gamma_R9_7 && Gamma_R8_10); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551588bv64), R8_13[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64), Gamma_R8_13); + assume {:captureState "l000003d1"} true; + R9, Gamma_R9 := zero_extend32_32(bvmul64(zero_extend32_32(R9[32:0]), zero_extend32_32(R10[32:0]))[32:0]), (Gamma_R10 && Gamma_R9); + #4, Gamma_#4 := bvnot32(R9[32:0]), Gamma_R9; + #5, Gamma_#5 := bvadd32(R8[32:0], bvnot32(R9[32:0])), (Gamma_R9 && Gamma_R8); + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(bvadd33(sign_extend1_32(R8[32:0]), sign_extend1_32(#4)), 1bv33))), (Gamma_#4 && (Gamma_R8 && Gamma_#5)); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#5, 1bv32)), bvadd33(bvadd33(zero_extend1_32(R8[32:0]), zero_extend1_32(#4)), 1bv33))), (Gamma_#4 && (Gamma_R8 && Gamma_#5)); + ZF, Gamma_ZF := bvcomp32(bvadd32(#5, 1bv32), 0bv32), Gamma_#5; + NF, Gamma_NF := bvadd32(#5, 1bv32)[32:31], Gamma_#5; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#5, 1bv32)), Gamma_#5; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000407"} true; + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l000003c9: + assume {:captureState "lmain_goto_l000003c9"} true; + assume (bvcomp32(R10[32:0], 0bv32) != 0bv1); + goto l000003c9; + lmain_goto_l000003ce: + assume {:captureState "lmain_goto_l000003ce"} true; + assume (bvcomp32(R10[32:0], 0bv32) == 0bv1); + goto l000003ce; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_13, R9_7; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_13, Gamma_R9_7; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation_gtirb.expected b/src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation_gtirb.expected index 260c708bd..cf9b45fac 100644 --- a/src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation_gtirb.expected +++ b/src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation_gtirb.expected @@ -1,43 +1,50 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1952bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvneg"} bvneg32(bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); function {:extern} {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); function {:extern} {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -48,28 +55,22 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1952bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1953bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1954bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1955bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1952bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -77,8 +78,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -91,93 +92,92 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R0, R10, R31, R8, R9, VF, ZF, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1952bv64) == 1bv8); - free requires (memory_load8_le(mem, 1953bv64) == 0bv8); - free requires (memory_load8_le(mem, 1954bv64) == 2bv8); - free requires (memory_load8_le(mem, 1955bv64) == 0bv8); + free requires (memory_load32_le(mem, 1952bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1952bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1953bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1954bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1955bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1952bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_13: bool; - var Gamma_R8_4: bool; - var Gamma_R8_5: bool; - var Gamma_R8_6: bool; - var Gamma_R8_7: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var Gamma_R9_6: bool; - var Gamma_R9_7: bool; - var R10_1: bv64; - var R8_1: bv32; - var R8_10: bv32; - var R8_13: bv64; - var R8_4: bv32; - var R8_5: bv32; - var R8_6: bv32; - var R8_7: bv32; - var R9_1: bv32; - var R9_2: bv32; - var R9_3: bv64; - var R9_6: bv64; - var R9_7: bv64; + var Cse0__5$0$26: bv32; + var Cse2__5$0$26: bv32; + var Gamma_Cse0__5$0$26: bool; + var Gamma_Cse2__5$0$26: bool; $main$__0__$f_18rgXZQX6Lj31g4VI6BQ: - R8_1, Gamma_R8_1 := R0_in[32:0], Gamma_R0_in; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_1), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_1); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R1_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 2bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), true); - R8_4, Gamma_R8_4 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - R9_1, Gamma_R9_1 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - R8_5, Gamma_R8_5 := bvxor32(R8_4, R9_1), (Gamma_R9_1 && Gamma_R8_4); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551588bv64), R8_5), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64), Gamma_R8_5); - R8_6, Gamma_R8_6 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - R9_2, Gamma_R9_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551588bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64)); - R8_7, Gamma_R8_7 := bvor32(R8_6, R9_2), (Gamma_R9_2 && Gamma_R8_6); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R8_7), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R8_7); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 30bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), 17bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), true); - R8_10, Gamma_R8_10 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - assert Gamma_R10_1; + assume {:captureState "$main$__0__$f_18rgXZQX6Lj31g4VI6BQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + R8, Gamma_R8 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "1824$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R8); + assume {:captureState "1828$0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "1832$0"} true; + R8, Gamma_R8 := 2bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1840$0"} true; + R8, Gamma_R8 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1848$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R8, Gamma_R8 := zero_extend32_32(bvxor32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "1864$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); + R8, Gamma_R8 := zero_extend32_32(bvor32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1880$0"} true; + R8, Gamma_R8 := 30bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1888$0"} true; + R8, Gamma_R8 := 17bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1896$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + assert Gamma_R10; goto $main$__0__$f_18rgXZQX6Lj31g4VI6BQ$__0, $main$__0__$f_18rgXZQX6Lj31g4VI6BQ$__1; - $main$__0__$f_18rgXZQX6Lj31g4VI6BQ$__1: - assume (!(R10_1[32:0] == 0bv32)); - R9_3, Gamma_R9_3 := zero_extend32_32(bvsdiv33(sign_extend1_32(R8_10), sign_extend1_32(R10_1[32:0]))[32:0]), (Gamma_R10_1 && Gamma_R8_10); - R9_6, Gamma_R9_6 := R9_3, Gamma_R9_3; - goto $main$__0__$f_18rgXZQX6Lj31g4VI6BQ$__2; $main$__0__$f_18rgXZQX6Lj31g4VI6BQ$__0: - assume (R10_1[32:0] == 0bv32); - R9_6, Gamma_R9_6 := 0bv64, true; + assume {:captureState "$main$__0__$f_18rgXZQX6Lj31g4VI6BQ$__0"} true; + assume (R10[32:0] == 0bv32); + R9, Gamma_R9 := 0bv64, true; + goto $main$__0__$f_18rgXZQX6Lj31g4VI6BQ$__2; + $main$__0__$f_18rgXZQX6Lj31g4VI6BQ$__1: + assume {:captureState "$main$__0__$f_18rgXZQX6Lj31g4VI6BQ$__1"} true; + assume (!(R10[32:0] == 0bv32)); + R9, Gamma_R9 := zero_extend32_32(bvsdiv33(sign_extend1_32(R8[32:0]), sign_extend1_32(R10[32:0]))[32:0]), (Gamma_R10 && Gamma_R8); goto $main$__0__$f_18rgXZQX6Lj31g4VI6BQ$__2; $main$__0__$f_18rgXZQX6Lj31g4VI6BQ$__2: - R9_7, Gamma_R9_7 := zero_extend32_32(bvmul64(zero_extend32_32(R9_6[32:0]), zero_extend32_32(R10_1[32:0]))[32:0]), (Gamma_R10_1 && Gamma_R9_6); - R8_13, Gamma_R8_13 := zero_extend32_32(bvadd32(R8_10, bvneg32(R9_7[32:0]))), (Gamma_R9_7 && Gamma_R8_10); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551588bv64), R8_13[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64), Gamma_R8_13); + assume {:captureState "$main$__0__$f_18rgXZQX6Lj31g4VI6BQ$__2"} true; + R9, Gamma_R9 := zero_extend32_32(bvmul64(zero_extend32_32(R9[32:0]), zero_extend32_32(R10[32:0]))[32:0]), (Gamma_R10 && Gamma_R9); + Cse2__5$0$26, Gamma_Cse2__5$0$26 := bvnot32(R9[32:0]), Gamma_R9; + Cse0__5$0$26, Gamma_Cse0__5$0$26 := bvadd32(R8[32:0], bvnot32(R9[32:0])), (Gamma_R9 && Gamma_R8); + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(Cse0__5$0$26, 1bv32)), bvadd33(bvadd33(sign_extend1_32(R8[32:0]), sign_extend1_32(Cse2__5$0$26)), 1bv33))), (Gamma_Cse2__5$0$26 && (Gamma_R8 && Gamma_Cse0__5$0$26)); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(Cse0__5$0$26, 1bv32)), bvadd33(bvadd33(zero_extend1_32(R8[32:0]), zero_extend1_32(Cse2__5$0$26)), 1bv33))), (Gamma_Cse2__5$0$26 && (Gamma_R8 && Gamma_Cse0__5$0$26)); + ZF, Gamma_ZF := bvcomp32(bvadd32(Cse0__5$0$26, 1bv32), 0bv32), Gamma_Cse0__5$0$26; + NF, Gamma_NF := bvadd32(Cse0__5$0$26, 1bv32)[32:31], Gamma_Cse0__5$0$26; + R8, Gamma_R8 := zero_extend32_32(bvadd32(Cse0__5$0$26, 1bv32)), Gamma_Cse0__5$0$26; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "1920$0"} true; + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_13, R9_7; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_13, Gamma_R9_7; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation.expected b/src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation.expected index 9ec8ec7de..44bceb181 100644 --- a/src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation.expected +++ b/src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation.expected @@ -1,43 +1,35 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1948bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvneg"} bvneg32(bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); function {:extern} {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); function {:extern} {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -48,28 +40,21 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1948bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1949bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1950bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1951bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1948bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -77,8 +62,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -91,92 +76,86 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_R31, Gamma_stack, R0, R1, R2, R31, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1948bv64) == 1bv8); - free requires (memory_load8_le(mem, 1949bv64) == 0bv8); - free requires (memory_load8_le(mem, 1950bv64) == 2bv8); - free requires (memory_load8_le(mem, 1951bv64) == 0bv8); + free requires (memory_load32_le(mem, 1948bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1948bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1949bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1950bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1951bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1948bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_13: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var Gamma_R1_6: bool; - var Gamma_R2_1: bool; - var Gamma_R2_4: bool; - var R0_10: bv32; - var R0_13: bv32; - var R0_4: bv32; - var R0_5: bv32; - var R0_6: bv32; - var R0_7: bv32; - var R1_2: bv32; - var R1_3: bv32; - var R1_4: bv32; - var R1_5: bv32; - var R1_6: bv64; - var R2_1: bv64; - var R2_4: bv64; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R1_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 2bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R1_2, Gamma_R1_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - R0_4, Gamma_R0_4 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - R0_5, Gamma_R0_5 := bvxor32(R1_2, R0_4), (Gamma_R0_4 && Gamma_R1_2); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_5), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_5); - R1_3, Gamma_R1_3 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - R0_6, Gamma_R0_6 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - R0_7, Gamma_R0_7 := bvor32(R1_3, R0_6), (Gamma_R0_6 && Gamma_R1_3); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_7), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_7); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 30bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 17bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R0_10, Gamma_R0_10 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - R1_4, Gamma_R1_4 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - assert Gamma_R1_4; + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000032a"} true; + stack, Gamma_stack := memory_store64_le(stack, R31, R1), gamma_store64(Gamma_stack, R31, Gamma_R1); + assume {:captureState "%00000332"} true; + R0, Gamma_R0 := 2bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R0); + assume {:captureState "%0000033f"} true; + R0, Gamma_R0 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%0000034c"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); + R0, Gamma_R0 := zero_extend32_32(bvxor32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000369"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + R0, Gamma_R0 := zero_extend32_32(bvor32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000386"} true; + R0, Gamma_R0 := 30bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R0); + assume {:captureState "%00000393"} true; + R0, Gamma_R0 := 17bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%000003a0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); + assert Gamma_R1; goto lmain_goto_l000003b3, lmain_goto_l000003b8; - lmain_goto_l000003b8: - assume (!(R1_4 == 0bv32)); - R2_1, Gamma_R2_1 := zero_extend32_32(bvsdiv33(sign_extend1_32(R0_10), sign_extend1_32(R1_4))[32:0]), (Gamma_R1_4 && Gamma_R0_10); - R2_4, Gamma_R2_4 := R2_1, Gamma_R2_1; + l000003b8: + assume {:captureState "l000003b8"} true; + R2, Gamma_R2 := zero_extend32_32(bvsdiv33(sign_extend1_32(R0[32:0]), sign_extend1_32(R1[32:0]))[32:0]), (Gamma_R1 && Gamma_R0); goto l000003bb; - lmain_goto_l000003b3: - assume (R1_4 == 0bv32); - R2_4, Gamma_R2_4 := 0bv64, true; + l000003b3: + assume {:captureState "l000003b3"} true; + R2, Gamma_R2 := 0bv64, true; goto l000003bb; l000003bb: - R1_5, Gamma_R1_5 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - R1_6, Gamma_R1_6 := zero_extend32_32(bvmul64(zero_extend32_32(R2_4[32:0]), zero_extend32_32(R1_5))[32:0]), (Gamma_R1_5 && Gamma_R2_4); - R0_13, Gamma_R0_13 := bvadd32(R0_10, bvneg32(R1_6[32:0])), (Gamma_R1_6 && Gamma_R0_10); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_13), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_13); + assume {:captureState "l000003bb"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); + R1, Gamma_R1 := zero_extend32_32(bvmul64(zero_extend32_32(R2[32:0]), zero_extend32_32(R1[32:0]))[32:0]), (Gamma_R1 && Gamma_R2); + R0, Gamma_R0 := zero_extend32_32(bvadd32(bvadd32(R0[32:0], bvnot32(R1[32:0])), 1bv32)), (Gamma_R1 && Gamma_R0); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%000003dc"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l000003b3: + assume {:captureState "lmain_goto_l000003b3"} true; + assume (bvcomp32(R1[32:0], 0bv32) != 0bv1); + goto l000003b3; + lmain_goto_l000003b8: + assume {:captureState "lmain_goto_l000003b8"} true; + assume (bvcomp32(R1[32:0], 0bv32) == 0bv1); + goto l000003b8; main_basil_return: - R0_out, R1_out, R2_out, R31_out := 0bv64, R1_6, R2_4, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out, Gamma_R31_out := true, Gamma_R1_6, Gamma_R2_4, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation_gtirb.expected b/src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation_gtirb.expected index 89d96ae52..b5ec9e0ac 100644 --- a/src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation_gtirb.expected +++ b/src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation_gtirb.expected @@ -1,43 +1,34 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1948bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvneg"} bvneg32(bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); function {:extern} {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); function {:extern} {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -48,28 +39,21 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1948bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1949bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1950bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1951bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1948bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -77,8 +61,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -91,92 +75,80 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_R31, Gamma_stack, R0, R1, R2, R31, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1948bv64) == 1bv8); - free requires (memory_load8_le(mem, 1949bv64) == 0bv8); - free requires (memory_load8_le(mem, 1950bv64) == 2bv8); - free requires (memory_load8_le(mem, 1951bv64) == 0bv8); + free requires (memory_load32_le(mem, 1948bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1948bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1949bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1950bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1951bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1948bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_13: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var Gamma_R1_6: bool; - var Gamma_R2_1: bool; - var Gamma_R2_4: bool; - var R0_10: bv32; - var R0_13: bv32; - var R0_4: bv32; - var R0_5: bv32; - var R0_6: bv32; - var R0_7: bv32; - var R1_2: bv32; - var R1_3: bv32; - var R1_4: bv32; - var R1_5: bv32; - var R1_6: bv64; - var R2_1: bv64; - var R2_4: bv64; $main$__0__$B9tkaGtQRX6xFjqGS87lEw: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R1_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 2bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R1_2, Gamma_R1_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - R0_4, Gamma_R0_4 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - R0_5, Gamma_R0_5 := bvxor32(R1_2, R0_4), (Gamma_R0_4 && Gamma_R1_2); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_5), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_5); - R1_3, Gamma_R1_3 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - R0_6, Gamma_R0_6 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - R0_7, Gamma_R0_7 := bvor32(R1_3, R0_6), (Gamma_R0_6 && Gamma_R1_3); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_7), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_7); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 30bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 17bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R0_10, Gamma_R0_10 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - R1_4, Gamma_R1_4 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - assert Gamma_R1_4; + assume {:captureState "$main$__0__$B9tkaGtQRX6xFjqGS87lEw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1816$0"} true; + stack, Gamma_stack := memory_store64_le(stack, R31, R1), gamma_store64(Gamma_stack, R31, Gamma_R1); + assume {:captureState "1820$0"} true; + R0, Gamma_R0 := 2bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R0); + assume {:captureState "1828$0"} true; + R0, Gamma_R0 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "1836$0"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); + R0, Gamma_R0 := zero_extend32_32(bvxor32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1852$0"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + R0, Gamma_R0 := zero_extend32_32(bvor32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "1868$0"} true; + R0, Gamma_R0 := 30bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R0); + assume {:captureState "1876$0"} true; + R0, Gamma_R0 := 17bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "1884$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); + assert Gamma_R1; goto $main$__0__$B9tkaGtQRX6xFjqGS87lEw$__0, $main$__0__$B9tkaGtQRX6xFjqGS87lEw$__1; - $main$__0__$B9tkaGtQRX6xFjqGS87lEw$__1: - assume (!(R1_4 == 0bv32)); - R2_1, Gamma_R2_1 := zero_extend32_32(bvsdiv33(sign_extend1_32(R0_10), sign_extend1_32(R1_4))[32:0]), (Gamma_R1_4 && Gamma_R0_10); - R2_4, Gamma_R2_4 := R2_1, Gamma_R2_1; - goto $main$__0__$B9tkaGtQRX6xFjqGS87lEw$__2; $main$__0__$B9tkaGtQRX6xFjqGS87lEw$__0: - assume (R1_4 == 0bv32); - R2_4, Gamma_R2_4 := 0bv64, true; + assume {:captureState "$main$__0__$B9tkaGtQRX6xFjqGS87lEw$__0"} true; + assume (R1[32:0] == 0bv32); + R2, Gamma_R2 := 0bv64, true; + goto $main$__0__$B9tkaGtQRX6xFjqGS87lEw$__2; + $main$__0__$B9tkaGtQRX6xFjqGS87lEw$__1: + assume {:captureState "$main$__0__$B9tkaGtQRX6xFjqGS87lEw$__1"} true; + assume (!(R1[32:0] == 0bv32)); + R2, Gamma_R2 := zero_extend32_32(bvsdiv33(sign_extend1_32(R0[32:0]), sign_extend1_32(R1[32:0]))[32:0]), (Gamma_R1 && Gamma_R0); goto $main$__0__$B9tkaGtQRX6xFjqGS87lEw$__2; $main$__0__$B9tkaGtQRX6xFjqGS87lEw$__2: - R1_5, Gamma_R1_5 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - R1_6, Gamma_R1_6 := zero_extend32_32(bvmul64(zero_extend32_32(R2_4[32:0]), zero_extend32_32(R1_5))[32:0]), (Gamma_R1_5 && Gamma_R2_4); - R0_13, Gamma_R0_13 := bvadd32(R0_10, bvneg32(R1_6[32:0])), (Gamma_R1_6 && Gamma_R0_10); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_13), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_13); + assume {:captureState "$main$__0__$B9tkaGtQRX6xFjqGS87lEw$__2"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); + R1, Gamma_R1 := zero_extend32_32(bvmul64(zero_extend32_32(R2[32:0]), zero_extend32_32(R1[32:0]))[32:0]), (Gamma_R1 && Gamma_R2); + R0, Gamma_R0 := zero_extend32_32(bvadd32(bvadd32(R0[32:0], bvnot32(R1[32:0])), 1bv32)), (Gamma_R1 && Gamma_R0); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1912$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out, R31_out := 0bv64, R1_6, R2_4, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out, Gamma_R31_out := true, Gamma_R1_6, Gamma_R2_4, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read.expected index 6007195eb..c8bb1c0d2 100644 --- a/src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read.expected @@ -1,35 +1,42 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +47,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -87,70 +89,91 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_4: bool; - var Gamma_R8_9: bool; - var R0_1: bv64; - var R8_2: bv32; - var R8_4: bv32; - var R8_9: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f5"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_2), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_2); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000309"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_4, Gamma_R8_4 := memory_load32_le(mem, 69688bv64), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - assert Gamma_R8_4; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000336, lmain_goto_l00000339; - lmain_goto_l00000339: - assume (R8_4 == 0bv32); - R8_9, Gamma_R8_9 := 1bv64, true; + l00000339: + assume {:captureState "l00000339"} true; + R8, Gamma_R8 := 1bv64, true; goto l0000033c; - lmain_goto_l00000336: - assume (!(R8_4 == 0bv32)); - R8_9, Gamma_R8_9 := 0bv64, true; + l00000336: + assume {:captureState "l00000336"} true; + R8, Gamma_R8 := 0bv64, true; goto l0000033c; l0000033c: - assert Gamma_R8_9; + assume {:captureState "l0000033c"} true; + assert Gamma_R8; goto l0000033c_goto_l00000344, l0000033c_goto_l0000035b; - l0000033c_goto_l0000035b: - assume (!(R8_9[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - goto l00000344; - l0000033c_goto_l00000344: - assume (R8_9[1:0] == 1bv1); + l0000035b: + assume {:captureState "l0000035b"} true; + goto l0000035c; + l0000035c: + assume {:captureState "l0000035c"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000364"} true; goto l00000344; l00000344: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "l00000344"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000336: + assume {:captureState "lmain_goto_l00000336"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000336; + lmain_goto_l00000339: + assume {:captureState "lmain_goto_l00000339"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000339; + l0000033c_goto_l00000344: + assume {:captureState "l0000033c_goto_l00000344"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l00000344; + l0000033c_goto_l0000035b: + assume {:captureState "l0000033c_goto_l0000035b"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l0000035b; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_9; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_9; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read_gtirb.expected b/src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read_gtirb.expected index 51cd6dc62..ab49772d7 100644 --- a/src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read_gtirb.expected +++ b/src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read_gtirb.expected @@ -1,35 +1,41 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +46,17 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -87,87 +87,83 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_12: bool; - var Gamma_R8_13: bool; - var Gamma_R8_2: bool; - var Gamma_R8_4: bool; - var R0_1: bv64; - var R8_10: bv64; - var R8_12: bv64; - var R8_13: bv64; - var R8_2: bv32; - var R8_4: bv32; + var Cse0__5$1$7: bv32; + var Gamma_Cse0__5$1$7: bool; $main$__0__$WzLWYelmQTqUhds6mh5VTA: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$WzLWYelmQTqUhds6mh5VTA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1816$0"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_2), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_2); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1828$0"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_4, Gamma_R8_4 := memory_load32_le(mem, 69688bv64), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - assert Gamma_R8_4; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + Cse0__5$1$7, Gamma_Cse0__5$1$7 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$1$7, Cse0__5$1$7)), Gamma_Cse0__5$1$7; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$1$7), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$1$7); + ZF, Gamma_ZF := bvcomp32(Cse0__5$1$7, 0bv32), Gamma_Cse0__5$1$7; + NF, Gamma_NF := Cse0__5$1$7[32:31], Gamma_Cse0__5$1$7; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$1$7), Gamma_Cse0__5$1$7; + assert Gamma_ZF; goto $main$__0__$WzLWYelmQTqUhds6mh5VTA$__0, $main$__0__$WzLWYelmQTqUhds6mh5VTA$__1; - $main$__0__$WzLWYelmQTqUhds6mh5VTA$__1: - assume (R8_4 == 0bv32); - goto $main$__0__$WzLWYelmQTqUhds6mh5VTA$__1_phi_$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__3__$UK2k~hvfRbmxHh2j_afrRg_phi_back_$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__3__$UK2k~hvfRbmxHh2j_afrRg, $main$__0__$WzLWYelmQTqUhds6mh5VTA$__1_phi_$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__1__$dD2JwdxOSPSFx54LfUM9kw_phi_back_$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__1__$dD2JwdxOSPSFx54LfUM9kw; - $main$__0__$WzLWYelmQTqUhds6mh5VTA$__1_phi_$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__1__$dD2JwdxOSPSFx54LfUM9kw_phi_back_$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__1__$dD2JwdxOSPSFx54LfUM9kw: - R8_10, Gamma_R8_10 := 1bv64, true; - assert Gamma_R8_10; - goto $main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__1__$dD2JwdxOSPSFx54LfUM9kw; - $main$__0__$WzLWYelmQTqUhds6mh5VTA$__1_phi_$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__3__$UK2k~hvfRbmxHh2j_afrRg_phi_back_$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__3__$UK2k~hvfRbmxHh2j_afrRg: - R8_12, Gamma_R8_12 := 1bv64, true; - assert Gamma_R8_12; - goto $main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__3__$UK2k~hvfRbmxHh2j_afrRg; - $main$__0__$WzLWYelmQTqUhds6mh5VTA$__0: - assume (!(R8_4 == 0bv32)); - goto $main$__0__$WzLWYelmQTqUhds6mh5VTA$__0_phi_back_$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__1__$dD2JwdxOSPSFx54LfUM9kw, $main$__0__$WzLWYelmQTqUhds6mh5VTA$__0_phi_back_$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__3__$UK2k~hvfRbmxHh2j_afrRg; - $main$__0__$WzLWYelmQTqUhds6mh5VTA$__0_phi_back_$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__3__$UK2k~hvfRbmxHh2j_afrRg: - R8_12, Gamma_R8_12 := 0bv64, true; - assert Gamma_R8_12; - goto $main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__3__$UK2k~hvfRbmxHh2j_afrRg; - $main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__3__$UK2k~hvfRbmxHh2j_afrRg: - assume (R8_12[1:0] == 1bv1); - R8_13, Gamma_R8_13 := R8_12, Gamma_R8_12; - goto $main$__3__$UK2k~hvfRbmxHh2j_afrRg; - $main$__0__$WzLWYelmQTqUhds6mh5VTA$__0_phi_back_$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__1__$dD2JwdxOSPSFx54LfUM9kw: - R8_10, Gamma_R8_10 := 0bv64, true; - assert Gamma_R8_10; - goto $main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__1__$dD2JwdxOSPSFx54LfUM9kw; - $main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__1__$dD2JwdxOSPSFx54LfUM9kw: - assume (!(R8_10[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R8_13, Gamma_R8_13 := R8_10, Gamma_R8_10; + $main$__1__$dD2JwdxOSPSFx54LfUM9kw: + assume {:captureState "$main$__1__$dD2JwdxOSPSFx54LfUM9kw"} true; + goto $main$__2__$7JWI5TAPT9~RSSH4jlqpjg; + $main$__2__$7JWI5TAPT9~RSSH4jlqpjg: + assume {:captureState "$main$__2__$7JWI5TAPT9~RSSH4jlqpjg"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "1856$0"} true; goto $main$__3__$UK2k~hvfRbmxHh2j_afrRg; $main$__3__$UK2k~hvfRbmxHh2j_afrRg: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__3__$UK2k~hvfRbmxHh2j_afrRg"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__3__$UK2k~hvfRbmxHh2j_afrRg: + assume {:captureState "$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__3__$UK2k~hvfRbmxHh2j_afrRg"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$UK2k~hvfRbmxHh2j_afrRg; + $main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__1__$dD2JwdxOSPSFx54LfUM9kw: + assume {:captureState "$main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__1__$dD2JwdxOSPSFx54LfUM9kw"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$dD2JwdxOSPSFx54LfUM9kw; + $main$__0__$WzLWYelmQTqUhds6mh5VTA$__0: + assume {:captureState "$main$__0__$WzLWYelmQTqUhds6mh5VTA$__0"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__3__$UK2k~hvfRbmxHh2j_afrRg, $main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__1__$dD2JwdxOSPSFx54LfUM9kw; + $main$__0__$WzLWYelmQTqUhds6mh5VTA$__1: + assume {:captureState "$main$__0__$WzLWYelmQTqUhds6mh5VTA$__1"} true; + assume (!(!(ZF == 1bv1))); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__3__$UK2k~hvfRbmxHh2j_afrRg, $main$__0__$WzLWYelmQTqUhds6mh5VTA_goto_$main$__1__$dD2JwdxOSPSFx54LfUM9kw; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_13; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_13; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read.expected index 11e000649..570c5a400 100644 --- a/src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read.expected @@ -1,14 +1,34 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -21,19 +41,14 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -64,58 +79,61 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R8, R9, VF, ZF, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R8_3: bool; - var Gamma_R9_3: bool; - var R0_3: bv64; - var R0_4: bv64; - var R8_3: bv64; - var R9_3: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); call rely(); - R9_3, Gamma_R9_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_3; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l000002fa, lmain_goto_l000002fd; - lmain_goto_l000002fd: - assume (!(R8_3[32:0] == 0bv32)); - R0_4, Gamma_R0_4 := 0bv64, true; + l000002fd: + assume {:captureState "l000002fd"} true; + R0, Gamma_R0 := 0bv64, true; goto l00000300; - lmain_goto_l000002fa: - assume (R8_3[32:0] == 0bv32); - R0_3, Gamma_R0_3 := zero_extend32_32(R9_3[32:0]), Gamma_R9_3; - R0_4, Gamma_R0_4 := R0_3, Gamma_R0_3; + l000002fa: + assume {:captureState "l000002fa"} true; + R0, Gamma_R0 := zero_extend32_32(R9[32:0]), Gamma_R9; goto l00000300; l00000300: + assume {:captureState "l00000300"} true; goto main_basil_return; + lmain_goto_l000002fa: + assume {:captureState "lmain_goto_l000002fa"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l000002fa; + lmain_goto_l000002fd: + assume {:captureState "lmain_goto_l000002fd"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l000002fd; main_basil_return: - R0_out, R8_out, R9_out := R0_4, R8_3, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_4, Gamma_R8_3, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read_gtirb.expected b/src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read_gtirb.expected index 88664c0f7..14bd77436 100644 --- a/src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read_gtirb.expected +++ b/src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read_gtirb.expected @@ -1,14 +1,33 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -21,19 +40,13 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -64,56 +77,52 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R8, R9, VF, ZF, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R8_3: bool; - var Gamma_R9_3: bool; - var R0_3: bv64; - var R0_4: bv64; - var R8_3: bv64; - var R9_3: bv64; + var Cse0__5$0$4: bv32; + var Gamma_Cse0__5$0$4: bool; $main$__0__$a~U4vJBkTaO8Xfm888rzkw: + assume {:captureState "$main$__0__$a~U4vJBkTaO8Xfm888rzkw"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); call rely(); - R9_3, Gamma_R9_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_3; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); + Cse0__5$0$4, Gamma_Cse0__5$0$4 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$4, Cse0__5$0$4)), Gamma_Cse0__5$0$4; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$4), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$0$4); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$4, 0bv32), Gamma_Cse0__5$0$4; + NF, Gamma_NF := Cse0__5$0$4[32:31], Gamma_Cse0__5$0$4; + assert Gamma_ZF; goto $main$__0__$a~U4vJBkTaO8Xfm888rzkw$__0, $main$__0__$a~U4vJBkTaO8Xfm888rzkw$__1; - $main$__0__$a~U4vJBkTaO8Xfm888rzkw$__1: - assume (!(R8_3[32:0] == 0bv32)); - R0_4, Gamma_R0_4 := 0bv64, true; - goto main_basil_return; $main$__0__$a~U4vJBkTaO8Xfm888rzkw$__0: - assume (R8_3[32:0] == 0bv32); - R0_3, Gamma_R0_3 := zero_extend32_32(R9_3[32:0]), Gamma_R9_3; - R0_4, Gamma_R0_4 := R0_3, Gamma_R0_3; + assume {:captureState "$main$__0__$a~U4vJBkTaO8Xfm888rzkw$__0"} true; + assume (ZF == 1bv1); + R0, Gamma_R0 := zero_extend32_32(R9[32:0]), Gamma_R9; + goto main_basil_return; + $main$__0__$a~U4vJBkTaO8Xfm888rzkw$__1: + assume {:captureState "$main$__0__$a~U4vJBkTaO8Xfm888rzkw$__1"} true; + assume (!(ZF == 1bv1)); + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := R0_4, R8_3, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_4, Gamma_R8_3, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read.expected index d094da2f1..d01c59e33 100644 --- a/src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read.expected @@ -1,25 +1,36 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +40,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,29 +51,24 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,82 +95,99 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1968bv64) == 1bv8); - free requires (memory_load8_le(mem, 1969bv64) == 0bv8); - free requires (memory_load8_le(mem, 1970bv64) == 2bv8); - free requires (memory_load8_le(mem, 1971bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1968bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_5: bool; - var Gamma_R8_6: bool; - var R0_1: bv64; - var R8_11: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_5: bv64; - var R8_6: bv32; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002fd"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_3); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000318"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_5, Gamma_R8_5 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - R8_6, Gamma_R8_6 := memory_load32_le(mem, R8_5), (gamma_load32(Gamma_mem, R8_5) || L(mem, R8_5)); - assert Gamma_R8_6; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l0000034c, lmain_goto_l0000034f; - lmain_goto_l0000034f: - assume (R8_6 == 0bv32); - R8_11, Gamma_R8_11 := 1bv64, true; + l0000034f: + assume {:captureState "l0000034f"} true; + R8, Gamma_R8 := 1bv64, true; goto l00000352; - lmain_goto_l0000034c: - assume (!(R8_6 == 0bv32)); - R8_11, Gamma_R8_11 := 0bv64, true; + l0000034c: + assume {:captureState "l0000034c"} true; + R8, Gamma_R8 := 0bv64, true; goto l00000352; l00000352: - assert Gamma_R8_11; + assume {:captureState "l00000352"} true; + assert Gamma_R8; goto l00000352_goto_l0000035a, l00000352_goto_l00000371; - l00000352_goto_l00000371: - assume (!(R8_11[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - goto l0000035a; - l00000352_goto_l0000035a: - assume (R8_11[1:0] == 1bv1); + l00000371: + assume {:captureState "l00000371"} true; + goto l00000372; + l00000372: + assume {:captureState "l00000372"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%0000037a"} true; goto l0000035a; l0000035a: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "l0000035a"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l0000034c: + assume {:captureState "lmain_goto_l0000034c"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l0000034c; + lmain_goto_l0000034f: + assume {:captureState "lmain_goto_l0000034f"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l0000034f; + l00000352_goto_l0000035a: + assume {:captureState "l00000352_goto_l0000035a"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l0000035a; + l00000352_goto_l00000371: + assume {:captureState "l00000352_goto_l00000371"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000371; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_11; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_11; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read_gtirb.expected b/src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read_gtirb.expected index dfe4f901c..66e17bf7d 100644 --- a/src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read_gtirb.expected +++ b/src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read_gtirb.expected @@ -1,25 +1,35 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +39,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,29 +50,23 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,99 +93,91 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1968bv64) == 1bv8); - free requires (memory_load8_le(mem, 1969bv64) == 0bv8); - free requires (memory_load8_le(mem, 1970bv64) == 2bv8); - free requires (memory_load8_le(mem, 1971bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1968bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_12: bool; - var Gamma_R8_14: bool; - var Gamma_R8_15: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_5: bool; - var Gamma_R8_6: bool; - var R0_1: bv64; - var R8_12: bv64; - var R8_14: bv64; - var R8_15: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_5: bv64; - var R8_6: bv32; + var Cse0__5$3$9: bv32; + var Gamma_Cse0__5$3$9: bool; $main$__0__$_zy4nZRRQ4202Be_0Qr3jw: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$_zy4nZRRQ4202Be_0Qr3jw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1880$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_3); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1896$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_5, Gamma_R8_5 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - R8_6, Gamma_R8_6 := memory_load32_le(mem, R8_5), (gamma_load32(Gamma_mem, R8_5) || L(mem, R8_5)); - assert Gamma_R8_6; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + Cse0__5$3$9, Gamma_Cse0__5$3$9 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$3$9, Cse0__5$3$9)), Gamma_Cse0__5$3$9; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$9), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$3$9); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$9, 0bv32), Gamma_Cse0__5$3$9; + NF, Gamma_NF := Cse0__5$3$9[32:31], Gamma_Cse0__5$3$9; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$3$9), Gamma_Cse0__5$3$9; + assert Gamma_ZF; goto $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__0, $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__1; - $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__1: - assume (R8_6 == 0bv32); - goto $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__1_phi_$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__3__$LP5ka6yvSFWP2kjw23G57g_phi_back_$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__3__$LP5ka6yvSFWP2kjw23G57g, $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__1_phi_$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__1__$rmVyzzfSSQeYVjuxiNU3PA_phi_back_$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__1__$rmVyzzfSSQeYVjuxiNU3PA; - $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__1_phi_$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__1__$rmVyzzfSSQeYVjuxiNU3PA_phi_back_$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__1__$rmVyzzfSSQeYVjuxiNU3PA: - R8_12, Gamma_R8_12 := 1bv64, true; - assert Gamma_R8_12; - goto $main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__1__$rmVyzzfSSQeYVjuxiNU3PA; - $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__1_phi_$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__3__$LP5ka6yvSFWP2kjw23G57g_phi_back_$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__3__$LP5ka6yvSFWP2kjw23G57g: - R8_14, Gamma_R8_14 := 1bv64, true; - assert Gamma_R8_14; - goto $main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__3__$LP5ka6yvSFWP2kjw23G57g; - $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__0: - assume (!(R8_6 == 0bv32)); - goto $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__0_phi_back_$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__1__$rmVyzzfSSQeYVjuxiNU3PA, $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__0_phi_back_$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__3__$LP5ka6yvSFWP2kjw23G57g; - $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__0_phi_back_$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__3__$LP5ka6yvSFWP2kjw23G57g: - R8_14, Gamma_R8_14 := 0bv64, true; - assert Gamma_R8_14; - goto $main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__3__$LP5ka6yvSFWP2kjw23G57g; - $main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__3__$LP5ka6yvSFWP2kjw23G57g: - assume (R8_14[1:0] == 1bv1); - R8_15, Gamma_R8_15 := R8_14, Gamma_R8_14; - goto $main$__3__$LP5ka6yvSFWP2kjw23G57g; - $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__0_phi_back_$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__1__$rmVyzzfSSQeYVjuxiNU3PA: - R8_12, Gamma_R8_12 := 0bv64, true; - assert Gamma_R8_12; - goto $main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__1__$rmVyzzfSSQeYVjuxiNU3PA; - $main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__1__$rmVyzzfSSQeYVjuxiNU3PA: - assume (!(R8_12[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R8_15, Gamma_R8_15 := R8_12, Gamma_R8_12; + $main$__1__$rmVyzzfSSQeYVjuxiNU3PA: + assume {:captureState "$main$__1__$rmVyzzfSSQeYVjuxiNU3PA"} true; + goto $main$__2__$nmt_XUHDT5eyVHAHshN3ww; + $main$__2__$nmt_XUHDT5eyVHAHshN3ww: + assume {:captureState "$main$__2__$nmt_XUHDT5eyVHAHshN3ww"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "1928$0"} true; goto $main$__3__$LP5ka6yvSFWP2kjw23G57g; $main$__3__$LP5ka6yvSFWP2kjw23G57g: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__3__$LP5ka6yvSFWP2kjw23G57g"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__3__$LP5ka6yvSFWP2kjw23G57g: + assume {:captureState "$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__3__$LP5ka6yvSFWP2kjw23G57g"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$LP5ka6yvSFWP2kjw23G57g; + $main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__1__$rmVyzzfSSQeYVjuxiNU3PA: + assume {:captureState "$main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__1__$rmVyzzfSSQeYVjuxiNU3PA"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$rmVyzzfSSQeYVjuxiNU3PA; + $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__0: + assume {:captureState "$main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__0"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__3__$LP5ka6yvSFWP2kjw23G57g, $main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__1__$rmVyzzfSSQeYVjuxiNU3PA; + $main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__1: + assume {:captureState "$main$__0__$_zy4nZRRQ4202Be_0Qr3jw$__1"} true; + assume (!(!(ZF == 1bv1))); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__3__$LP5ka6yvSFWP2kjw23G57g, $main$__0__$_zy4nZRRQ4202Be_0Qr3jw_goto_$main$__1__$rmVyzzfSSQeYVjuxiNU3PA; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_15; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_15; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/gcc/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/gcc/basic_sec_policy_read.expected index 0d4b53b94..7f1f47659 100644 --- a/src/test/correct/basic_sec_policy_read/gcc/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/gcc/basic_sec_policy_read.expected @@ -1,35 +1,40 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +45,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -87,56 +87,67 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1888bv64) == 1bv8); - free requires (memory_load8_le(mem, 1889bv64) == 0bv8); - free requires (memory_load8_le(mem, 1890bv64) == 2bv8); - free requires (memory_load8_le(mem, 1891bv64) == 0bv8); + free requires (memory_load32_le(mem, 1888bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var R0_3: bv32; - var R0_6: bv32; - var R0_7: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_3); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000300"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, 69656bv64), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l0000032e, lmain_goto_l00000345; - lmain_goto_l00000345: - assume (!(R0_6 == 0bv32)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - goto l0000032e; - lmain_goto_l0000032e: - assume (R0_6 == 0bv32); + l00000345: + assume {:captureState "l00000345"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%0000034a"} true; goto l0000032e; l0000032e: - R0_7, Gamma_R0_7 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l0000032e"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l0000032e: + assume {:captureState "lmain_goto_l0000032e"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l0000032e; + lmain_goto_l00000345: + assume {:captureState "lmain_goto_l00000345"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l00000345; main_basil_return: - R0_out, R31_out := R0_7, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_7, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/gcc/basic_sec_policy_read_gtirb.expected b/src/test/correct/basic_sec_policy_read/gcc/basic_sec_policy_read_gtirb.expected index 59536899b..eaf8bfed3 100644 --- a/src/test/correct/basic_sec_policy_read/gcc/basic_sec_policy_read_gtirb.expected +++ b/src/test/correct/basic_sec_policy_read/gcc/basic_sec_policy_read_gtirb.expected @@ -1,35 +1,39 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +44,17 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -87,56 +85,67 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1888bv64) == 1bv8); - free requires (memory_load8_le(mem, 1889bv64) == 0bv8); - free requires (memory_load8_le(mem, 1890bv64) == 2bv8); - free requires (memory_load8_le(mem, 1891bv64) == 0bv8); + free requires (memory_load32_le(mem, 1888bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var R0_3: bv32; - var R0_6: bv32; - var R0_7: bv64; + var Cse0__5$0$8: bv32; + var Gamma_Cse0__5$0$8: bool; $main$__0__$qLy9TrC9QH2pk7NWiim55Q: + assume {:captureState "$main$__0__$qLy9TrC9QH2pk7NWiim55Q"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_3); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1828$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, 69656bv64), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$0$8, Gamma_Cse0__5$0$8 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$8, Cse0__5$0$8)), Gamma_Cse0__5$0$8; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$8), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$0$8); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$8, 0bv32), Gamma_Cse0__5$0$8; + NF, Gamma_NF := Cse0__5$0$8[32:31], Gamma_Cse0__5$0$8; + assert Gamma_ZF; goto $main$__0__$qLy9TrC9QH2pk7NWiim55Q_goto_$main$__2__$w_2v0dVvQ2~CbK2pWb20GA, $main$__0__$qLy9TrC9QH2pk7NWiim55Q_goto_$main$__1__$_azgQEK1R4ujBoxU5Olnyw; - $main$__0__$qLy9TrC9QH2pk7NWiim55Q_goto_$main$__1__$_azgQEK1R4ujBoxU5Olnyw: - assume (!(R0_6 == 0bv32)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - goto $main$__2__$w_2v0dVvQ2~CbK2pWb20GA; - $main$__0__$qLy9TrC9QH2pk7NWiim55Q_goto_$main$__2__$w_2v0dVvQ2~CbK2pWb20GA: - assume (R0_6 == 0bv32); + $main$__1__$_azgQEK1R4ujBoxU5Olnyw: + assume {:captureState "$main$__1__$_azgQEK1R4ujBoxU5Olnyw"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1852$0"} true; goto $main$__2__$w_2v0dVvQ2~CbK2pWb20GA; $main$__2__$w_2v0dVvQ2~CbK2pWb20GA: - R0_7, Gamma_R0_7 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__2__$w_2v0dVvQ2~CbK2pWb20GA"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$qLy9TrC9QH2pk7NWiim55Q_goto_$main$__2__$w_2v0dVvQ2~CbK2pWb20GA: + assume {:captureState "$main$__0__$qLy9TrC9QH2pk7NWiim55Q_goto_$main$__2__$w_2v0dVvQ2~CbK2pWb20GA"} true; + assume (ZF == 1bv1); + goto $main$__2__$w_2v0dVvQ2~CbK2pWb20GA; + $main$__0__$qLy9TrC9QH2pk7NWiim55Q_goto_$main$__1__$_azgQEK1R4ujBoxU5Olnyw: + assume {:captureState "$main$__0__$qLy9TrC9QH2pk7NWiim55Q_goto_$main$__1__$_azgQEK1R4ujBoxU5Olnyw"} true; + assume (!(ZF == 1bv1)); + goto $main$__1__$_azgQEK1R4ujBoxU5Olnyw; main_basil_return: - R0_out, R31_out := R0_7, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_7, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/gcc_O2/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/gcc_O2/basic_sec_policy_read.expected index 4d26970d7..1d55828ab 100644 --- a/src/test/correct/basic_sec_policy_read/gcc_O2/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/gcc_O2/basic_sec_policy_read.expected @@ -1,14 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -21,19 +29,12 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -64,55 +65,50 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_4: bool; - var Gamma_R1_3: bool; - var R0_2: bv64; - var R0_4: bv64; - var R1_3: bv64; lmain: + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R0, Gamma_R0 := 0bv64, true; call rely(); - R1_3, Gamma_R1_3 := zero_extend32_32(memory_load32_le(mem, 69652bv64)), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R1_3; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 20bv64)) || L(mem, bvadd64(R1, 20bv64))); + assert Gamma_R1; goto lmain_goto_l000001c2, lmain_goto_l0000039c; - lmain_goto_l0000039c: - assume (R1_3[32:0] == 0bv32); + l0000039c: + assume {:captureState "l0000039c"} true; call rely(); - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(mem, 69656bv64)), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - R0_4, Gamma_R0_4 := R0_2, Gamma_R0_2; - goto l000001c2; - lmain_goto_l000001c2: - assume (!(R1_3[32:0] == 0bv32)); - R0_4, Gamma_R0_4 := 0bv64, true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 4bv64)) || L(mem, bvadd64(R2, 4bv64))); goto l000001c2; l000001c2: + assume {:captureState "l000001c2"} true; goto main_basil_return; + lmain_goto_l000001c2: + assume {:captureState "lmain_goto_l000001c2"} true; + assume (bvnot1(bvcomp32(R1[32:0], 0bv32)) != 0bv1); + goto l000001c2; + lmain_goto_l0000039c: + assume {:captureState "lmain_goto_l0000039c"} true; + assume (bvnot1(bvcomp32(R1[32:0], 0bv32)) == 0bv1); + goto l0000039c; main_basil_return: - R0_out, R1_out, R2_out := R0_4, R1_3, 69652bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := Gamma_R0_4, Gamma_R1_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/gcc_O2/basic_sec_policy_read_gtirb.expected b/src/test/correct/basic_sec_policy_read/gcc_O2/basic_sec_policy_read_gtirb.expected index b79bcae5c..332049bab 100644 --- a/src/test/correct/basic_sec_policy_read/gcc_O2/basic_sec_policy_read_gtirb.expected +++ b/src/test/correct/basic_sec_policy_read/gcc_O2/basic_sec_policy_read_gtirb.expected @@ -1,11 +1,17 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); @@ -21,19 +27,12 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -64,55 +63,50 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_4: bool; - var Gamma_R1_3: bool; - var R0_2: bv64; - var R0_4: bv64; - var R1_3: bv64; $main$__0__$iALoIb4ETM23Kc4pUOH9GQ: + assume {:captureState "$main$__0__$iALoIb4ETM23Kc4pUOH9GQ"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R0, Gamma_R0 := 0bv64, true; call rely(); - R1_3, Gamma_R1_3 := zero_extend32_32(memory_load32_le(mem, 69652bv64)), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R1_3; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 20bv64)) || L(mem, bvadd64(R1, 20bv64))); + assert Gamma_R1; goto $main$__0__$iALoIb4ETM23Kc4pUOH9GQ_goto_$main$__2__$Y~6LIazeTTCtbeZ37_HdXQ, $main$__0__$iALoIb4ETM23Kc4pUOH9GQ_goto_$main$__1__$Jddk5YHLSfKVviyVawKy~g; - $main$__0__$iALoIb4ETM23Kc4pUOH9GQ_goto_$main$__1__$Jddk5YHLSfKVviyVawKy~g: - assume (R1_3[32:0] == 0bv32); + $main$__1__$Jddk5YHLSfKVviyVawKy~g: + assume {:captureState "$main$__1__$Jddk5YHLSfKVviyVawKy~g"} true; call rely(); - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(mem, 69656bv64)), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - R0_4, Gamma_R0_4 := R0_2, Gamma_R0_2; - goto $main$__2__$Y~6LIazeTTCtbeZ37_HdXQ; - $main$__0__$iALoIb4ETM23Kc4pUOH9GQ_goto_$main$__2__$Y~6LIazeTTCtbeZ37_HdXQ: - assume (!(R1_3[32:0] == 0bv32)); - R0_4, Gamma_R0_4 := 0bv64, true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 4bv64)) || L(mem, bvadd64(R2, 4bv64))); goto $main$__2__$Y~6LIazeTTCtbeZ37_HdXQ; $main$__2__$Y~6LIazeTTCtbeZ37_HdXQ: + assume {:captureState "$main$__2__$Y~6LIazeTTCtbeZ37_HdXQ"} true; goto main_basil_return; + $main$__0__$iALoIb4ETM23Kc4pUOH9GQ_goto_$main$__2__$Y~6LIazeTTCtbeZ37_HdXQ: + assume {:captureState "$main$__0__$iALoIb4ETM23Kc4pUOH9GQ_goto_$main$__2__$Y~6LIazeTTCtbeZ37_HdXQ"} true; + assume ((R1[32:0] == 0bv32) == false); + goto $main$__2__$Y~6LIazeTTCtbeZ37_HdXQ; + $main$__0__$iALoIb4ETM23Kc4pUOH9GQ_goto_$main$__1__$Jddk5YHLSfKVviyVawKy~g: + assume {:captureState "$main$__0__$iALoIb4ETM23Kc4pUOH9GQ_goto_$main$__1__$Jddk5YHLSfKVviyVawKy~g"} true; + assume (!((R1[32:0] == 0bv32) == false)); + goto $main$__1__$Jddk5YHLSfKVviyVawKy~g; main_basil_return: - R0_out, R1_out, R2_out := R0_4, R1_3, 69652bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := Gamma_R0_4, Gamma_R1_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/gcc_pic/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/gcc_pic/basic_sec_policy_read.expected index 0935e02d6..cd3bca542 100644 --- a/src/test/correct/basic_sec_policy_read/gcc_pic/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/gcc_pic/basic_sec_policy_read.expected @@ -1,25 +1,34 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +38,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,29 +49,24 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - free ensures (memory_load8_le(mem, 1952bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1953bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1954bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1955bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 1952bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,68 +93,73 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1952bv64) == 1bv8); - free requires (memory_load8_le(mem, 1953bv64) == 0bv8); - free requires (memory_load8_le(mem, 1954bv64) == 2bv8); - free requires (memory_load8_le(mem, 1955bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 1952bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1952bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1953bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1954bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1955bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1952bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var R0_2: bv64; - var R0_3: bv32; - var R0_5: bv64; - var R0_6: bv32; - var R0_7: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, R0_2), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_3); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000301"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, R0_5), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000330, lmain_goto_l00000347; - lmain_goto_l00000347: - assume (!(R0_6 == 0bv32)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - goto l00000330; - lmain_goto_l00000330: - assume (R0_6 == 0bv32); + l00000347: + assume {:captureState "l00000347"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%0000034c"} true; goto l00000330; l00000330: - R0_7, Gamma_R0_7 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l00000330"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000330: + assume {:captureState "lmain_goto_l00000330"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l00000330; + lmain_goto_l00000347: + assume {:captureState "lmain_goto_l00000347"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l00000347; main_basil_return: - R0_out, R31_out := R0_7, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_7, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/gcc_pic/basic_sec_policy_read_gtirb.expected b/src/test/correct/basic_sec_policy_read/gcc_pic/basic_sec_policy_read_gtirb.expected index dd90a9c41..196da7a8f 100644 --- a/src/test/correct/basic_sec_policy_read/gcc_pic/basic_sec_policy_read_gtirb.expected +++ b/src/test/correct/basic_sec_policy_read/gcc_pic/basic_sec_policy_read_gtirb.expected @@ -1,25 +1,33 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +37,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,29 +48,23 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - free ensures (memory_load8_le(mem, 1952bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1953bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1954bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1955bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 1952bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,68 +91,73 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1952bv64) == 1bv8); - free requires (memory_load8_le(mem, 1953bv64) == 0bv8); - free requires (memory_load8_le(mem, 1954bv64) == 2bv8); - free requires (memory_load8_le(mem, 1955bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 1952bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1952bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1953bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1954bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1955bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1952bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var R0_2: bv64; - var R0_3: bv32; - var R0_5: bv64; - var R0_6: bv32; - var R0_7: bv64; + var Cse0__5$1$8: bv32; + var Gamma_Cse0__5$1$8: bool; $main$__0__$c_xQDd7dTMmXdcuFG3bPhA: + assume {:captureState "$main$__0__$c_xQDd7dTMmXdcuFG3bPhA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, R0_2), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_3); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1892$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, R0_5), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$1$8, Gamma_Cse0__5$1$8 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$1$8, Cse0__5$1$8)), Gamma_Cse0__5$1$8; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$1$8), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$1$8); + ZF, Gamma_ZF := bvcomp32(Cse0__5$1$8, 0bv32), Gamma_Cse0__5$1$8; + NF, Gamma_NF := Cse0__5$1$8[32:31], Gamma_Cse0__5$1$8; + assert Gamma_ZF; goto $main$__0__$c_xQDd7dTMmXdcuFG3bPhA_goto_$main$__2__$GiBIfuJeR2SduseX6HGFYw, $main$__0__$c_xQDd7dTMmXdcuFG3bPhA_goto_$main$__1__$kAMxpbl8Q2GFrZSNGYpqAA; - $main$__0__$c_xQDd7dTMmXdcuFG3bPhA_goto_$main$__1__$kAMxpbl8Q2GFrZSNGYpqAA: - assume (!(R0_6 == 0bv32)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - goto $main$__2__$GiBIfuJeR2SduseX6HGFYw; - $main$__0__$c_xQDd7dTMmXdcuFG3bPhA_goto_$main$__2__$GiBIfuJeR2SduseX6HGFYw: - assume (R0_6 == 0bv32); + $main$__1__$kAMxpbl8Q2GFrZSNGYpqAA: + assume {:captureState "$main$__1__$kAMxpbl8Q2GFrZSNGYpqAA"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1916$0"} true; goto $main$__2__$GiBIfuJeR2SduseX6HGFYw; $main$__2__$GiBIfuJeR2SduseX6HGFYw: - R0_7, Gamma_R0_7 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__2__$GiBIfuJeR2SduseX6HGFYw"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$c_xQDd7dTMmXdcuFG3bPhA_goto_$main$__2__$GiBIfuJeR2SduseX6HGFYw: + assume {:captureState "$main$__0__$c_xQDd7dTMmXdcuFG3bPhA_goto_$main$__2__$GiBIfuJeR2SduseX6HGFYw"} true; + assume (ZF == 1bv1); + goto $main$__2__$GiBIfuJeR2SduseX6HGFYw; + $main$__0__$c_xQDd7dTMmXdcuFG3bPhA_goto_$main$__1__$kAMxpbl8Q2GFrZSNGYpqAA: + assume {:captureState "$main$__0__$c_xQDd7dTMmXdcuFG3bPhA_goto_$main$__1__$kAMxpbl8Q2GFrZSNGYpqAA"} true; + assume (!(ZF == 1bv1)); + goto $main$__1__$kAMxpbl8Q2GFrZSNGYpqAA; main_basil_return: - R0_out, R31_out := R0_7, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_7, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write.expected index 99c421ef2..a3979b57c 100644 --- a/src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write.expected @@ -1,35 +1,32 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +46,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -87,69 +77,75 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1888bv64) == 1bv8); - free requires (memory_load8_le(mem, 1889bv64) == 0bv8); - free requires (memory_load8_le(mem, 1890bv64) == 2bv8); - free requires (memory_load8_le(mem, 1891bv64) == 0bv8); + free requires (memory_load32_le(mem, 1888bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; var Gamma_x_old: bool; - var R10_1: bv64; var z_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002ee"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "%00000300"} true; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R10_1); + assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R10_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R10_1); - assert ((69688bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R10); + assert ((bvadd64(R8, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000314"} true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); + assert (L(mem, bvadd64(R8, 56bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 0bv32), gamma_store32(Gamma_mem, 69688bv64, true); - assert ((69688bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); + assert ((bvadd64(R8, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000320"} true; + R8, Gamma_R8 := 2bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 2bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000032d"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, 2bv64, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write_gtirb.expected b/src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write_gtirb.expected index b3aa50ba6..9070091b0 100644 --- a/src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write_gtirb.expected +++ b/src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write_gtirb.expected @@ -1,35 +1,32 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +46,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -87,69 +77,75 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1888bv64) == 1bv8); - free requires (memory_load8_le(mem, 1889bv64) == 0bv8); - free requires (memory_load8_le(mem, 1890bv64) == 2bv8); - free requires (memory_load8_le(mem, 1891bv64) == 0bv8); + free requires (memory_load32_le(mem, 1888bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; var Gamma_x_old: bool; - var R10_1: bv64; var z_old: bv32; $main$__0__$GQL0b5TkRWCLhw9luiQEHw: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "$main$__0__$GQL0b5TkRWCLhw9luiQEHw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1816$0"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "1828$0"} true; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R10_1); + assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R10_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R10_1); - assert ((69688bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R10); + assert ((bvadd64(R8, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "1840$0"} true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); + assert (L(mem, bvadd64(R8, 56bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 0bv32), gamma_store32(Gamma_mem, 69688bv64, true); - assert ((69688bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); + assert ((bvadd64(R8, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "1848$0"} true; + R8, Gamma_R8 := 2bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 2bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "1856$0"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, 2bv64, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write.expected index 4eefb0b59..bfe1831a9 100644 --- a/src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write.expected @@ -12,8 +12,8 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); @@ -33,10 +33,6 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } @@ -45,10 +41,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -84,18 +77,12 @@ procedure main(); requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); diff --git a/src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write_gtirb.expected b/src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write_gtirb.expected index 9082fce74..7e4ff7591 100644 --- a/src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write_gtirb.expected +++ b/src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write_gtirb.expected @@ -12,8 +12,8 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); @@ -33,10 +33,6 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } @@ -45,10 +41,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -84,18 +77,12 @@ procedure main(); requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); diff --git a/src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write.expected index d63c541b0..f306f9dd4 100644 --- a/src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write.expected @@ -1,25 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +30,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,12 +41,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,16 +50,13 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,81 +83,83 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1960bv64) == 1bv8); - free requires (memory_load8_le(mem, 1961bv64) == 0bv8); - free requires (memory_load8_le(mem, 1962bv64) == 2bv8); - free requires (memory_load8_le(mem, 1963bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1960bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_3: bool; - var Gamma_R9_2: bool; var Gamma_x_old: bool; - var R10_1: bv64; - var R8_3: bv64; - var R9_2: bv64; var z_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002f6"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); + assert (L(mem, R9) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 1bv32), gamma_store32(Gamma_mem, R9_2, true); - assert ((R9_2 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "%0000030f"} true; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); - assert (L(mem, R8_3) ==> Gamma_R10_1); + assert (L(mem, R8) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_3, R10_1[32:0]), gamma_store32(Gamma_mem, R8_3, Gamma_R10_1); - assert ((R8_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, R10[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R10); + assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000032a"} true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, R8_3) ==> true); + assert (L(mem, R8) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_3, 0bv32), gamma_store32(Gamma_mem, R8_3, true); - assert ((R8_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); + assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000336"} true; + R8, Gamma_R8 := 2bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); + assert (L(mem, R9) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 2bv32), gamma_store32(Gamma_mem, R9_2, true); - assert ((R9_2 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000343"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, 2bv64, R9_2; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, true, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write_gtirb.expected b/src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write_gtirb.expected index a84f9ca3b..7bb922ca1 100644 --- a/src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write_gtirb.expected +++ b/src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write_gtirb.expected @@ -1,25 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +30,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,12 +41,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,16 +50,13 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -93,81 +83,83 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1960bv64) == 1bv8); - free requires (memory_load8_le(mem, 1961bv64) == 0bv8); - free requires (memory_load8_le(mem, 1962bv64) == 2bv8); - free requires (memory_load8_le(mem, 1963bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1960bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_3: bool; - var Gamma_R9_2: bool; var Gamma_x_old: bool; - var R10_1: bv64; - var R8_3: bv64; - var R9_2: bv64; var z_old: bv32; $main$__0__$7yoZTp0aQWOcm6Iu3MMmPw: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "$main$__0__$7yoZTp0aQWOcm6Iu3MMmPw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1880$0"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); + assert (L(mem, R9) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 1bv32), gamma_store32(Gamma_mem, R9_2, true); - assert ((R9_2 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "1896$0"} true; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); - assert (L(mem, R8_3) ==> Gamma_R10_1); + assert (L(mem, R8) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_3, R10_1[32:0]), gamma_store32(Gamma_mem, R8_3, Gamma_R10_1); - assert ((R8_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, R10[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R10); + assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "1912$0"} true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, R8_3) ==> true); + assert (L(mem, R8) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_3, 0bv32), gamma_store32(Gamma_mem, R8_3, true); - assert ((R8_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); + assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "1920$0"} true; + R8, Gamma_R8 := 2bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); + assert (L(mem, R9) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 2bv32), gamma_store32(Gamma_mem, R9_2, true); - assert ((R9_2 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "1928$0"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, 2bv64, R9_2; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, true, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_write/gcc/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/gcc/basic_sec_policy_write.expected index aaad6a02f..e759f7728 100644 --- a/src/test/correct/basic_sec_policy_write/gcc/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/gcc/basic_sec_policy_write.expected @@ -1,35 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,22 +33,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -86,69 +73,81 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1912bv64) == 1bv8); - free requires (memory_load8_le(mem, 1913bv64) == 0bv8); - free requires (memory_load8_le(mem, 1914bv64) == 2bv8); - free requires (memory_load8_le(mem, 1915bv64) == 0bv8); + free requires (memory_load32_le(mem, 1912bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R1_2: bool; var Gamma_x_old: bool; - var R1_2: bv32; var z_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000306"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 1bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - R1_2, Gamma_R1_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "%0000031e"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_2), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_2); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000338"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 0bv32), gamma_store32(Gamma_mem, 69652bv64, true); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000034a"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 2bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 2bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000362"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, 2bv64, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, true, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_write/gcc/basic_sec_policy_write_gtirb.expected b/src/test/correct/basic_sec_policy_write/gcc/basic_sec_policy_write_gtirb.expected index 158420cf3..7ca7ac1e3 100644 --- a/src/test/correct/basic_sec_policy_write/gcc/basic_sec_policy_write_gtirb.expected +++ b/src/test/correct/basic_sec_policy_write/gcc/basic_sec_policy_write_gtirb.expected @@ -1,35 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,22 +33,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -86,69 +73,81 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1912bv64) == 1bv8); - free requires (memory_load8_le(mem, 1913bv64) == 0bv8); - free requires (memory_load8_le(mem, 1914bv64) == 2bv8); - free requires (memory_load8_le(mem, 1915bv64) == 0bv8); + free requires (memory_load32_le(mem, 1912bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R1_2: bool; var Gamma_x_old: bool; - var R1_2: bv32; var z_old: bv32; $main$__0__$5B4s2Td8TWOj0raIcjCjQg: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "$main$__0__$5B4s2Td8TWOj0raIcjCjQg"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1816$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 1bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); - R1_2, Gamma_R1_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "1832$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_2), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_2); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "1848$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 0bv32), gamma_store32(Gamma_mem, 69652bv64, true); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "1860$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 2bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 2bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "1876$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, 2bv64, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, true, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_write/gcc_O2/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/gcc_O2/basic_sec_policy_write.expected index 3555af022..77502d30d 100644 --- a/src/test/correct/basic_sec_policy_write/gcc_O2/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/gcc_O2/basic_sec_policy_write.expected @@ -12,8 +12,8 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); @@ -33,10 +33,6 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } @@ -45,10 +41,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -84,18 +77,12 @@ procedure main(); requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); diff --git a/src/test/correct/basic_sec_policy_write/gcc_O2/basic_sec_policy_write_gtirb.expected b/src/test/correct/basic_sec_policy_write/gcc_O2/basic_sec_policy_write_gtirb.expected index e7ca31254..f1873f412 100644 --- a/src/test/correct/basic_sec_policy_write/gcc_O2/basic_sec_policy_write_gtirb.expected +++ b/src/test/correct/basic_sec_policy_write/gcc_O2/basic_sec_policy_write_gtirb.expected @@ -12,8 +12,8 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); @@ -33,10 +33,6 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } @@ -45,10 +41,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -84,18 +77,12 @@ procedure main(); requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); diff --git a/src/test/correct/basic_sec_policy_write/gcc_pic/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/gcc_pic/basic_sec_policy_write.expected index 6dc7cf729..aa7a508bf 100644 --- a/src/test/correct/basic_sec_policy_write/gcc_pic/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/gcc_pic/basic_sec_policy_write.expected @@ -1,25 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +26,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,28 +37,22 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); - free ensures (memory_load8_le(mem, 1976bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1977bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1978bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1979bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 1976bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -92,89 +79,89 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1976bv64) == 1bv8); - free requires (memory_load8_le(mem, 1977bv64) == 0bv8); - free requires (memory_load8_le(mem, 1978bv64) == 2bv8); - free requires (memory_load8_le(mem, 1979bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 1976bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1976bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1977bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1978bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1979bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1976bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_9: bool; - var Gamma_R1_2: bool; var Gamma_x_old: bool; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_9: bv64; - var R1_2: bv32; var z_old: bv32; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000306"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); - assert ((R0_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000031f"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); - R1_2, Gamma_R1_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_2), gamma_store32(Gamma_mem, R0_5, Gamma_R1_2); - assert ((R0_5 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000033a"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - assert (L(mem, R0_7) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_7, 0bv32), gamma_store32(Gamma_mem, R0_7, true); - assert ((R0_7 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000034d"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_9, Gamma_R0_9 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := 2bv64, true; call rely(); - assert (L(mem, R0_9) ==> true); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_9, 2bv32), gamma_store32(Gamma_mem, R0_9, true); - assert ((R0_9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000366"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, 2bv64, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, true, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basic_sec_policy_write/gcc_pic/basic_sec_policy_write_gtirb.expected b/src/test/correct/basic_sec_policy_write/gcc_pic/basic_sec_policy_write_gtirb.expected index 52c3d0fa8..700334cdf 100644 --- a/src/test/correct/basic_sec_policy_write/gcc_pic/basic_sec_policy_write_gtirb.expected +++ b/src/test/correct/basic_sec_policy_write/gcc_pic/basic_sec_policy_write_gtirb.expected @@ -1,25 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +26,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,28 +37,22 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); - free ensures (memory_load8_le(mem, 1976bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1977bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1978bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1979bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 1976bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -92,89 +79,89 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == false); +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; + requires (Gamma_R0 == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1976bv64) == 1bv8); - free requires (memory_load8_le(mem, 1977bv64) == 0bv8); - free requires (memory_load8_le(mem, 1978bv64) == 2bv8); - free requires (memory_load8_le(mem, 1979bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 1976bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1976bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1977bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1978bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1979bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1976bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_9: bool; - var Gamma_R1_2: bool; var Gamma_x_old: bool; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_9: bv64; - var R1_2: bv32; var z_old: bv32; $main$__0__$Rd6PFSFeTgqYLa9US2ew9w: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); + assume {:captureState "$main$__0__$Rd6PFSFeTgqYLa9US2ew9w"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1880$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); - assert ((R0_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "1896$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); - R1_2, Gamma_R1_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_2), gamma_store32(Gamma_mem, R0_5, Gamma_R1_2); - assert ((R0_5 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "1912$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - assert (L(mem, R0_7) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_7, 0bv32), gamma_store32(Gamma_mem, R0_7, true); - assert ((R0_7 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "1924$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_9, Gamma_R0_9 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := 2bv64, true; call rely(); - assert (L(mem, R0_9) ==> true); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_9, 2bv32), gamma_store32(Gamma_mem, R0_9, true); - assert ((R0_9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "1940$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, 2bv64, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, true, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basicassign_gamma0/clang/basicassign_gamma0.expected b/src/test/correct/basicassign_gamma0/clang/basicassign_gamma0.expected index 472bc1cb7..665a042aa 100644 --- a/src/test/correct/basicassign_gamma0/clang/basicassign_gamma0.expected +++ b/src/test/correct/basicassign_gamma0/clang/basicassign_gamma0.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +31,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +40,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -80,42 +66,38 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (gamma_load32(Gamma_mem, $secret_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var R8_3: bv64; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%000002d9"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basicassign_gamma0/clang/basicassign_gamma0_gtirb.expected b/src/test/correct/basicassign_gamma0/clang/basicassign_gamma0_gtirb.expected index 6ecb1f802..08553b2a1 100644 --- a/src/test/correct/basicassign_gamma0/clang/basicassign_gamma0_gtirb.expected +++ b/src/test/correct/basicassign_gamma0/clang/basicassign_gamma0_gtirb.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +31,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +40,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -80,42 +66,38 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (gamma_load32(Gamma_mem, $secret_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var R8_3: bv64; $main$__0__$z8gjj~niR~us0mMf~~CgEA: + assume {:captureState "$main$__0__$z8gjj~niR~us0mMf~~CgEA"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0.expected b/src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0.expected index 40c461c35..ca1f84813 100644 --- a/src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0.expected +++ b/src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0.expected @@ -1,23 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +24,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +35,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -55,16 +44,13 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); - free ensures (memory_load8_le(mem, 1928bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1929bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1930bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1931bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free ensures (memory_load32_le(mem, 1928bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -86,54 +72,46 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (gamma_load32(Gamma_mem, $secret_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1928bv64) == 1bv8); - free requires (memory_load8_le(mem, 1929bv64) == 0bv8); - free requires (memory_load8_le(mem, 1930bv64) == 2bv8); - free requires (memory_load8_le(mem, 1931bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load32_le(mem, 1928bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1928bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1929bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1930bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1931bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1928bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R9_3: bool; - var R8_3: bv64; - var R8_4: bv64; - var R9_3: bv64; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - R8_4, Gamma_R8_4 := zero_extend32_32(memory_load32_le(mem, R8_3)), (gamma_load32(Gamma_mem, R8_3) || L(mem, R8_3)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R8_4[32:0]), gamma_store32(Gamma_mem, R9_3, Gamma_R8_4); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000002ef"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_4, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_4, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0_gtirb.expected b/src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0_gtirb.expected index abefd580f..011c7af6c 100644 --- a/src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0_gtirb.expected +++ b/src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0_gtirb.expected @@ -1,23 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +24,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +35,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -55,16 +44,13 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); - free ensures (memory_load8_le(mem, 1928bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1929bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1930bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1931bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free ensures (memory_load32_le(mem, 1928bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -86,54 +72,46 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires (gamma_load32(Gamma_mem, $secret_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1928bv64) == 1bv8); - free requires (memory_load8_le(mem, 1929bv64) == 0bv8); - free requires (memory_load8_le(mem, 1930bv64) == 2bv8); - free requires (memory_load8_le(mem, 1931bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load32_le(mem, 1928bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1928bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1929bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1930bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1931bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1928bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R9_3: bool; - var R8_3: bv64; - var R8_4: bv64; - var R9_3: bv64; $main$__0__$F4R_psC2T4y6sYXDzaadXQ: + assume {:captureState "$main$__0__$F4R_psC2T4y6sYXDzaadXQ"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - R8_4, Gamma_R8_4 := zero_extend32_32(memory_load32_le(mem, R8_3)), (gamma_load32(Gamma_mem, R8_3) || L(mem, R8_3)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R8_4[32:0]), gamma_store32(Gamma_mem, R9_3, Gamma_R8_4); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1896$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_4, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_4, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basicassign_gamma0/gcc/basicassign_gamma0.expected b/src/test/correct/basicassign_gamma0/gcc/basicassign_gamma0.expected index 8deac4459..360bde82a 100644 --- a/src/test/correct/basicassign_gamma0/gcc/basicassign_gamma0.expected +++ b/src/test/correct/basicassign_gamma0/gcc/basicassign_gamma0.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69656bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +29,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +38,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); - free ensures (memory_load8_le(mem, 1864bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1865bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1866bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1867bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1864bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -80,42 +64,40 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (gamma_load32(Gamma_mem, $secret_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1864bv64) == 1bv8); - free requires (memory_load8_le(mem, 1865bv64) == 0bv8); - free requires (memory_load8_le(mem, 1866bv64) == 2bv8); - free requires (memory_load8_le(mem, 1867bv64) == 0bv8); + free requires (memory_load32_le(mem, 1864bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1864bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1865bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1866bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1867bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1864bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R1_2: bool; - var R1_2: bv64; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(mem, 69656bv64)), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_2[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000002ed"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_2; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basicassign_gamma0/gcc/basicassign_gamma0_gtirb.expected b/src/test/correct/basicassign_gamma0/gcc/basicassign_gamma0_gtirb.expected index 5f0b25505..8e56ac1a2 100644 --- a/src/test/correct/basicassign_gamma0/gcc/basicassign_gamma0_gtirb.expected +++ b/src/test/correct/basicassign_gamma0/gcc/basicassign_gamma0_gtirb.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69656bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +29,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +38,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); - free ensures (memory_load8_le(mem, 1864bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1865bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1866bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1867bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1864bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -80,42 +64,40 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (gamma_load32(Gamma_mem, $secret_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1864bv64) == 1bv8); - free requires (memory_load8_le(mem, 1865bv64) == 0bv8); - free requires (memory_load8_le(mem, 1866bv64) == 2bv8); - free requires (memory_load8_le(mem, 1867bv64) == 0bv8); + free requires (memory_load32_le(mem, 1864bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1864bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1865bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1866bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1867bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1864bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R1_2: bool; - var R1_2: bv64; $main$__0__$M0T7btlSRzGIu2yXb8baZw: + assume {:captureState "$main$__0__$M0T7btlSRzGIu2yXb8baZw"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(mem, 69656bv64)), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_2[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1832$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_2; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basicassign_gamma0/gcc_O2/basicassign_gamma0.expected b/src/test/correct/basicassign_gamma0/gcc_O2/basicassign_gamma0.expected index 50a4ffeed..a6c4c2b09 100644 --- a/src/test/correct/basicassign_gamma0/gcc_O2/basicassign_gamma0.expected +++ b/src/test/correct/basicassign_gamma0/gcc_O2/basicassign_gamma0.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69656bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +31,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +40,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -80,42 +66,38 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; requires (gamma_load32(Gamma_mem, $secret_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R2_3: bool; - var R2_3: bv64; lmain: + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R0, Gamma_R0 := 0bv64, true; call rely(); - R2_3, Gamma_R2_3 := zero_extend32_32(memory_load32_le(mem, 69656bv64)), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); + R2, Gamma_R2 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 4bv64)) || L(mem, bvadd64(R2, 4bv64))); call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R2_3[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R2_3); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); + assume {:captureState "%000001c5"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, R2_3; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, Gamma_R2_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basicassign_gamma0/gcc_O2/basicassign_gamma0_gtirb.expected b/src/test/correct/basicassign_gamma0/gcc_O2/basicassign_gamma0_gtirb.expected index e14f70a9c..18d09ccfd 100644 --- a/src/test/correct/basicassign_gamma0/gcc_O2/basicassign_gamma0_gtirb.expected +++ b/src/test/correct/basicassign_gamma0/gcc_O2/basicassign_gamma0_gtirb.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69656bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,12 +31,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -51,10 +40,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -80,42 +66,38 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; requires (gamma_load32(Gamma_mem, $secret_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R2_3: bool; - var R2_3: bv64; $main$__0__$ZeApiS~BRSG296M3kaSCnQ: + assume {:captureState "$main$__0__$ZeApiS~BRSG296M3kaSCnQ"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R0, Gamma_R0 := 0bv64, true; call rely(); - R2_3, Gamma_R2_3 := zero_extend32_32(memory_load32_le(mem, 69656bv64)), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); + R2, Gamma_R2 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 4bv64)) || L(mem, bvadd64(R2, 4bv64))); call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R2_3[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R2_3); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); + assume {:captureState "1552$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, R2_3; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, Gamma_R2_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basicassign_gamma0/gcc_pic/basicassign_gamma0.expected b/src/test/correct/basicassign_gamma0/gcc_pic/basicassign_gamma0.expected index 55025dceb..ced19431d 100644 --- a/src/test/correct/basicassign_gamma0/gcc_pic/basicassign_gamma0.expected +++ b/src/test/correct/basicassign_gamma0/gcc_pic/basicassign_gamma0.expected @@ -1,23 +1,18 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69656bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +22,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +33,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -55,16 +42,13 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); - free ensures (memory_load8_le(mem, 1928bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1929bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1930bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1931bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1928bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -86,54 +70,46 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (gamma_load32(Gamma_mem, $secret_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1928bv64) == 1bv8); - free requires (memory_load8_le(mem, 1929bv64) == 0bv8); - free requires (memory_load8_le(mem, 1930bv64) == 2bv8); - free requires (memory_load8_le(mem, 1931bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1928bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1928bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1929bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1930bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1931bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1928bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R1_2: bool; - var R0_3: bv64; - var R0_5: bv64; - var R1_2: bv64; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(mem, R0_3)), (gamma_load32(Gamma_mem, R0_3) || L(mem, R0_3)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_2[32:0]), gamma_store32(Gamma_mem, R0_5, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000002ef"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_2; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basicassign_gamma0/gcc_pic/basicassign_gamma0_gtirb.expected b/src/test/correct/basicassign_gamma0/gcc_pic/basicassign_gamma0_gtirb.expected index 0a07822bc..653ba335f 100644 --- a/src/test/correct/basicassign_gamma0/gcc_pic/basicassign_gamma0_gtirb.expected +++ b/src/test/correct/basicassign_gamma0/gcc_pic/basicassign_gamma0_gtirb.expected @@ -1,23 +1,18 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69656bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +22,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +33,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -55,16 +42,13 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); - free ensures (memory_load8_le(mem, 1928bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1929bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1930bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1931bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1928bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -86,54 +70,46 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (gamma_load32(Gamma_mem, $secret_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1928bv64) == 1bv8); - free requires (memory_load8_le(mem, 1929bv64) == 0bv8); - free requires (memory_load8_le(mem, 1930bv64) == 2bv8); - free requires (memory_load8_le(mem, 1931bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1928bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1928bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1929bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1930bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1931bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1928bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R1_2: bool; - var R0_3: bv64; - var R0_5: bv64; - var R1_2: bv64; $main$__0__$WRy2wCdrSBWU_mSIGGNB5Q: + assume {:captureState "$main$__0__$WRy2wCdrSBWU_mSIGGNB5Q"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(mem, R0_3)), (gamma_load32(Gamma_mem, R0_3) || L(mem, R0_3)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_2[32:0]), gamma_store32(Gamma_mem, R0_5, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1896$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_2; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/basicfree/clang/basicfree.expected b/src/test/correct/basicfree/clang/basicfree.expected index 060eda80a..1224cf5b2 100644 --- a/src/test/correct/basicfree/clang/basicfree.expected +++ b/src/test/correct/basicfree/clang/basicfree.expected @@ -1,72 +1,63 @@ +var {:extern} Gamma_R0: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2080bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69592bv64) == 2004bv64); @@ -74,8 +65,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -88,278 +79,91 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); modifies Gamma_R16, Gamma_R17, R16, R17; - free requires (memory_load8_le(mem, 2080bv64) == 1bv8); - free requires (memory_load8_le(mem, 2081bv64) == 0bv8); - free requires (memory_load8_le(mem, 2082bv64) == 2bv8); - free requires (memory_load8_le(mem, 2083bv64) == 0bv8); + free requires (memory_load32_le(mem, 2080bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 2000bv64); free requires (memory_load64_le(mem, 69072bv64) == 1920bv64); free requires (memory_load64_le(mem, 69592bv64) == 2004bv64); free requires (memory_load64_le(mem, 69688bv64) == 69688bv64); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69592bv64) == 2004bv64); free ensures (memory_load64_le(mem, 69688bv64) == 69688bv64); -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69680bv64) == 0bv64); free requires (memory_load64_le(mem, 69688bv64) == 69688bv64); - free requires (memory_load8_le(mem, 2080bv64) == 1bv8); - free requires (memory_load8_le(mem, 2081bv64) == 0bv8); - free requires (memory_load8_le(mem, 2082bv64) == 2bv8); - free requires (memory_load8_le(mem, 2083bv64) == 0bv8); + free requires (memory_load32_le(mem, 2080bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 2000bv64); free requires (memory_load64_le(mem, 69072bv64) == 1920bv64); free requires (memory_load64_le(mem, 69592bv64) == 2004bv64); free requires (memory_load64_le(mem, 69688bv64) == 69688bv64); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69592bv64) == 2004bv64); free ensures (memory_load64_le(mem, 69688bv64) == 69688bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R10_2: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R11_2: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R12_2: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R13_2: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R14_2: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R15_2: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R18_2: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R19_2: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R20_2: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R21_2: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R22_2: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R23_2: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R24_2: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R25_2: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R26_2: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R27_2: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R28_2: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R29_5: bool; - var Gamma_R2_1: bool; - var Gamma_R2_2: bool; - var Gamma_R3: bool; - var Gamma_R30_3: bool; - var Gamma_R30_5: bool; - var Gamma_R30_6: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R3_1: bool; - var Gamma_R3_2: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R4_2: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R5_2: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R6_2: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R7_2: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R8_3: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var R0_2: bv64; - var R0_3: bv64; - var R0_4: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R10_2: bv64; - var R11: bv64; - var R11_1: bv64; - var R11_2: bv64; - var R12: bv64; - var R12_1: bv64; - var R12_2: bv64; - var R13: bv64; - var R13_1: bv64; - var R13_2: bv64; - var R14: bv64; - var R14_1: bv64; - var R14_2: bv64; - var R15: bv64; - var R15_1: bv64; - var R15_2: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R17: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R18_2: bv64; - var R19: bv64; - var R19_1: bv64; - var R19_2: bv64; - var R1_1: bv64; - var R1_2: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R20_2: bv64; - var R21: bv64; - var R21_1: bv64; - var R21_2: bv64; - var R22: bv64; - var R22_1: bv64; - var R22_2: bv64; - var R23: bv64; - var R23_1: bv64; - var R23_2: bv64; - var R24: bv64; - var R24_1: bv64; - var R24_2: bv64; - var R25: bv64; - var R25_1: bv64; - var R25_2: bv64; - var R26: bv64; - var R26_1: bv64; - var R26_2: bv64; - var R27: bv64; - var R27_1: bv64; - var R27_2: bv64; - var R28: bv64; - var R28_1: bv64; - var R28_2: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R29_5: bv64; - var R2_1: bv64; - var R2_2: bv64; - var R3: bv64; - var R30_3: bv64; - var R30_5: bv64; - var R30_6: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R3_1: bv64; - var R3_2: bv64; - var R4: bv64; - var R4_1: bv64; - var R4_2: bv64; - var R5: bv64; - var R5_1: bv64; - var R5_2: bv64; - var R6: bv64; - var R6_1: bv64; - var R6_2: bv64; - var R7: bv64; - var R7_1: bv64; - var R7_2: bv64; - var R8: bv64; - var R8_1: bv64; - var R8_3: bv64; - var R9: bv64; - var R9_1: bv64; - var R9_2: bv64; - var R9_3: bv64; + var #4: bv64; + var #5: bv64; + var Gamma_#4: bool; + var Gamma_#5: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(4bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, R2, Gamma_R2, 2024bv64, true, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + #4, Gamma_#4 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002f2"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002f8"} true; + R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2024bv64, true; + call malloc(); goto l0000030d; l0000030d: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_3, 8bv64), R0_2), gamma_store64(Gamma_stack, bvadd64(R31_3, 8bv64), Gamma_R0_2); - R9_2, Gamma_R9_2 := memory_load64_le(stack, bvadd64(R31_3, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 8bv64)); + assume {:captureState "l0000030d"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000313"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 1bv32), gamma_store32(Gamma_mem, R9_2, true); - R0_3, Gamma_R0_3 := memory_load64_le(stack, bvadd64(R31_3, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 8bv64)); - call R0_4, Gamma_R0_4, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_2, Gamma_R1_2, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, R30_5, Gamma_R30_5, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_3, Gamma_R8_3, R9_3, Gamma_R9_3 := #free(R0_3, Gamma_R0_3, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, 2048bv64, true, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, 1bv64, true, R9_2, Gamma_R9_2); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000327"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R30, Gamma_R30 := 2048bv64, true; + call #free(); goto l00000338; l00000338: - R29_5, Gamma_R29_5 := memory_load64_le(stack, bvadd64(R31_4, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 16bv64)); - R30_6, Gamma_R30_6 := memory_load64_le(stack, bvadd64(R31_4, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 24bv64)); + assume {:captureState "l00000338"} true; + #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#5, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out, R9_out := R0_4, R29_5, R30_6, bvadd64(R31_4, 32bv64), R8_3, R9_3; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_4, Gamma_R29_5, Gamma_R30_6, Gamma_R31_4, Gamma_R8_3, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); modifies Gamma_R16, Gamma_R17, R16, R17; - free requires (memory_load8_le(mem, 2080bv64) == 1bv8); - free requires (memory_load8_le(mem, 2081bv64) == 0bv8); - free requires (memory_load8_le(mem, 2082bv64) == 2bv8); - free requires (memory_load8_le(mem, 2083bv64) == 0bv8); + free requires (memory_load32_le(mem, 2080bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 2000bv64); free requires (memory_load64_le(mem, 69072bv64) == 1920bv64); free requires (memory_load64_le(mem, 69592bv64) == 2004bv64); free requires (memory_load64_le(mem, 69688bv64) == 69688bv64); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69592bv64) == 2004bv64); diff --git a/src/test/correct/basicfree/clang/basicfree_gtirb.expected b/src/test/correct/basicfree/clang/basicfree_gtirb.expected index 41eccabb0..53b48009a 100644 --- a/src/test/correct/basicfree/clang/basicfree_gtirb.expected +++ b/src/test/correct/basicfree/clang/basicfree_gtirb.expected @@ -1,68 +1,63 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2080bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69592bv64) == 2004bv64); @@ -70,8 +65,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -84,410 +79,139 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_650(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2080bv64) == 1bv8); - free requires (memory_load8_le(mem, 2081bv64) == 0bv8); - free requires (memory_load8_le(mem, 2082bv64) == 2bv8); - free requires (memory_load8_le(mem, 2083bv64) == 0bv8); +procedure FUN_650(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; + free requires (memory_load32_le(mem, 2080bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 2000bv64); free requires (memory_load64_le(mem, 69072bv64) == 1920bv64); free requires (memory_load64_le(mem, 69592bv64) == 2004bv64); free requires (memory_load64_le(mem, 69688bv64) == 69688bv64); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69592bv64) == 2004bv64); free ensures (memory_load64_le(mem, 69688bv64) == 69688bv64); -implementation FUN_650(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_650() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_650$__0__$sjc2rj6TThubVCNZDv8wdw: + assume {:captureState "$FUN_650$__0__$sjc2rj6TThubVCNZDv8wdw"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69648bv64), (gamma_load64(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69648bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 16bv64)) || L(mem, bvadd64(R16, 16bv64))); + R16, Gamma_R16 := bvadd64(R16, 16bv64), Gamma_R16; + call malloc(); assume false; } -procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2080bv64) == 1bv8); - free requires (memory_load8_le(mem, 2081bv64) == 0bv8); - free requires (memory_load8_le(mem, 2082bv64) == 2bv8); - free requires (memory_load8_le(mem, 2083bv64) == 0bv8); +procedure FUN_680(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; + free requires (memory_load32_le(mem, 2080bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 2000bv64); free requires (memory_load64_le(mem, 69072bv64) == 1920bv64); free requires (memory_load64_le(mem, 69592bv64) == 2004bv64); free requires (memory_load64_le(mem, 69688bv64) == 69688bv64); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69592bv64) == 2004bv64); free ensures (memory_load64_le(mem, 69688bv64) == 69688bv64); -implementation FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_680() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_680$__0__$cp70h48_Qy2QShRHYpYqzw: + assume {:captureState "$FUN_680$__0__$cp70h48_Qy2QShRHYpYqzw"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69672bv64), (gamma_load64(Gamma_mem, 69672bv64) || L(mem, 69672bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := #free(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69672bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 40bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 40bv64)) || L(mem, bvadd64(R16, 40bv64))); + R16, Gamma_R16 := bvadd64(R16, 40bv64), Gamma_R16; + call #free(); assume false; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69680bv64) == 0bv64); free requires (memory_load64_le(mem, 69688bv64) == 69688bv64); - free requires (memory_load8_le(mem, 2080bv64) == 1bv8); - free requires (memory_load8_le(mem, 2081bv64) == 0bv8); - free requires (memory_load8_le(mem, 2082bv64) == 2bv8); - free requires (memory_load8_le(mem, 2083bv64) == 0bv8); + free requires (memory_load32_le(mem, 2080bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 2000bv64); free requires (memory_load64_le(mem, 69072bv64) == 1920bv64); free requires (memory_load64_le(mem, 69592bv64) == 2004bv64); free requires (memory_load64_le(mem, 69688bv64) == 69688bv64); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69592bv64) == 2004bv64); free ensures (memory_load64_le(mem, 69688bv64) == 69688bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_4: bool; - var Gamma_R9_1: bool; - var R0_2: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R29_3: bv64; - var R30_4: bv64; - var R9_1: bv64; + var Cse0__5$0$1: bv64; + var Cse0__5$1$0: bv64; + var Gamma_Cse0__5$0$1: bool; + var Gamma_Cse0__5$1$0: bool; $main$__0__$AaLXFLvRTeKg3QkcY_Eoyw: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_650(R16, Gamma_R16); + assume {:captureState "$main$__0__$AaLXFLvRTeKg3QkcY_Eoyw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + Cse0__5$0$1, Gamma_Cse0__5$0$1 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$1, R29), gamma_store64(Gamma_stack, Cse0__5$0$1, Gamma_R29); + assume {:captureState "2008$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$1, 8bv64), Gamma_R30); + assume {:captureState "2008$2"} true; + R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2024bv64, true; + call FUN_650(); goto $main$__1__$sf~3otWHTPClXjl5_L1xPQ; $main$__1__$sf~3otWHTPClXjl5_L1xPQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), true); - R9_1, Gamma_R9_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "$main$__1__$sf~3otWHTPClXjl5_L1xPQ"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "2024$0"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_1) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_1, 1bv32), gamma_store32(Gamma_mem, R9_1, true); - R0_2, Gamma_R0_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := FUN_680(R16_1, Gamma_R16_1); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "2036$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R30, Gamma_R30 := 2048bv64, true; + call FUN_680(); goto $main$__2__$GmXGrcwFTMKJEOfTLmGTjg; $main$__2__$GmXGrcwFTMKJEOfTLmGTjg: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_4, Gamma_R30_4 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__2__$GmXGrcwFTMKJEOfTLmGTjg"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd64(R31, 16bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$1$0), gamma_load64(Gamma_stack, Cse0__5$1$0); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$1$0, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$1$0, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R29_out, R30_out, R31_out, R8_out, R9_out := R0_2, R16_2, R17_2, R29_3, R30_4, R31_in, 1bv64, R9_1; - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_2, Gamma_R16_2, Gamma_R17_2, Gamma_R29_3, Gamma_R30_4, Gamma_R31_in, true, Gamma_R9_1; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - free requires (memory_load8_le(mem, 2080bv64) == 1bv8); - free requires (memory_load8_le(mem, 2081bv64) == 0bv8); - free requires (memory_load8_le(mem, 2082bv64) == 2bv8); - free requires (memory_load8_le(mem, 2083bv64) == 0bv8); +procedure malloc(); + free requires (memory_load32_le(mem, 2080bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 2000bv64); free requires (memory_load64_le(mem, 69072bv64) == 1920bv64); free requires (memory_load64_le(mem, 69592bv64) == 2004bv64); free requires (memory_load64_le(mem, 69688bv64) == 69688bv64); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69592bv64) == 2004bv64); free ensures (memory_load64_le(mem, 69688bv64) == 69688bv64); -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - free requires (memory_load8_le(mem, 2080bv64) == 1bv8); - free requires (memory_load8_le(mem, 2081bv64) == 0bv8); - free requires (memory_load8_le(mem, 2082bv64) == 2bv8); - free requires (memory_load8_le(mem, 2083bv64) == 0bv8); +procedure #free(); + free requires (memory_load32_le(mem, 2080bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 2000bv64); free requires (memory_load64_le(mem, 69072bv64) == 1920bv64); free requires (memory_load64_le(mem, 69592bv64) == 2004bv64); free requires (memory_load64_le(mem, 69688bv64) == 69688bv64); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69592bv64) == 2004bv64); diff --git a/src/test/correct/basicfree/gcc/basicfree.expected b/src/test/correct/basicfree/gcc/basicfree.expected index fda5c7b80..bf81fd5ac 100644 --- a/src/test/correct/basicfree/gcc/basicfree.expected +++ b/src/test/correct/basicfree/gcc/basicfree.expected @@ -1,72 +1,61 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2076bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2076bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2077bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2078bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2079bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2076bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69000bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69616bv64) == 2004bv64); @@ -74,8 +63,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -88,278 +77,88 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); modifies Gamma_R16, Gamma_R17, R16, R17; - free requires (memory_load8_le(mem, 2076bv64) == 1bv8); - free requires (memory_load8_le(mem, 2077bv64) == 0bv8); - free requires (memory_load8_le(mem, 2078bv64) == 2bv8); - free requires (memory_load8_le(mem, 2079bv64) == 0bv8); + free requires (memory_load32_le(mem, 2076bv64) == 131073bv32); free requires (memory_load64_le(mem, 69000bv64) == 2000bv64); free requires (memory_load64_le(mem, 69008bv64) == 1920bv64); free requires (memory_load64_le(mem, 69616bv64) == 2004bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2076bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2077bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2078bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2079bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2076bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69000bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69616bv64) == 2004bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 2076bv64) == 1bv8); - free requires (memory_load8_le(mem, 2077bv64) == 0bv8); - free requires (memory_load8_le(mem, 2078bv64) == 2bv8); - free requires (memory_load8_le(mem, 2079bv64) == 0bv8); + free requires (memory_load32_le(mem, 2076bv64) == 131073bv32); free requires (memory_load64_le(mem, 69000bv64) == 2000bv64); free requires (memory_load64_le(mem, 69008bv64) == 1920bv64); free requires (memory_load64_le(mem, 69616bv64) == 2004bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2076bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2077bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2078bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2079bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2076bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69000bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69616bv64) == 2004bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R10_2: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R11_2: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R12_2: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R13_2: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R14_2: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R15_2: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R18_2: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R19_2: bool; - var Gamma_R1_1: bool; - var Gamma_R1_3: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R20_2: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R21_2: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R22_2: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R23_2: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R24_2: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R25_2: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R26_2: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R27_2: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R28_2: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R29_5: bool; - var Gamma_R2_1: bool; - var Gamma_R2_2: bool; - var Gamma_R3: bool; - var Gamma_R30_3: bool; - var Gamma_R30_5: bool; - var Gamma_R30_6: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R3_1: bool; - var Gamma_R3_2: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R4_2: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R5_2: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R6_2: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R7_2: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var R0_2: bv64; - var R0_3: bv64; - var R0_4: bv64; - var R0_5: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R10_2: bv64; - var R11: bv64; - var R11_1: bv64; - var R11_2: bv64; - var R12: bv64; - var R12_1: bv64; - var R12_2: bv64; - var R13: bv64; - var R13_1: bv64; - var R13_2: bv64; - var R14: bv64; - var R14_1: bv64; - var R14_2: bv64; - var R15: bv64; - var R15_1: bv64; - var R15_2: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R17: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R18_2: bv64; - var R19: bv64; - var R19_1: bv64; - var R19_2: bv64; - var R1_1: bv64; - var R1_3: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R20_2: bv64; - var R21: bv64; - var R21_1: bv64; - var R21_2: bv64; - var R22: bv64; - var R22_1: bv64; - var R22_2: bv64; - var R23: bv64; - var R23_1: bv64; - var R23_2: bv64; - var R24: bv64; - var R24_1: bv64; - var R24_2: bv64; - var R25: bv64; - var R25_1: bv64; - var R25_2: bv64; - var R26: bv64; - var R26_1: bv64; - var R26_2: bv64; - var R27: bv64; - var R27_1: bv64; - var R27_2: bv64; - var R28: bv64; - var R28_1: bv64; - var R28_2: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R29_5: bv64; - var R2_1: bv64; - var R2_2: bv64; - var R3: bv64; - var R30_3: bv64; - var R30_5: bv64; - var R30_6: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R3_1: bv64; - var R3_2: bv64; - var R4: bv64; - var R4_1: bv64; - var R4_2: bv64; - var R5: bv64; - var R5_1: bv64; - var R5_2: bv64; - var R6: bv64; - var R6_1: bv64; - var R6_2: bv64; - var R7: bv64; - var R7_1: bv64; - var R7_2: bv64; - var R8: bv64; - var R8_1: bv64; - var R8_2: bv64; - var R9: bv64; - var R9_1: bv64; - var R9_2: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(4bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in, R2, Gamma_R2, 2020bv64, true, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002e8"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002ee"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2020bv64, true; + call malloc(); goto l00000307; l00000307: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_3, 24bv64), R0_2), gamma_store64(Gamma_stack, bvadd64(R31_3, 24bv64), Gamma_R0_2); - R0_3, Gamma_R0_3 := memory_load64_le(stack, bvadd64(R31_3, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 24bv64)); + assume {:captureState "l00000307"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%0000030d"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); - R0_4, Gamma_R0_4 := memory_load64_le(stack, bvadd64(R31_3, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 24bv64)); - call R0_5, Gamma_R0_5, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_3, Gamma_R1_3, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, R30_5, Gamma_R30_5, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2 := #free(R0_4, Gamma_R0_4, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, 1bv64, true, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, 2044bv64, true, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000321"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + R30, Gamma_R30 := 2044bv64, true; + call #free(); goto l00000332; l00000332: - R29_5, Gamma_R29_5 := memory_load64_le(stack, R31_4), gamma_load64(Gamma_stack, R31_4); - R30_6, Gamma_R30_6 := memory_load64_le(stack, bvadd64(R31_4, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 8bv64)); + assume {:captureState "l00000332"} true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := R0_5, R1_3, R29_5, R30_6, bvadd64(R31_4, 32bv64); - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := Gamma_R0_5, Gamma_R1_3, Gamma_R29_5, Gamma_R30_6, Gamma_R31_4; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); modifies Gamma_R16, Gamma_R17, R16, R17; - free requires (memory_load8_le(mem, 2076bv64) == 1bv8); - free requires (memory_load8_le(mem, 2077bv64) == 0bv8); - free requires (memory_load8_le(mem, 2078bv64) == 2bv8); - free requires (memory_load8_le(mem, 2079bv64) == 0bv8); + free requires (memory_load32_le(mem, 2076bv64) == 131073bv32); free requires (memory_load64_le(mem, 69000bv64) == 2000bv64); free requires (memory_load64_le(mem, 69008bv64) == 1920bv64); free requires (memory_load64_le(mem, 69616bv64) == 2004bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2076bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2077bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2078bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2079bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2076bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69000bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69616bv64) == 2004bv64); diff --git a/src/test/correct/basicfree/gcc/basicfree_gtirb.expected b/src/test/correct/basicfree/gcc/basicfree_gtirb.expected index 0059a2b19..e9dfa741d 100644 --- a/src/test/correct/basicfree/gcc/basicfree_gtirb.expected +++ b/src/test/correct/basicfree/gcc/basicfree_gtirb.expected @@ -1,68 +1,61 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2076bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2076bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2077bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2078bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2079bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2076bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69000bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69616bv64) == 2004bv64); @@ -70,8 +63,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -84,410 +77,136 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2076bv64) == 1bv8); - free requires (memory_load8_le(mem, 2077bv64) == 0bv8); - free requires (memory_load8_le(mem, 2078bv64) == 2bv8); - free requires (memory_load8_le(mem, 2079bv64) == 0bv8); +procedure FUN_680(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; + free requires (memory_load32_le(mem, 2076bv64) == 131073bv32); free requires (memory_load64_le(mem, 69000bv64) == 2000bv64); free requires (memory_load64_le(mem, 69008bv64) == 1920bv64); free requires (memory_load64_le(mem, 69616bv64) == 2004bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2076bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2077bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2078bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2079bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2076bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69000bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69616bv64) == 2004bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_680() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_680$__0__$Munhgh3nShysDJa~x_gpnQ: + assume {:captureState "$FUN_680$__0__$Munhgh3nShysDJa~x_gpnQ"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := #free(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69576bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4040bv64)) || L(mem, bvadd64(R16, 4040bv64))); + R16, Gamma_R16 := bvadd64(R16, 4040bv64), Gamma_R16; + call #free(); assume false; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 2076bv64) == 1bv8); - free requires (memory_load8_le(mem, 2077bv64) == 0bv8); - free requires (memory_load8_le(mem, 2078bv64) == 2bv8); - free requires (memory_load8_le(mem, 2079bv64) == 0bv8); + free requires (memory_load32_le(mem, 2076bv64) == 131073bv32); free requires (memory_load64_le(mem, 69000bv64) == 2000bv64); free requires (memory_load64_le(mem, 69008bv64) == 1920bv64); free requires (memory_load64_le(mem, 69616bv64) == 2004bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2076bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2077bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2078bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2079bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2076bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69000bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69616bv64) == 2004bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_4: bool; - var R0_2: bv64; - var R0_3: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R29_3: bv64; - var R30_4: bv64; + var Cse0__5$1$0: bv64; + var Gamma_Cse0__5$1$0: bool; $main$__0__$SVwwAKxIQmqlA4JVB4NRNA: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_650(R16, Gamma_R16); + assume {:captureState "$main$__0__$SVwwAKxIQmqlA4JVB4NRNA"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$0, R29), gamma_store64(Gamma_stack, Cse0__5$1$0, Gamma_R29); + assume {:captureState "2004$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$0, 8bv64), Gamma_R30); + assume {:captureState "2004$2"} true; + R31, Gamma_R31 := Cse0__5$1$0, Gamma_Cse0__5$1$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2020bv64, true; + call FUN_650(); goto $main$__1__$9qt6Bm68Rve4QS0F_cEB3w; $main$__1__$9qt6Bm68Rve4QS0F_cEB3w: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R0_2, Gamma_R0_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__1__$9qt6Bm68Rve4QS0F_cEB3w"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "2020$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_2, 1bv32), gamma_store32(Gamma_mem, R0_2, true); - R0_3, Gamma_R0_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := FUN_680(R16_1, Gamma_R16_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2032$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + R30, Gamma_R30 := 2044bv64, true; + call FUN_680(); goto $main$__2__$JmJ8ydmEQ0KG2aqp3uFiQw; $main$__2__$JmJ8ydmEQ0KG2aqp3uFiQw: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - R30_4, Gamma_R30_4 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "$main$__2__$JmJ8ydmEQ0KG2aqp3uFiQw"} true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R1_out, R29_out, R30_out, R31_out := R0_3, R16_2, R17_2, 1bv64, R29_3, R30_4, R31_in; - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := Gamma_R0_3, Gamma_R16_2, Gamma_R17_2, true, Gamma_R29_3, Gamma_R30_4, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } -procedure FUN_650(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2076bv64) == 1bv8); - free requires (memory_load8_le(mem, 2077bv64) == 0bv8); - free requires (memory_load8_le(mem, 2078bv64) == 2bv8); - free requires (memory_load8_le(mem, 2079bv64) == 0bv8); +procedure FUN_650(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; + free requires (memory_load32_le(mem, 2076bv64) == 131073bv32); free requires (memory_load64_le(mem, 69000bv64) == 2000bv64); free requires (memory_load64_le(mem, 69008bv64) == 1920bv64); free requires (memory_load64_le(mem, 69616bv64) == 2004bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2076bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2077bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2078bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2079bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2076bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69000bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69616bv64) == 2004bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_650(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_650() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_650$__0__$6QXyVlMjT_e0YItUboXIPw: + assume {:captureState "$FUN_650$__0__$6QXyVlMjT_e0YItUboXIPw"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69552bv64), (gamma_load64(Gamma_mem, 69552bv64) || L(mem, 69552bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69552bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4016bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4016bv64)) || L(mem, bvadd64(R16, 4016bv64))); + R16, Gamma_R16 := bvadd64(R16, 4016bv64), Gamma_R16; + call malloc(); assume false; } -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - free requires (memory_load8_le(mem, 2076bv64) == 1bv8); - free requires (memory_load8_le(mem, 2077bv64) == 0bv8); - free requires (memory_load8_le(mem, 2078bv64) == 2bv8); - free requires (memory_load8_le(mem, 2079bv64) == 0bv8); +procedure #free(); + free requires (memory_load32_le(mem, 2076bv64) == 131073bv32); free requires (memory_load64_le(mem, 69000bv64) == 2000bv64); free requires (memory_load64_le(mem, 69008bv64) == 1920bv64); free requires (memory_load64_le(mem, 69616bv64) == 2004bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2076bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2077bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2078bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2079bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2076bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69000bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69616bv64) == 2004bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - free requires (memory_load8_le(mem, 2076bv64) == 1bv8); - free requires (memory_load8_le(mem, 2077bv64) == 0bv8); - free requires (memory_load8_le(mem, 2078bv64) == 2bv8); - free requires (memory_load8_le(mem, 2079bv64) == 0bv8); +procedure malloc(); + free requires (memory_load32_le(mem, 2076bv64) == 131073bv32); free requires (memory_load64_le(mem, 69000bv64) == 2000bv64); free requires (memory_load64_le(mem, 69008bv64) == 1920bv64); free requires (memory_load64_le(mem, 69616bv64) == 2004bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2076bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2077bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2078bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2079bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2076bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69000bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1920bv64); free ensures (memory_load64_le(mem, 69616bv64) == 2004bv64); diff --git a/src/test/correct/cjump/clang/cjump.expected b/src/test/correct/cjump/clang/cjump.expected index d8152a685..e74e0ba9c 100644 --- a/src/test/correct/cjump/clang/cjump.expected +++ b/src/test/correct/cjump/clang/cjump.expected @@ -1,35 +1,44 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +49,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -64,8 +68,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -78,79 +82,106 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, R9, VF, ZF, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1916bv64) == 1bv8); - free requires (memory_load8_le(mem, 1917bv64) == 0bv8); - free requires (memory_load8_le(mem, 1918bv64) == 2bv8); - free requires (memory_load8_le(mem, 1919bv64) == 0bv8); + free requires (memory_load32_le(mem, 1916bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_2: bool; - var Gamma_R8_7: bool; - var R0_1: bv64; - var R8_11: bv64; - var R8_2: bv32; - var R8_7: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000309"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); + assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assume {:captureState "%0000031b"} true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000343, lmain_goto_l00000346; - lmain_goto_l00000346: - assume (R8_2 == 0bv32); - R8_7, Gamma_R8_7 := 1bv64, true; + l00000346: + assume {:captureState "l00000346"} true; + R8, Gamma_R8 := 1bv64, true; goto l00000349; - lmain_goto_l00000343: - assume (!(R8_2 == 0bv32)); - R8_7, Gamma_R8_7 := 0bv64, true; + l00000343: + assume {:captureState "l00000343"} true; + R8, Gamma_R8 := 0bv64, true; goto l00000349; l00000349: - assert Gamma_R8_7; + assume {:captureState "l00000349"} true; + assert Gamma_R8; goto l00000349_goto_l00000351, l00000349_goto_l0000037e; - l00000349_goto_l0000037e: - assume (!(R8_7[1:0] == 1bv1)); + l00000351: + assume {:captureState "l00000351"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 2bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 3bv32), gamma_store32(Gamma_mem, 69688bv64, true); - R8_11, Gamma_R8_11 := 3bv64, true; + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%00000366"} true; goto l00000369; - l00000349_goto_l00000351: - assume (R8_7[1:0] == 1bv1); + l0000037e: + assume {:captureState "l0000037e"} true; + goto l0000037f; + l0000037f: + assume {:captureState "l0000037f"} true; + R8, Gamma_R8 := 3bv64, true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 2bv32), gamma_store32(Gamma_mem, 69688bv64, true); - R8_11, Gamma_R8_11 := 2bv64, true; + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%00000392"} true; goto l00000369; l00000369: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l00000369"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000343: + assume {:captureState "lmain_goto_l00000343"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000343; + lmain_goto_l00000346: + assume {:captureState "lmain_goto_l00000346"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000346; + l00000349_goto_l00000351: + assume {:captureState "l00000349_goto_l00000351"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l00000351; + l00000349_goto_l0000037e: + assume {:captureState "l00000349_goto_l0000037e"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l0000037e; main_basil_return: - R0_out, R31_out, R8_out, R9_out := R0_1, R31_in, R8_11, 69632bv64; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_11, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/cjump/clang/cjump_gtirb.expected b/src/test/correct/cjump/clang/cjump_gtirb.expected index 45629f845..db365724f 100644 --- a/src/test/correct/cjump/clang/cjump_gtirb.expected +++ b/src/test/correct/cjump/clang/cjump_gtirb.expected @@ -1,35 +1,43 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +48,17 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -64,8 +66,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -78,92 +80,98 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, R9, VF, ZF, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1916bv64) == 1bv8); - free requires (memory_load8_le(mem, 1917bv64) == 0bv8); - free requires (memory_load8_le(mem, 1918bv64) == 2bv8); - free requires (memory_load8_le(mem, 1919bv64) == 0bv8); + free requires (memory_load32_le(mem, 1916bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_13: bool; - var Gamma_R8_2: bool; - var Gamma_R8_8: bool; - var R0_1: bv64; - var R8_11: bv64; - var R8_13: bv64; - var R8_2: bv32; - var R8_8: bv64; + var Cse0__5$0$6: bv32; + var Gamma_Cse0__5$0$6: bool; $main$__0__$PnDIl5cyR4GGh5gDIaWl6w: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$PnDIl5cyR4GGh5gDIaWl6w"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1816$0"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); + assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assume {:captureState "1828$0"} true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + Cse0__5$0$6, Gamma_Cse0__5$0$6 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$6, Cse0__5$0$6)), Gamma_Cse0__5$0$6; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$6), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$0$6); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$6, 0bv32), Gamma_Cse0__5$0$6; + NF, Gamma_NF := Cse0__5$0$6[32:31], Gamma_Cse0__5$0$6; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$0$6), Gamma_Cse0__5$0$6; + assert Gamma_ZF; goto $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__0, $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__1; - $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__1: - assume (R8_2 == 0bv32); - goto $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__1_phi_$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__3__$I4nigOnuRzaYmG2czUcPqQ_phi_back_$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__3__$I4nigOnuRzaYmG2czUcPqQ, $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__1_phi_$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg_phi_back_$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg; - $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__1_phi_$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg_phi_back_$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg: - R8_8, Gamma_R8_8 := 1bv64, true; - assert Gamma_R8_8; - goto $main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg; - $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__1_phi_$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__3__$I4nigOnuRzaYmG2czUcPqQ_phi_back_$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__3__$I4nigOnuRzaYmG2czUcPqQ: - R8_11, Gamma_R8_11 := 1bv64, true; - assert Gamma_R8_11; - goto $main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__3__$I4nigOnuRzaYmG2czUcPqQ; - $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__0: - assume (!(R8_2 == 0bv32)); - goto $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__0_phi_back_$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg, $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__0_phi_back_$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__3__$I4nigOnuRzaYmG2czUcPqQ; - $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__0_phi_back_$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__3__$I4nigOnuRzaYmG2czUcPqQ: - R8_11, Gamma_R8_11 := 0bv64, true; - assert Gamma_R8_11; - goto $main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__3__$I4nigOnuRzaYmG2czUcPqQ; - $main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__3__$I4nigOnuRzaYmG2czUcPqQ: - assume (R8_11[1:0] == 1bv1); + $main$__1__$QUCiZ1czSk63UIuy~Dy6Bg: + assume {:captureState "$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg"} true; + goto $main$__2__$5gUE9BicSVSdDO98Zitx1A; + $main$__2__$5gUE9BicSVSdDO98Zitx1A: + assume {:captureState "$main$__2__$5gUE9BicSVSdDO98Zitx1A"} true; + R8, Gamma_R8 := 3bv64, true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 2bv32), gamma_store32(Gamma_mem, 69688bv64, true); - R8_13, Gamma_R8_13 := 2bv64, true; + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "1860$0"} true; goto $main$__4__$yxwH2dUnQdipf4xbcLk77w; - $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__0_phi_back_$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg: - R8_8, Gamma_R8_8 := 0bv64, true; - assert Gamma_R8_8; - goto $main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg; - $main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg: - assume (!(R8_8[1:0] == 1bv1)); + $main$__3__$I4nigOnuRzaYmG2czUcPqQ: + assume {:captureState "$main$__3__$I4nigOnuRzaYmG2czUcPqQ"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 2bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 3bv32), gamma_store32(Gamma_mem, 69688bv64, true); - R8_13, Gamma_R8_13 := 3bv64, true; + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "1876$0"} true; goto $main$__4__$yxwH2dUnQdipf4xbcLk77w; $main$__4__$yxwH2dUnQdipf4xbcLk77w: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__4__$yxwH2dUnQdipf4xbcLk77w"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__3__$I4nigOnuRzaYmG2czUcPqQ: + assume {:captureState "$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__3__$I4nigOnuRzaYmG2czUcPqQ"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$I4nigOnuRzaYmG2czUcPqQ; + $main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg: + assume {:captureState "$main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$QUCiZ1czSk63UIuy~Dy6Bg; + $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__0: + assume {:captureState "$main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__0"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__3__$I4nigOnuRzaYmG2czUcPqQ, $main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg; + $main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__1: + assume {:captureState "$main$__0__$PnDIl5cyR4GGh5gDIaWl6w$__1"} true; + assume (!(!(ZF == 1bv1))); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__3__$I4nigOnuRzaYmG2czUcPqQ, $main$__0__$PnDIl5cyR4GGh5gDIaWl6w_goto_$main$__1__$QUCiZ1czSk63UIuy~Dy6Bg; main_basil_return: - R0_out, R31_out, R8_out, R9_out := R0_1, R31_in, R8_13, 69632bv64; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_13, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/cjump/clang_pic/cjump.expected b/src/test/correct/cjump/clang_pic/cjump.expected index a903bb07c..b51a7b7e0 100644 --- a/src/test/correct/cjump/clang_pic/cjump.expected +++ b/src/test/correct/cjump/clang_pic/cjump.expected @@ -1,25 +1,38 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +42,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,34 +53,29 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1992bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1993bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1994bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1995bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1992bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -84,99 +88,116 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, R9, VF, ZF, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1992bv64) == 1bv8); - free requires (memory_load8_le(mem, 1993bv64) == 0bv8); - free requires (memory_load8_le(mem, 1994bv64) == 2bv8); - free requires (memory_load8_le(mem, 1995bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load32_le(mem, 1992bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1992bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1993bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1994bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1995bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1992bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_12: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_8: bool; - var Gamma_R9_3: bool; - var Gamma_R9_6: bool; - var Gamma_R9_7: bool; - var R0_1: bv64; - var R8_12: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_8: bv64; - var R9_3: bv64; - var R9_6: bv64; - var R9_7: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000315"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); + R9, Gamma_R9 := 1bv64, true; call rely(); - assert (L(mem, R8_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R8_2, 1bv32), gamma_store32(Gamma_mem, R8_2, true); + assert (L(mem, R8) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, R8, R9[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R9); + assume {:captureState "%0000032e"} true; call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000356, lmain_goto_l00000359; - lmain_goto_l00000359: - assume (R8_3 == 0bv32); - R8_8, Gamma_R8_8 := 1bv64, true; + l00000359: + assume {:captureState "l00000359"} true; + R8, Gamma_R8 := 1bv64, true; goto l0000035c; - lmain_goto_l00000356: - assume (!(R8_3 == 0bv32)); - R8_8, Gamma_R8_8 := 0bv64, true; + l00000356: + assume {:captureState "l00000356"} true; + R8, Gamma_R8 := 0bv64, true; goto l0000035c; l0000035c: - assert Gamma_R8_8; + assume {:captureState "l0000035c"} true; + assert Gamma_R8; goto l0000035c_goto_l00000364, l0000035c_goto_l00000398; - l0000035c_goto_l00000398: - assume (!(R8_8[1:0] == 1bv1)); + l00000364: + assume {:captureState "l00000364"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4048bv64)) || L(mem, bvadd64(R9, 4048bv64))); + R8, Gamma_R8 := 2bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 3bv32), gamma_store32(Gamma_mem, R9_3, true); - R9_7, Gamma_R9_7 := R9_3, Gamma_R9_3; - R8_12, Gamma_R8_12 := 3bv64, true; + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000380"} true; goto l00000383; - l0000035c_goto_l00000364: - assume (R8_8[1:0] == 1bv1); + l00000398: + assume {:captureState "l00000398"} true; + goto l00000399; + l00000399: + assume {:captureState "l00000399"} true; + R8, Gamma_R8 := 3bv64, true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_6, Gamma_R9_6 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4048bv64)) || L(mem, bvadd64(R9, 4048bv64))); call rely(); - assert (L(mem, R9_6) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_6, 2bv32), gamma_store32(Gamma_mem, R9_6, true); - R9_7, Gamma_R9_7 := R9_6, Gamma_R9_6; - R8_12, Gamma_R8_12 := 2bv64, true; + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000003b3"} true; goto l00000383; l00000383: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l00000383"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000356: + assume {:captureState "lmain_goto_l00000356"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000356; + lmain_goto_l00000359: + assume {:captureState "lmain_goto_l00000359"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000359; + l0000035c_goto_l00000364: + assume {:captureState "l0000035c_goto_l00000364"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l00000364; + l0000035c_goto_l00000398: + assume {:captureState "l0000035c_goto_l00000398"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000398; main_basil_return: - R0_out, R31_out, R8_out, R9_out := R0_1, R31_in, R8_12, R9_7; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_12, Gamma_R9_7; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/cjump/clang_pic/cjump_gtirb.expected b/src/test/correct/cjump/clang_pic/cjump_gtirb.expected index 444b2dd54..9d0935d98 100644 --- a/src/test/correct/cjump/clang_pic/cjump_gtirb.expected +++ b/src/test/correct/cjump/clang_pic/cjump_gtirb.expected @@ -1,25 +1,37 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +41,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,34 +52,28 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1992bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1993bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1994bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1995bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1992bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -84,112 +86,108 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, R9, VF, ZF, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == false); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1992bv64) == 1bv8); - free requires (memory_load8_le(mem, 1993bv64) == 0bv8); - free requires (memory_load8_le(mem, 1994bv64) == 2bv8); - free requires (memory_load8_le(mem, 1995bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load32_le(mem, 1992bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1992bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1993bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1994bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1995bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1992bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_12: bool; - var Gamma_R8_14: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_9: bool; - var Gamma_R9_3: bool; - var Gamma_R9_6: bool; - var Gamma_R9_7: bool; - var R0_1: bv64; - var R8_12: bv64; - var R8_14: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_9: bv64; - var R9_3: bv64; - var R9_6: bv64; - var R9_7: bv64; + var Cse0__5$4$7: bv32; + var Gamma_Cse0__5$4$7: bool; $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1880$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); + R9, Gamma_R9 := 1bv64, true; call rely(); - assert (L(mem, R8_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R8_2, 1bv32), gamma_store32(Gamma_mem, R8_2, true); + assert (L(mem, R8) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, R8, R9[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R9); + assume {:captureState "1896$0"} true; call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + Cse0__5$4$7, Gamma_Cse0__5$4$7 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$4$7, Cse0__5$4$7)), Gamma_Cse0__5$4$7; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$4$7), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$4$7); + ZF, Gamma_ZF := bvcomp32(Cse0__5$4$7, 0bv32), Gamma_Cse0__5$4$7; + NF, Gamma_NF := Cse0__5$4$7[32:31], Gamma_Cse0__5$4$7; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$4$7), Gamma_Cse0__5$4$7; + assert Gamma_ZF; goto $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__0, $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__1; - $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__1: - assume (R8_3 == 0bv32); - goto $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__1_phi_$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__3__$lxnj6lMASh2SOnwbX1sHQw_phi_back_$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__3__$lxnj6lMASh2SOnwbX1sHQw, $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__1_phi_$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__1__$5SdYH~vURDuHuVGzlLv_ow_phi_back_$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__1__$5SdYH~vURDuHuVGzlLv_ow; - $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__1_phi_$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__1__$5SdYH~vURDuHuVGzlLv_ow_phi_back_$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__1__$5SdYH~vURDuHuVGzlLv_ow: - R8_9, Gamma_R8_9 := 1bv64, true; - assert Gamma_R8_9; - goto $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__1__$5SdYH~vURDuHuVGzlLv_ow; - $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__1_phi_$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__3__$lxnj6lMASh2SOnwbX1sHQw_phi_back_$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__3__$lxnj6lMASh2SOnwbX1sHQw: - R8_12, Gamma_R8_12 := 1bv64, true; - assert Gamma_R8_12; - goto $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__3__$lxnj6lMASh2SOnwbX1sHQw; - $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__0: - assume (!(R8_3 == 0bv32)); - goto $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__0_phi_back_$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__1__$5SdYH~vURDuHuVGzlLv_ow, $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__0_phi_back_$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__3__$lxnj6lMASh2SOnwbX1sHQw; - $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__0_phi_back_$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__3__$lxnj6lMASh2SOnwbX1sHQw: - R8_12, Gamma_R8_12 := 0bv64, true; - assert Gamma_R8_12; - goto $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__3__$lxnj6lMASh2SOnwbX1sHQw; - $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__3__$lxnj6lMASh2SOnwbX1sHQw: - assume (R8_12[1:0] == 1bv1); + $main$__1__$5SdYH~vURDuHuVGzlLv_ow: + assume {:captureState "$main$__1__$5SdYH~vURDuHuVGzlLv_ow"} true; + goto $main$__2__$mQXc6EwUQvuLoeh2D_PNVA; + $main$__2__$mQXc6EwUQvuLoeh2D_PNVA: + assume {:captureState "$main$__2__$mQXc6EwUQvuLoeh2D_PNVA"} true; + R8, Gamma_R8 := 3bv64, true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_6, Gamma_R9_6 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4048bv64)) || L(mem, bvadd64(R9, 4048bv64))); call rely(); - assert (L(mem, R9_6) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_6, 2bv32), gamma_store32(Gamma_mem, R9_6, true); - R9_7, Gamma_R9_7 := R9_6, Gamma_R9_6; - R8_14, Gamma_R8_14 := 2bv64, true; + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1932$0"} true; goto $main$__4__$7LOsLwE1R4Kli011Bz8Pqw; - $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__0_phi_back_$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__1__$5SdYH~vURDuHuVGzlLv_ow: - R8_9, Gamma_R8_9 := 0bv64, true; - assert Gamma_R8_9; - goto $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__1__$5SdYH~vURDuHuVGzlLv_ow; - $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__1__$5SdYH~vURDuHuVGzlLv_ow: - assume (!(R8_9[1:0] == 1bv1)); + $main$__3__$lxnj6lMASh2SOnwbX1sHQw: + assume {:captureState "$main$__3__$lxnj6lMASh2SOnwbX1sHQw"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4048bv64)) || L(mem, bvadd64(R9, 4048bv64))); + R8, Gamma_R8 := 2bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 3bv32), gamma_store32(Gamma_mem, R9_3, true); - R9_7, Gamma_R9_7 := R9_3, Gamma_R9_3; - R8_14, Gamma_R8_14 := 3bv64, true; + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1952$0"} true; goto $main$__4__$7LOsLwE1R4Kli011Bz8Pqw; $main$__4__$7LOsLwE1R4Kli011Bz8Pqw: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__4__$7LOsLwE1R4Kli011Bz8Pqw"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__3__$lxnj6lMASh2SOnwbX1sHQw: + assume {:captureState "$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__3__$lxnj6lMASh2SOnwbX1sHQw"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$lxnj6lMASh2SOnwbX1sHQw; + $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__1__$5SdYH~vURDuHuVGzlLv_ow: + assume {:captureState "$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__1__$5SdYH~vURDuHuVGzlLv_ow"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$5SdYH~vURDuHuVGzlLv_ow; + $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__0: + assume {:captureState "$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__0"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__3__$lxnj6lMASh2SOnwbX1sHQw, $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__1__$5SdYH~vURDuHuVGzlLv_ow; + $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__1: + assume {:captureState "$main$__0__$ryTsqXUlQyOWNh8Q~a~WOg$__1"} true; + assume (!(!(ZF == 1bv1))); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__3__$lxnj6lMASh2SOnwbX1sHQw, $main$__0__$ryTsqXUlQyOWNh8Q~a~WOg_goto_$main$__1__$5SdYH~vURDuHuVGzlLv_ow; main_basil_return: - R0_out, R31_out, R8_out, R9_out := R0_1, R31_in, R8_14, R9_7; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_14, Gamma_R9_7; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/cjump/gcc/cjump.expected b/src/test/correct/cjump/gcc/cjump.expected index ab5386692..136b5251d 100644 --- a/src/test/correct/cjump/gcc/cjump.expected +++ b/src/test/correct/cjump/gcc/cjump.expected @@ -1,33 +1,38 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,22 +43,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -61,8 +62,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -75,62 +76,81 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R1, VF, ZF, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1912bv64) == 1bv8); - free requires (memory_load8_le(mem, 1913bv64) == 0bv8); - free requires (memory_load8_le(mem, 1914bv64) == 2bv8); - free requires (memory_load8_le(mem, 1915bv64) == 0bv8); + free requires (memory_load32_le(mem, 1912bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_6: bool; - var Gamma_R1_6: bool; - var R0_6: bv32; - var R1_6: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000310"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l0000033e, lmain_goto_l00000365; - lmain_goto_l00000365: - assume (!(R0_6 == 0bv32)); + l0000033e: + assume {:captureState "l0000033e"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 2bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 3bv32), gamma_store32(Gamma_mem, 69656bv64, true); - R1_6, Gamma_R1_6 := 3bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000359"} true; goto l0000035b; - lmain_goto_l0000033e: - assume (R0_6 == 0bv32); + l00000365: + assume {:captureState "l00000365"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 3bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 2bv32), gamma_store32(Gamma_mem, 69656bv64, true); - R1_6, Gamma_R1_6 := 2bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000037b"} true; goto l0000035b; l0000035b: + assume {:captureState "l0000035b"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + lmain_goto_l0000033e: + assume {:captureState "lmain_goto_l0000033e"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l0000033e; + lmain_goto_l00000365: + assume {:captureState "lmain_goto_l00000365"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l00000365; main_basil_return: - R0_out, R1_out := 0bv64, R1_6; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_6; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/cjump/gcc/cjump_gtirb.expected b/src/test/correct/cjump/gcc/cjump_gtirb.expected index d0fbd5a10..35ffd3da4 100644 --- a/src/test/correct/cjump/gcc/cjump_gtirb.expected +++ b/src/test/correct/cjump/gcc/cjump_gtirb.expected @@ -1,33 +1,37 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,22 +42,17 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -61,8 +60,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -75,62 +74,81 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R1, VF, ZF, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1912bv64) == 1bv8); - free requires (memory_load8_le(mem, 1913bv64) == 0bv8); - free requires (memory_load8_le(mem, 1914bv64) == 2bv8); - free requires (memory_load8_le(mem, 1915bv64) == 0bv8); + free requires (memory_load32_le(mem, 1912bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_6: bool; - var Gamma_R1_6: bool; - var R0_6: bv32; - var R1_6: bv64; + var Cse0__5$3$7: bv32; + var Gamma_Cse0__5$3$7: bool; $main$__0__$YwDxm6NpRSaYnJwZf~bgAg: + assume {:captureState "$main$__0__$YwDxm6NpRSaYnJwZf~bgAg"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$3$7, Gamma_Cse0__5$3$7 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$3$7, Cse0__5$3$7)), Gamma_Cse0__5$3$7; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$7), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$3$7); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$7, 0bv32), Gamma_Cse0__5$3$7; + NF, Gamma_NF := Cse0__5$3$7[32:31], Gamma_Cse0__5$3$7; + assert Gamma_ZF; goto $main$__0__$YwDxm6NpRSaYnJwZf~bgAg_goto_$main$__2__$WXfzVKBzTQ2pcN9SDnwGAQ, $main$__0__$YwDxm6NpRSaYnJwZf~bgAg_goto_$main$__1__$YoxtYzmmTLarbLScWy3SCQ; - $main$__0__$YwDxm6NpRSaYnJwZf~bgAg_goto_$main$__1__$YoxtYzmmTLarbLScWy3SCQ: - assume (!(R0_6 == 0bv32)); + $main$__1__$YoxtYzmmTLarbLScWy3SCQ: + assume {:captureState "$main$__1__$YoxtYzmmTLarbLScWy3SCQ"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 3bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 3bv32), gamma_store32(Gamma_mem, 69656bv64, true); - R1_6, Gamma_R1_6 := 3bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1860$0"} true; goto $main$__3__$RpUJmfB5RPyIGv0DK5At_g; - $main$__0__$YwDxm6NpRSaYnJwZf~bgAg_goto_$main$__2__$WXfzVKBzTQ2pcN9SDnwGAQ: - assume (R0_6 == 0bv32); + $main$__2__$WXfzVKBzTQ2pcN9SDnwGAQ: + assume {:captureState "$main$__2__$WXfzVKBzTQ2pcN9SDnwGAQ"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 2bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 2bv32), gamma_store32(Gamma_mem, 69656bv64, true); - R1_6, Gamma_R1_6 := 2bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1880$0"} true; goto $main$__3__$RpUJmfB5RPyIGv0DK5At_g; $main$__3__$RpUJmfB5RPyIGv0DK5At_g: + assume {:captureState "$main$__3__$RpUJmfB5RPyIGv0DK5At_g"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + $main$__0__$YwDxm6NpRSaYnJwZf~bgAg_goto_$main$__2__$WXfzVKBzTQ2pcN9SDnwGAQ: + assume {:captureState "$main$__0__$YwDxm6NpRSaYnJwZf~bgAg_goto_$main$__2__$WXfzVKBzTQ2pcN9SDnwGAQ"} true; + assume (ZF == 1bv1); + goto $main$__2__$WXfzVKBzTQ2pcN9SDnwGAQ; + $main$__0__$YwDxm6NpRSaYnJwZf~bgAg_goto_$main$__1__$YoxtYzmmTLarbLScWy3SCQ: + assume {:captureState "$main$__0__$YwDxm6NpRSaYnJwZf~bgAg_goto_$main$__1__$YoxtYzmmTLarbLScWy3SCQ"} true; + assume (!(ZF == 1bv1)); + goto $main$__1__$YoxtYzmmTLarbLScWy3SCQ; main_basil_return: - R0_out, R1_out := 0bv64, R1_6; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_6; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/cjump/gcc_pic/cjump.expected b/src/test/correct/cjump/gcc_pic/cjump.expected index 43cc714ed..0162d3f40 100644 --- a/src/test/correct/cjump/gcc_pic/cjump.expected +++ b/src/test/correct/cjump/gcc_pic/cjump.expected @@ -1,23 +1,32 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +36,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,33 +47,29 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1976bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1977bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1978bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1979bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1976bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -81,82 +82,89 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R1, VF, ZF, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1976bv64) == 1bv8); - free requires (memory_load8_le(mem, 1977bv64) == 0bv8); - free requires (memory_load8_le(mem, 1978bv64) == 2bv8); - free requires (memory_load8_le(mem, 1979bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1976bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1976bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1977bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1978bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1979bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1976bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_8: bool; - var Gamma_R1_6: bool; - var R0_10: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_6: bv32; - var R0_8: bv64; - var R1_6: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000311"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, R0_5), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000340, lmain_goto_l00000368; - lmain_goto_l00000368: - assume (!(R0_6 == 0bv32)); + l00000340: + assume {:captureState "l00000340"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_8, Gamma_R0_8 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); + R1, Gamma_R1 := 2bv64, true; call rely(); - assert (L(mem, R0_8) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_8, 3bv32), gamma_store32(Gamma_mem, R0_8, true); - R1_6, Gamma_R1_6 := 3bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000035c"} true; goto l0000035e; - lmain_goto_l00000340: - assume (R0_6 == 0bv32); + l00000368: + assume {:captureState "l00000368"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_10, Gamma_R0_10 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); + R1, Gamma_R1 := 3bv64, true; call rely(); - assert (L(mem, R0_10) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_10, 2bv32), gamma_store32(Gamma_mem, R0_10, true); - R1_6, Gamma_R1_6 := 2bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000037f"} true; goto l0000035e; l0000035e: + assume {:captureState "l0000035e"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + lmain_goto_l00000340: + assume {:captureState "lmain_goto_l00000340"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l00000340; + lmain_goto_l00000368: + assume {:captureState "lmain_goto_l00000368"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l00000368; main_basil_return: - R0_out, R1_out := 0bv64, R1_6; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_6; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/cjump/gcc_pic/cjump_gtirb.expected b/src/test/correct/cjump/gcc_pic/cjump_gtirb.expected index e49ae6369..0e9fdc0b6 100644 --- a/src/test/correct/cjump/gcc_pic/cjump_gtirb.expected +++ b/src/test/correct/cjump/gcc_pic/cjump_gtirb.expected @@ -1,23 +1,31 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +35,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,33 +46,28 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1976bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1977bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1978bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1979bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1976bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -81,82 +80,89 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R1, VF, ZF, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == false); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1976bv64) == 1bv8); - free requires (memory_load8_le(mem, 1977bv64) == 0bv8); - free requires (memory_load8_le(mem, 1978bv64) == 2bv8); - free requires (memory_load8_le(mem, 1979bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1976bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1976bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1977bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1978bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1979bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1976bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_8: bool; - var Gamma_R1_6: bool; - var R0_10: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_6: bv32; - var R0_8: bv64; - var R1_6: bv64; + var Cse0__5$2$7: bv32; + var Gamma_Cse0__5$2$7: bool; $main$__0__$odan6iejSaiIvyv2xbxX2Q: + assume {:captureState "$main$__0__$odan6iejSaiIvyv2xbxX2Q"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1888$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, R0_5), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$2$7, Gamma_Cse0__5$2$7 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$2$7, Cse0__5$2$7)), Gamma_Cse0__5$2$7; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$2$7), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$2$7); + ZF, Gamma_ZF := bvcomp32(Cse0__5$2$7, 0bv32), Gamma_Cse0__5$2$7; + NF, Gamma_NF := Cse0__5$2$7[32:31], Gamma_Cse0__5$2$7; + assert Gamma_ZF; goto $main$__0__$odan6iejSaiIvyv2xbxX2Q_goto_$main$__2__$7OQ5GMtLT3i738Ax4kb9lg, $main$__0__$odan6iejSaiIvyv2xbxX2Q_goto_$main$__1__$MCUkhZcpTE24flHPahs6NA; - $main$__0__$odan6iejSaiIvyv2xbxX2Q_goto_$main$__1__$MCUkhZcpTE24flHPahs6NA: - assume (!(R0_6 == 0bv32)); + $main$__1__$MCUkhZcpTE24flHPahs6NA: + assume {:captureState "$main$__1__$MCUkhZcpTE24flHPahs6NA"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_8, Gamma_R0_8 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); + R1, Gamma_R1 := 3bv64, true; call rely(); - assert (L(mem, R0_8) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_8, 3bv32), gamma_store32(Gamma_mem, R0_8, true); - R1_6, Gamma_R1_6 := 3bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1924$0"} true; goto $main$__3__$bH6WR9krRFGfL0jcN6MCWA; - $main$__0__$odan6iejSaiIvyv2xbxX2Q_goto_$main$__2__$7OQ5GMtLT3i738Ax4kb9lg: - assume (R0_6 == 0bv32); + $main$__2__$7OQ5GMtLT3i738Ax4kb9lg: + assume {:captureState "$main$__2__$7OQ5GMtLT3i738Ax4kb9lg"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_10, Gamma_R0_10 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); + R1, Gamma_R1 := 2bv64, true; call rely(); - assert (L(mem, R0_10) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_10, 2bv32), gamma_store32(Gamma_mem, R0_10, true); - R1_6, Gamma_R1_6 := 2bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1944$0"} true; goto $main$__3__$bH6WR9krRFGfL0jcN6MCWA; $main$__3__$bH6WR9krRFGfL0jcN6MCWA: + assume {:captureState "$main$__3__$bH6WR9krRFGfL0jcN6MCWA"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + $main$__0__$odan6iejSaiIvyv2xbxX2Q_goto_$main$__2__$7OQ5GMtLT3i738Ax4kb9lg: + assume {:captureState "$main$__0__$odan6iejSaiIvyv2xbxX2Q_goto_$main$__2__$7OQ5GMtLT3i738Ax4kb9lg"} true; + assume (ZF == 1bv1); + goto $main$__2__$7OQ5GMtLT3i738Ax4kb9lg; + $main$__0__$odan6iejSaiIvyv2xbxX2Q_goto_$main$__1__$MCUkhZcpTE24flHPahs6NA: + assume {:captureState "$main$__0__$odan6iejSaiIvyv2xbxX2Q_goto_$main$__1__$MCUkhZcpTE24flHPahs6NA"} true; + assume (!(ZF == 1bv1)); + goto $main$__1__$MCUkhZcpTE24flHPahs6NA; main_basil_return: - R0_out, R1_out := 0bv64, R1_6; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_6; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/floatingpoint/clang/floatingpoint_gtirb.expected b/src/test/correct/floatingpoint/clang/floatingpoint_gtirb.expected index 2b88f0ddd..376b609a9 100644 --- a/src/test/correct/floatingpoint/clang/floatingpoint_gtirb.expected +++ b/src/test/correct/floatingpoint/clang/floatingpoint_gtirb.expected @@ -1,5 +1,19 @@ +var {:extern} FPCR: bv32; +var {:extern} Gamma_FPCR: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_V0: bool; +var {:extern} Gamma_V1: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} V0: bv128; +var {:extern} V1: bv128; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -15,25 +29,11 @@ function FPMul$64(bv64, bv64, bv32) returns (bv64); function FPSub$32(bv32, bv32, bv32) returns (bv32); function FPSub$64(bv64, bv64, bv32) returns (bv64); function FPToFixed$32$64(bv64, int, bool, bv32, int) returns (bv32); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -43,15 +43,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -63,20 +59,21 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_2(bv2) returns (bv3); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 64"} zero_extend64_64(bv64) returns (bv128); function {:extern} {:bvbuiltin "zero_extend 96"} zero_extend96_32(bv32) returns (bv128); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2088bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2096bv64) == 4767034467667331754bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); @@ -86,8 +83,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -100,8 +97,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(FPCR_in: bv32, Gamma_FPCR_in: bool, R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_V0, Gamma_V1, Gamma_mem, Gamma_stack, R0, R31, R8, V0, V1, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); free requires (memory_load64_le(mem, 2088bv64) == 131073bv64); @@ -110,6 +107,8 @@ procedure main(FPCR_in: bv32, Gamma_FPCR_in: bool, R0_in: bv64, Gamma_R0_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2088bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2096bv64) == 4767034467667331754bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); @@ -117,133 +116,146 @@ procedure main(FPCR_in: bv32, Gamma_FPCR_in: bool, R0_in: bv64, Gamma_R0_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(FPCR_in: bv32, Gamma_FPCR_in: bool, R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R8_6: bool; - var Gamma_V0_1: bool; - var Gamma_V0_10: bool; - var Gamma_V0_11: bool; - var Gamma_V0_12: bool; - var Gamma_V0_13: bool; - var Gamma_V0_14: bool; - var Gamma_V0_15: bool; - var Gamma_V0_16: bool; - var Gamma_V0_17: bool; - var Gamma_V0_18: bool; - var Gamma_V0_19: bool; - var Gamma_V0_2: bool; - var Gamma_V0_20: bool; - var Gamma_V0_21: bool; - var Gamma_V0_22: bool; - var Gamma_V0_23: bool; - var Gamma_V0_24: bool; - var Gamma_V0_3: bool; - var Gamma_V0_4: bool; - var Gamma_V0_5: bool; - var Gamma_V0_6: bool; - var Gamma_V0_7: bool; - var Gamma_V0_8: bool; - var Gamma_V0_9: bool; - var Gamma_V1_1: bool; - var Gamma_V1_11: bool; - var Gamma_V1_2: bool; - var Gamma_V1_3: bool; - var Gamma_V1_4: bool; - var Gamma_V1_5: bool; - var Gamma_V1_7: bool; - var Gamma_V1_9: bool; - var R0_2: bv64; - var R8_6: bv64; - var V0_1: bv128; - var V0_10: bv128; - var V0_11: bv128; - var V0_12: bv128; - var V0_13: bv128; - var V0_14: bv128; - var V0_15: bv128; - var V0_16: bv128; - var V0_17: bv128; - var V0_18: bv128; - var V0_19: bv128; - var V0_2: bv128; - var V0_20: bv128; - var V0_21: bv128; - var V0_22: bv128; - var V0_23: bv128; - var V0_24: bv128; - var V0_3: bv128; - var V0_4: bv128; - var V0_5: bv128; - var V0_6: bv128; - var V0_7: bv128; - var V0_8: bv128; - var V0_9: bv128; - var V1_1: bv128; - var V1_11: bv128; - var V1_2: bv128; - var V1_3: bv128; - var V1_4: bv128; - var V1_5: bv128; - var V1_7: bv128; - var V1_9: bv128; + var Exp10__6$0$33: bv64; + var Exp10__6$0$38: bv64; + var Exp10__6$0$43: bv64; + var Exp10__6$0$48: bv64; + var Exp10__6$0$52: bv32; + var Exp10__6$0$55: bv64; + var Exp7__5$0$58: bv32; + var Exp9__5$0$14: bv32; + var Exp9__5$0$18: bv32; + var Exp9__5$0$22: bv32; + var Exp9__5$0$26: bv32; + var Exp9__5$0$34: bv64; + var Exp9__5$0$39: bv64; + var Exp9__5$0$44: bv64; + var Exp9__5$0$49: bv64; + var FPDecodeRounding8__7: bv3; + var Gamma_Exp10__6$0$33: bool; + var Gamma_Exp10__6$0$38: bool; + var Gamma_Exp10__6$0$43: bool; + var Gamma_Exp10__6$0$48: bool; + var Gamma_Exp10__6$0$52: bool; + var Gamma_Exp10__6$0$55: bool; + var Gamma_Exp7__5$0$58: bool; + var Gamma_Exp9__5$0$14: bool; + var Gamma_Exp9__5$0$18: bool; + var Gamma_Exp9__5$0$22: bool; + var Gamma_Exp9__5$0$26: bool; + var Gamma_Exp9__5$0$34: bool; + var Gamma_Exp9__5$0$39: bool; + var Gamma_Exp9__5$0$44: bool; + var Gamma_Exp9__5$0$49: bool; + var Gamma_FPDecodeRounding8__7: bool; $main$__0__$b3UZxKKWTIWwuKGd8CuBtA: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R1_in); - V0_1, Gamma_V0_1 := 1093186421bv128, true; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), V0_1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_V0_1); - V0_2, Gamma_V0_2 := 1079401174bv128, true; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), V0_2[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_V0_2); - V0_3, Gamma_V0_3 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - V1_1, Gamma_V1_1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - V0_4, Gamma_V0_4 := zero_extend96_32(FPMul$32(V0_3[32:0], V1_1[32:0], FPCR_in)), (Gamma_FPCR_in && (Gamma_V1_1 && Gamma_V0_3)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551588bv64), V0_4[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64), Gamma_V0_4); - V0_5, Gamma_V0_5 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - V1_2, Gamma_V1_2 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - V0_6, Gamma_V0_6 := zero_extend96_32(FPDiv$32(V0_5[32:0], V1_2[32:0], FPCR_in)), (Gamma_FPCR_in && (Gamma_V1_2 && Gamma_V0_5)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551588bv64), V0_6[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64), Gamma_V0_6); - V0_7, Gamma_V0_7 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - V1_3, Gamma_V1_3 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - V0_8, Gamma_V0_8 := zero_extend96_32(FPSub$32(V0_7[32:0], V1_3[32:0], FPCR_in)), (Gamma_FPCR_in && (Gamma_V1_3 && Gamma_V0_7)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551588bv64), V0_8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64), Gamma_V0_8); - V0_9, Gamma_V0_9 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - V1_4, Gamma_V1_4 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - V0_10, Gamma_V0_10 := zero_extend96_32(FPAdd$32(V0_9[32:0], V1_4[32:0], FPCR_in)), (Gamma_FPCR_in && (Gamma_V1_4 && Gamma_V0_9)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551588bv64), V0_10[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64), Gamma_V0_10); + assume {:captureState "$main$__0__$b3UZxKKWTIWwuKGd8CuBtA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551552bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 60bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 60bv64), true); + assume {:captureState "1816$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 56bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 56bv64), Gamma_R0); + assume {:captureState "1820$0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 48bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 48bv64), Gamma_R1); + assume {:captureState "1824$0"} true; + R8, Gamma_R8 := 45941bv64, true; + R8, Gamma_R8 := zero_extend32_32((16680bv16 ++ R8[16:0])), Gamma_R8; + V0, Gamma_V0 := zero_extend96_32(R8[32:0]), Gamma_R8; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_V0); + assume {:captureState "1840$0"} true; + R8, Gamma_R8 := 23254bv64, true; + R8, Gamma_R8 := zero_extend32_32((16470bv16 ++ R8[16:0])), Gamma_R8; + V0, Gamma_V0 := zero_extend96_32(R8[32:0]), Gamma_R8; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 40bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 40bv64), Gamma_V0); + assume {:captureState "1856$0"} true; + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 44bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 44bv64)); + V1, Gamma_V1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 40bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 40bv64)); + Exp9__5$0$14, Gamma_Exp9__5$0$14 := FPMul$32(V0[32:0], V1[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend96_32(Exp9__5$0$14), Gamma_Exp9__5$0$14; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_V0); + assume {:captureState "1872$0"} true; + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 44bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 44bv64)); + V1, Gamma_V1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 40bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 40bv64)); + Exp9__5$0$18, Gamma_Exp9__5$0$18 := FPDiv$32(V0[32:0], V1[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend96_32(Exp9__5$0$18), Gamma_Exp9__5$0$18; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_V0); + assume {:captureState "1888$0"} true; + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 44bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 44bv64)); + V1, Gamma_V1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 40bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 40bv64)); + Exp9__5$0$22, Gamma_Exp9__5$0$22 := FPSub$32(V0[32:0], V1[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend96_32(Exp9__5$0$22), Gamma_Exp9__5$0$22; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_V0); + assume {:captureState "1904$0"} true; + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 44bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 44bv64)); + V1, Gamma_V1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 40bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 40bv64)); + Exp9__5$0$26, Gamma_Exp9__5$0$26 := FPAdd$32(V0[32:0], V1[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend96_32(Exp9__5$0$26), Gamma_Exp9__5$0$26; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_V0); + assume {:captureState "1920$0"} true; + R8, Gamma_R8 := 0bv64, true; call rely(); - V0_11, Gamma_V0_11 := zero_extend64_64(memory_load64_le(mem, 2096bv64)), (gamma_load64(Gamma_mem, 2096bv64) || L(mem, 2096bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551576bv64), V0_11[64:0]), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64), Gamma_V0_11); - V0_12, Gamma_V0_12 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31_in, 18446744073709551576bv64))), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64)); - V1_5, Gamma_V1_5 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - V0_13, Gamma_V0_13 := zero_extend64_64(FPMul$64(V0_12[64:0], FPConvert$64$32(V1_5[32:0], FPCR_in), FPCR_in)), (Gamma_FPCR_in && (Gamma_V1_5 && Gamma_V0_12)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), V0_13[64:0]), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), Gamma_V0_13); - V0_14, Gamma_V0_14 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31_in, 18446744073709551576bv64))), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64)); - V1_7, Gamma_V1_7 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - V0_15, Gamma_V0_15 := zero_extend64_64(FPSub$64(V0_14[64:0], FPConvert$64$32(V1_7[32:0], FPCR_in), FPCR_in)), (Gamma_FPCR_in && (Gamma_V1_7 && Gamma_V0_14)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), V0_15[64:0]), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), Gamma_V0_15); - V0_16, Gamma_V0_16 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31_in, 18446744073709551576bv64))), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64)); - V1_9, Gamma_V1_9 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - V0_17, Gamma_V0_17 := zero_extend64_64(FPAdd$64(V0_16[64:0], FPConvert$64$32(V1_9[32:0], FPCR_in), FPCR_in)), (Gamma_FPCR_in && (Gamma_V1_9 && Gamma_V0_16)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), V0_17[64:0]), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), Gamma_V0_17); - V0_18, Gamma_V0_18 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31_in, 18446744073709551576bv64))), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64)); - V1_11, Gamma_V1_11 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - V0_19, Gamma_V0_19 := zero_extend64_64(FPDiv$64(V0_18[64:0], FPConvert$64$32(V1_11[32:0], FPCR_in), FPCR_in)), (Gamma_FPCR_in && (Gamma_V1_11 && Gamma_V0_18)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), V0_19[64:0]), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), Gamma_V0_19); - V0_20, Gamma_V0_20 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31_in, 18446744073709551568bv64))), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64)); - V0_21, Gamma_V0_21 := zero_extend96_32(FPConvert$32$64(V0_20[64:0], FPCR_in)), (Gamma_FPCR_in && Gamma_V0_20); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), V0_21[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_V0_21); - V0_22, Gamma_V0_22 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - V0_23, Gamma_V0_23 := zero_extend64_64(FPConvert$64$32(V0_22[32:0], FPCR_in)), (Gamma_FPCR_in && Gamma_V0_22); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551576bv64), V0_23[64:0]), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64), Gamma_V0_23); - V0_24, Gamma_V0_24 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31_in, 18446744073709551568bv64))), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64)); - R8_6, Gamma_R8_6 := zero_extend32_32(FPToFixed$32$64(V0_24[64:0], 0, false, FPCR_in, 3)), (Gamma_FPCR_in && Gamma_V0_24); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551564bv64), R8_6[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551564bv64), Gamma_R8_6); - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551564bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551564bv64)); + V0, Gamma_V0 := zero_extend64_64(memory_load64_le(mem, bvadd64(R8, 2096bv64))), (gamma_load64(Gamma_mem, bvadd64(R8, 2096bv64)) || L(mem, bvadd64(R8, 2096bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), V0[64:0]), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_V0); + assume {:captureState "1932$0"} true; + V0, Gamma_V0 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31, 24bv64))), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + V1, Gamma_V1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 40bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 40bv64)); + FPDecodeRounding8__7, Gamma_FPDecodeRounding8__7 := zero_extend1_2(FPCR[24:22]), Gamma_FPCR; + Exp10__6$0$33, Gamma_Exp10__6$0$33 := FPConvert$64$32(V1[32:0], FPCR), true; + V1, Gamma_V1 := zero_extend64_64(Exp10__6$0$33), Gamma_Exp10__6$0$33; + Exp9__5$0$34, Gamma_Exp9__5$0$34 := FPMul$64(V0[64:0], V1[64:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp9__5$0$34), Gamma_Exp9__5$0$34; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), V0[64:0]), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_V0); + assume {:captureState "1952$0"} true; + V0, Gamma_V0 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31, 24bv64))), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + V1, Gamma_V1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 40bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 40bv64)); + FPDecodeRounding8__7, Gamma_FPDecodeRounding8__7 := zero_extend1_2(FPCR[24:22]), Gamma_FPCR; + Exp10__6$0$38, Gamma_Exp10__6$0$38 := FPConvert$64$32(V1[32:0], FPCR), true; + V1, Gamma_V1 := zero_extend64_64(Exp10__6$0$38), Gamma_Exp10__6$0$38; + Exp9__5$0$39, Gamma_Exp9__5$0$39 := FPSub$64(V0[64:0], V1[64:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp9__5$0$39), Gamma_Exp9__5$0$39; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), V0[64:0]), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_V0); + assume {:captureState "1972$0"} true; + V0, Gamma_V0 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31, 24bv64))), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + V1, Gamma_V1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 40bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 40bv64)); + FPDecodeRounding8__7, Gamma_FPDecodeRounding8__7 := zero_extend1_2(FPCR[24:22]), Gamma_FPCR; + Exp10__6$0$43, Gamma_Exp10__6$0$43 := FPConvert$64$32(V1[32:0], FPCR), true; + V1, Gamma_V1 := zero_extend64_64(Exp10__6$0$43), Gamma_Exp10__6$0$43; + Exp9__5$0$44, Gamma_Exp9__5$0$44 := FPAdd$64(V0[64:0], V1[64:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp9__5$0$44), Gamma_Exp9__5$0$44; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), V0[64:0]), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_V0); + assume {:captureState "1992$0"} true; + V0, Gamma_V0 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31, 24bv64))), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + V1, Gamma_V1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 40bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 40bv64)); + FPDecodeRounding8__7, Gamma_FPDecodeRounding8__7 := zero_extend1_2(FPCR[24:22]), Gamma_FPCR; + Exp10__6$0$48, Gamma_Exp10__6$0$48 := FPConvert$64$32(V1[32:0], FPCR), true; + V1, Gamma_V1 := zero_extend64_64(Exp10__6$0$48), Gamma_Exp10__6$0$48; + Exp9__5$0$49, Gamma_Exp9__5$0$49 := FPDiv$64(V0[64:0], V1[64:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp9__5$0$49), Gamma_Exp9__5$0$49; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), V0[64:0]), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_V0); + assume {:captureState "2012$0"} true; + V0, Gamma_V0 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31, 16bv64))), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + FPDecodeRounding8__7, Gamma_FPDecodeRounding8__7 := zero_extend1_2(FPCR[24:22]), Gamma_FPCR; + Exp10__6$0$52, Gamma_Exp10__6$0$52 := FPConvert$32$64(V0[64:0], FPCR), true; + V0, Gamma_V0 := zero_extend96_32(Exp10__6$0$52), Gamma_Exp10__6$0$52; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_V0); + assume {:captureState "2024$0"} true; + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 40bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 40bv64)); + FPDecodeRounding8__7, Gamma_FPDecodeRounding8__7 := zero_extend1_2(FPCR[24:22]), Gamma_FPCR; + Exp10__6$0$55, Gamma_Exp10__6$0$55 := FPConvert$64$32(V0[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp10__6$0$55), Gamma_Exp10__6$0$55; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), V0[64:0]), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_V0); + assume {:captureState "2036$0"} true; + V0, Gamma_V0 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31, 16bv64))), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + Exp7__5$0$58, Gamma_Exp7__5$0$58 := FPToFixed$32$64(V0[64:0], 0, false, FPCR, 3), true; + R8, Gamma_R8 := zero_extend32_32(Exp7__5$0$58), Gamma_Exp7__5$0$58; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "2048$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 64bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R31_out, R8_out := R0_2, R31_in, R8_6; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_2, Gamma_R31_in, Gamma_R8_6; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/floatingpoint/gcc/floatingpoint_gtirb.expected b/src/test/correct/floatingpoint/gcc/floatingpoint_gtirb.expected index baa123e73..72d704dc3 100644 --- a/src/test/correct/floatingpoint/gcc/floatingpoint_gtirb.expected +++ b/src/test/correct/floatingpoint/gcc/floatingpoint_gtirb.expected @@ -1,5 +1,17 @@ +var {:extern} FPCR: bv32; +var {:extern} Gamma_FPCR: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_V0: bool; +var {:extern} Gamma_V1: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} V0: bv128; +var {:extern} V1: bv128; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -15,25 +27,11 @@ function FPMul$64(bv64, bv64, bv32) returns (bv64); function FPSub$32(bv32, bv32, bv32) returns (bv32); function FPSub$64(bv64, bv64, bv32) returns (bv64); function FPToFixed$32$64(bv64, int, bool, bv32, int) returns (bv32); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -43,15 +41,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -63,20 +57,21 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_2(bv2) returns (bv3); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 64"} zero_extend64_64(bv64) returns (bv128); function {:extern} {:bvbuiltin "zero_extend 96"} zero_extend96_32(bv32) returns (bv128); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2080bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2088bv64) == 4767034467667331754bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); @@ -86,8 +81,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -100,8 +95,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(FPCR_in: bv32, Gamma_FPCR_in: bool, R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R31, Gamma_V0, Gamma_V1, Gamma_mem, Gamma_stack, R0, R31, V0, V1, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2080bv64) == 131073bv64); @@ -110,6 +105,8 @@ procedure main(FPCR_in: bv32, Gamma_FPCR_in: bool, R0_in: bv64, Gamma_R0_in: boo free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2080bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2088bv64) == 4767034467667331754bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); @@ -117,132 +114,144 @@ procedure main(FPCR_in: bv32, Gamma_FPCR_in: bool, R0_in: bv64, Gamma_R0_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(FPCR_in: bv32, Gamma_FPCR_in: bool, R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_V0_1: bool; - var Gamma_V0_10: bool; - var Gamma_V0_11: bool; - var Gamma_V0_12: bool; - var Gamma_V0_14: bool; - var Gamma_V0_15: bool; - var Gamma_V0_17: bool; - var Gamma_V0_18: bool; - var Gamma_V0_2: bool; - var Gamma_V0_20: bool; - var Gamma_V0_21: bool; - var Gamma_V0_23: bool; - var Gamma_V0_24: bool; - var Gamma_V0_25: bool; - var Gamma_V0_26: bool; - var Gamma_V0_27: bool; - var Gamma_V0_28: bool; - var Gamma_V0_3: bool; - var Gamma_V0_4: bool; - var Gamma_V0_5: bool; - var Gamma_V0_6: bool; - var Gamma_V0_7: bool; - var Gamma_V0_8: bool; - var Gamma_V0_9: bool; - var Gamma_V1_1: bool; - var Gamma_V1_2: bool; - var Gamma_V1_3: bool; - var Gamma_V1_4: bool; - var Gamma_V1_5: bool; - var Gamma_V1_6: bool; - var Gamma_V1_7: bool; - var Gamma_V1_8: bool; - var R0_7: bv64; - var R0_8: bv64; - var V0_1: bv128; - var V0_10: bv128; - var V0_11: bv128; - var V0_12: bv128; - var V0_14: bv128; - var V0_15: bv128; - var V0_17: bv128; - var V0_18: bv128; - var V0_2: bv128; - var V0_20: bv128; - var V0_21: bv128; - var V0_23: bv128; - var V0_24: bv128; - var V0_25: bv128; - var V0_26: bv128; - var V0_27: bv128; - var V0_28: bv128; - var V0_3: bv128; - var V0_4: bv128; - var V0_5: bv128; - var V0_6: bv128; - var V0_7: bv128; - var V0_8: bv128; - var V0_9: bv128; - var V1_1: bv128; - var V1_2: bv128; - var V1_3: bv128; - var V1_4: bv128; - var V1_5: bv128; - var V1_6: bv128; - var V1_7: bv128; - var V1_8: bv128; + var Exp10__6$0$31: bv64; + var Exp10__6$0$36: bv64; + var Exp10__6$0$41: bv64; + var Exp10__6$0$46: bv64; + var Exp10__6$0$51: bv32; + var Exp10__6$0$54: bv64; + var Exp7__5$0$57: bv32; + var Exp9__5$0$13: bv32; + var Exp9__5$0$17: bv32; + var Exp9__5$0$21: bv32; + var Exp9__5$0$25: bv32; + var Exp9__5$0$33: bv64; + var Exp9__5$0$38: bv64; + var Exp9__5$0$43: bv64; + var Exp9__5$0$48: bv64; + var FPDecodeRounding8__7: bv3; + var Gamma_Exp10__6$0$31: bool; + var Gamma_Exp10__6$0$36: bool; + var Gamma_Exp10__6$0$41: bool; + var Gamma_Exp10__6$0$46: bool; + var Gamma_Exp10__6$0$51: bool; + var Gamma_Exp10__6$0$54: bool; + var Gamma_Exp7__5$0$57: bool; + var Gamma_Exp9__5$0$13: bool; + var Gamma_Exp9__5$0$17: bool; + var Gamma_Exp9__5$0$21: bool; + var Gamma_Exp9__5$0$25: bool; + var Gamma_Exp9__5$0$33: bool; + var Gamma_Exp9__5$0$38: bool; + var Gamma_Exp9__5$0$43: bool; + var Gamma_Exp9__5$0$48: bool; + var Gamma_FPDecodeRounding8__7: bool; $main$__0__$ApY~zz48QdCDKl~J0XWxTA: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551580bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R1_in); - V0_1, Gamma_V0_1 := 1093186421bv128, true; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551584bv64), V0_1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_V0_1); - V0_2, Gamma_V0_2 := 1079401174bv128, true; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551588bv64), V0_2[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64), Gamma_V0_2); - V1_1, Gamma_V1_1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551584bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - V0_3, Gamma_V0_3 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551588bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64)); - V0_4, Gamma_V0_4 := zero_extend96_32(FPMul$32(V1_1[32:0], V0_3[32:0], FPCR_in)), (Gamma_FPCR_in && (Gamma_V0_3 && Gamma_V1_1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), V0_4[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_V0_4); - V0_5, Gamma_V0_5 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551588bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64)); - V1_2, Gamma_V1_2 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551584bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - V0_6, Gamma_V0_6 := zero_extend96_32(FPDiv$32(V1_2[32:0], V0_5[32:0], FPCR_in)), (Gamma_FPCR_in && (Gamma_V0_5 && Gamma_V1_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), V0_6[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_V0_6); - V1_3, Gamma_V1_3 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551584bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - V0_7, Gamma_V0_7 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551588bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64)); - V0_8, Gamma_V0_8 := zero_extend96_32(FPSub$32(V1_3[32:0], V0_7[32:0], FPCR_in)), (Gamma_FPCR_in && (Gamma_V0_7 && Gamma_V1_3)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), V0_8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_V0_8); - V1_4, Gamma_V1_4 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551584bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - V0_9, Gamma_V0_9 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551588bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64)); - V0_10, Gamma_V0_10 := zero_extend96_32(FPAdd$32(V1_4[32:0], V0_9[32:0], FPCR_in)), (Gamma_FPCR_in && (Gamma_V0_9 && Gamma_V1_4)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), V0_10[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_V0_10); + assume {:captureState "$main$__0__$ApY~zz48QdCDKl~J0XWxTA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1816$0"} true; + stack, Gamma_stack := memory_store64_le(stack, R31, R1), gamma_store64(Gamma_stack, R31, Gamma_R1); + assume {:captureState "1820$0"} true; + R0, Gamma_R0 := 45941bv64, true; + R0, Gamma_R0 := zero_extend32_32((16680bv16 ++ R0[16:0])), Gamma_R0; + V0, Gamma_V0 := zero_extend96_32(R0[32:0]), Gamma_R0; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 16bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 16bv64), Gamma_V0); + assume {:captureState "1836$0"} true; + R0, Gamma_R0 := 23254bv64, true; + R0, Gamma_R0 := zero_extend32_32((16470bv16 ++ R0[16:0])), Gamma_R0; + V0, Gamma_V0 := zero_extend96_32(R0[32:0]), Gamma_R0; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_V0); + assume {:captureState "1852$0"} true; + V1, Gamma_V1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 16bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 16bv64)); + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + Exp9__5$0$13, Gamma_Exp9__5$0$13 := FPMul$32(V1[32:0], V0[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend96_32(Exp9__5$0$13), Gamma_Exp9__5$0$13; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_V0); + assume {:captureState "1868$0"} true; + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + V1, Gamma_V1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 16bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 16bv64)); + Exp9__5$0$17, Gamma_Exp9__5$0$17 := FPDiv$32(V1[32:0], V0[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend96_32(Exp9__5$0$17), Gamma_Exp9__5$0$17; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_V0); + assume {:captureState "1884$0"} true; + V1, Gamma_V1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 16bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 16bv64)); + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + Exp9__5$0$21, Gamma_Exp9__5$0$21 := FPSub$32(V1[32:0], V0[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend96_32(Exp9__5$0$21), Gamma_Exp9__5$0$21; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_V0); + assume {:captureState "1900$0"} true; + V1, Gamma_V1 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 16bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 16bv64)); + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + Exp9__5$0$25, Gamma_Exp9__5$0$25 := FPAdd$32(V1[32:0], V0[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend96_32(Exp9__5$0$25), Gamma_Exp9__5$0$25; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_V0); + assume {:captureState "1916$0"} true; + R0, Gamma_R0 := 0bv64, true; call rely(); - V0_11, Gamma_V0_11 := zero_extend64_64(memory_load64_le(mem, 2088bv64)), (gamma_load64(Gamma_mem, 2088bv64) || L(mem, 2088bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), V0_11[64:0]), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_V0_11); - V0_12, Gamma_V0_12 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551588bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64)); - V1_5, Gamma_V1_5 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64))), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - V0_14, Gamma_V0_14 := zero_extend64_64(FPMul$64(V1_5[64:0], FPConvert$64$32(V0_12[32:0], FPCR_in), FPCR_in)), (Gamma_FPCR_in && (Gamma_V0_12 && Gamma_V1_5)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), V0_14[64:0]), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_V0_14); - V0_15, Gamma_V0_15 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551588bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64)); - V1_6, Gamma_V1_6 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64))), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - V0_17, Gamma_V0_17 := zero_extend64_64(FPSub$64(V1_6[64:0], FPConvert$64$32(V0_15[32:0], FPCR_in), FPCR_in)), (Gamma_FPCR_in && (Gamma_V0_15 && Gamma_V1_6)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), V0_17[64:0]), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_V0_17); - V0_18, Gamma_V0_18 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551588bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64)); - V1_7, Gamma_V1_7 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64))), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - V0_20, Gamma_V0_20 := zero_extend64_64(FPAdd$64(V1_7[64:0], FPConvert$64$32(V0_18[32:0], FPCR_in), FPCR_in)), (Gamma_FPCR_in && (Gamma_V0_18 && Gamma_V1_7)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), V0_20[64:0]), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_V0_20); - V0_21, Gamma_V0_21 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551588bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64)); - V1_8, Gamma_V1_8 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64))), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - V0_23, Gamma_V0_23 := zero_extend64_64(FPDiv$64(V1_8[64:0], FPConvert$64$32(V0_21[32:0], FPCR_in), FPCR_in)), (Gamma_FPCR_in && (Gamma_V0_21 && Gamma_V1_8)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), V0_23[64:0]), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_V0_23); - V0_24, Gamma_V0_24 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - V0_25, Gamma_V0_25 := zero_extend96_32(FPConvert$32$64(V0_24[64:0], FPCR_in)), (Gamma_FPCR_in && Gamma_V0_24); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551584bv64), V0_25[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_V0_25); - V0_26, Gamma_V0_26 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551588bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64)); - V0_27, Gamma_V0_27 := zero_extend64_64(FPConvert$64$32(V0_26[32:0], FPCR_in)), (Gamma_FPCR_in && Gamma_V0_26); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), V0_27[64:0]), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_V0_27); - V0_28, Gamma_V0_28 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - R0_7, Gamma_R0_7 := zero_extend32_32(FPToFixed$32$64(V0_28[64:0], 0, false, FPCR_in, 3)), (Gamma_FPCR_in && Gamma_V0_28); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_7[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_7); - R0_8, Gamma_R0_8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); + V0, Gamma_V0 := zero_extend64_64(memory_load64_le(mem, bvadd64(R0, 2088bv64))), (gamma_load64(Gamma_mem, bvadd64(R0, 2088bv64)) || L(mem, bvadd64(R0, 2088bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), V0[64:0]), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_V0); + assume {:captureState "1928$0"} true; + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + FPDecodeRounding8__7, Gamma_FPDecodeRounding8__7 := zero_extend1_2(FPCR[24:22]), Gamma_FPCR; + Exp10__6$0$31, Gamma_Exp10__6$0$31 := FPConvert$64$32(V0[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp10__6$0$31), Gamma_Exp10__6$0$31; + V1, Gamma_V1 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31, 32bv64))), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + Exp9__5$0$33, Gamma_Exp9__5$0$33 := FPMul$64(V1[64:0], V0[64:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp9__5$0$33), Gamma_Exp9__5$0$33; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), V0[64:0]), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_V0); + assume {:captureState "1948$0"} true; + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + FPDecodeRounding8__7, Gamma_FPDecodeRounding8__7 := zero_extend1_2(FPCR[24:22]), Gamma_FPCR; + Exp10__6$0$36, Gamma_Exp10__6$0$36 := FPConvert$64$32(V0[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp10__6$0$36), Gamma_Exp10__6$0$36; + V1, Gamma_V1 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31, 32bv64))), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + Exp9__5$0$38, Gamma_Exp9__5$0$38 := FPSub$64(V1[64:0], V0[64:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp9__5$0$38), Gamma_Exp9__5$0$38; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), V0[64:0]), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_V0); + assume {:captureState "1968$0"} true; + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + FPDecodeRounding8__7, Gamma_FPDecodeRounding8__7 := zero_extend1_2(FPCR[24:22]), Gamma_FPCR; + Exp10__6$0$41, Gamma_Exp10__6$0$41 := FPConvert$64$32(V0[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp10__6$0$41), Gamma_Exp10__6$0$41; + V1, Gamma_V1 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31, 32bv64))), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + Exp9__5$0$43, Gamma_Exp9__5$0$43 := FPAdd$64(V1[64:0], V0[64:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp9__5$0$43), Gamma_Exp9__5$0$43; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), V0[64:0]), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_V0); + assume {:captureState "1988$0"} true; + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + FPDecodeRounding8__7, Gamma_FPDecodeRounding8__7 := zero_extend1_2(FPCR[24:22]), Gamma_FPCR; + Exp10__6$0$46, Gamma_Exp10__6$0$46 := FPConvert$64$32(V0[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp10__6$0$46), Gamma_Exp10__6$0$46; + V1, Gamma_V1 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31, 32bv64))), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + Exp9__5$0$48, Gamma_Exp9__5$0$48 := FPDiv$64(V1[64:0], V0[64:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp9__5$0$48), Gamma_Exp9__5$0$48; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), V0[64:0]), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_V0); + assume {:captureState "2008$0"} true; + V0, Gamma_V0 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31, 40bv64))), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + FPDecodeRounding8__7, Gamma_FPDecodeRounding8__7 := zero_extend1_2(FPCR[24:22]), Gamma_FPCR; + Exp10__6$0$51, Gamma_Exp10__6$0$51 := FPConvert$32$64(V0[64:0], FPCR), true; + V0, Gamma_V0 := zero_extend96_32(Exp10__6$0$51), Gamma_Exp10__6$0$51; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 16bv64), V0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 16bv64), Gamma_V0); + assume {:captureState "2020$0"} true; + V0, Gamma_V0 := zero_extend96_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + FPDecodeRounding8__7, Gamma_FPDecodeRounding8__7 := zero_extend1_2(FPCR[24:22]), Gamma_FPCR; + Exp10__6$0$54, Gamma_Exp10__6$0$54 := FPConvert$64$32(V0[32:0], FPCR), true; + V0, Gamma_V0 := zero_extend64_64(Exp10__6$0$54), Gamma_Exp10__6$0$54; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), V0[64:0]), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_V0); + assume {:captureState "2032$0"} true; + V0, Gamma_V0 := zero_extend64_64(memory_load64_le(stack, bvadd64(R31, 40bv64))), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + Exp7__5$0$57, Gamma_Exp7__5$0$57 := FPToFixed$32$64(V0[64:0], 0, false, FPCR, 3), true; + R0, Gamma_R0 := zero_extend32_32(Exp7__5$0$57), Gamma_Exp7__5$0$57; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "2044$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R31_out := R0_8, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_8, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/function/clang/function.expected b/src/test/correct/function/clang/function.expected index 8548505a0..30f7cb520 100644 --- a/src/test/correct/function/clang/function.expected +++ b/src/test/correct/function/clang/function.expected @@ -1,30 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,41 +32,34 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1884bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1885bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1886bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1887bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1884bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -76,8 +67,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -90,84 +81,88 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure get_two() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1884bv64) == 1bv8); - free requires (memory_load8_le(mem, 1885bv64) == 0bv8); - free requires (memory_load8_le(mem, 1886bv64) == 2bv8); - free requires (memory_load8_le(mem, 1887bv64) == 0bv8); +procedure get_two(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1884bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - ensures (Gamma_R0_out == true); - free ensures (memory_load8_le(mem, 1884bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1885bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1886bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1887bv64) == 0bv8); + ensures (Gamma_R0 == true); + free ensures (memory_load32_le(mem, 1884bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation get_two() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation get_two() { lget_two: + assume {:captureState "lget_two"} true; + R0, Gamma_R0 := 2bv64, true; goto get_two_basil_return; get_two_basil_return: - R0_out := 2bv64; - Gamma_R0_out := true; + assume {:captureState "get_two_basil_return"} true; return; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R29, R30, R31, R8, R9, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1884bv64) == 1bv8); - free requires (memory_load8_le(mem, 1885bv64) == 0bv8); - free requires (memory_load8_le(mem, 1886bv64) == 2bv8); - free requires (memory_load8_le(mem, 1887bv64) == 0bv8); + free requires (memory_load32_le(mem, 1884bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1884bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1885bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1886bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1887bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1884bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var R0_1: bv64; - var R29_3: bv64; - var R30_3: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000008db"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000008e1"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); - call R0_1, Gamma_R0_1 := get_two(); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "%000008fd"} true; + R30, Gamma_R30 := 1836bv64, true; + call get_two(); goto l00000910; l00000910: + assume {:captureState "l00000910"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R0_1); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R0_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R0_1); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R0); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R0); + assume {:captureState "%0000091b"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out, R9_out := 0bv64, R29_3, R30_3, R31_in, 69632bv64, 69632bv64; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/function/clang/function_gtirb.expected b/src/test/correct/function/clang/function_gtirb.expected index ac588414f..66b9258bb 100644 --- a/src/test/correct/function/clang/function_gtirb.expected +++ b/src/test/correct/function/clang/function_gtirb.expected @@ -1,30 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,41 +32,34 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1884bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1885bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1886bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1887bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1884bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -76,8 +67,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -90,84 +81,88 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R29, R30, R31, R8, R9, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1884bv64) == 1bv8); - free requires (memory_load8_le(mem, 1885bv64) == 0bv8); - free requires (memory_load8_le(mem, 1886bv64) == 2bv8); - free requires (memory_load8_le(mem, 1887bv64) == 0bv8); + free requires (memory_load32_le(mem, 1884bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1884bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1885bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1886bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1887bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1884bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var R0_1: bv64; - var R29_3: bv64; - var R30_3: bv64; + var Cse0__5$0$0: bv64; + var Gamma_Cse0__5$0$0: bool; $main$__0__$EOZN5uSLQQqIXnLhnZHeWA: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "$main$__0__$EOZN5uSLQQqIXnLhnZHeWA"} true; + Cse0__5$0$0, Gamma_Cse0__5$0$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$0, R29), gamma_store64(Gamma_stack, Cse0__5$0$0, Gamma_R29); + assume {:captureState "1812$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$0, 8bv64), Gamma_R30); + assume {:captureState "1812$2"} true; + R31, Gamma_R31 := Cse0__5$0$0, Gamma_Cse0__5$0$0; + R29, Gamma_R29 := R31, Gamma_R31; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); - call R0_1, Gamma_R0_1 := get_two(); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "1828$0"} true; + R30, Gamma_R30 := 1836bv64, true; + call get_two(); goto $main$__1__$Q55zdQssRl~zLCCVlSDCuw; $main$__1__$Q55zdQssRl~zLCCVlSDCuw: + assume {:captureState "$main$__1__$Q55zdQssRl~zLCCVlSDCuw"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R0_1); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R0_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R0_1); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R0); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R0); + assume {:captureState "1840$0"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out, R9_out := 0bv64, R29_3, R30_3, R31_in, 69632bv64, 69632bv64; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in, true, true; + assume {:captureState "main_basil_return"} true; return; } -procedure get_two() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1884bv64) == 1bv8); - free requires (memory_load8_le(mem, 1885bv64) == 0bv8); - free requires (memory_load8_le(mem, 1886bv64) == 2bv8); - free requires (memory_load8_le(mem, 1887bv64) == 0bv8); +procedure get_two(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1884bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - ensures (Gamma_R0_out == true); - free ensures (memory_load8_le(mem, 1884bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1885bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1886bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1887bv64) == 0bv8); + ensures (Gamma_R0 == true); + free ensures (memory_load32_le(mem, 1884bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation get_two() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation get_two() { $get_two$__0__$1qmWzVjSR9iAETCu0c0vYw: + assume {:captureState "$get_two$__0__$1qmWzVjSR9iAETCu0c0vYw"} true; + R0, Gamma_R0 := 2bv64, true; goto get_two_basil_return; get_two_basil_return: - R0_out := 2bv64; - Gamma_R0_out := true; + assume {:captureState "get_two_basil_return"} true; return; } diff --git a/src/test/correct/function/clang_pic/function.expected b/src/test/correct/function/clang_pic/function.expected index 738380c17..648dee795 100644 --- a/src/test/correct/function/clang_pic/function.expected +++ b/src/test/correct/function/clang_pic/function.expected @@ -1,30 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,52 +32,45 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -92,100 +83,100 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure get_two() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1956bv64) == 1bv8); - free requires (memory_load8_le(mem, 1957bv64) == 0bv8); - free requires (memory_load8_le(mem, 1958bv64) == 2bv8); - free requires (memory_load8_le(mem, 1959bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); +procedure get_two(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1956bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - ensures (Gamma_R0_out == true); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + ensures (Gamma_R0 == true); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation get_two() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation get_two() { lget_two: + assume {:captureState "lget_two"} true; + R0, Gamma_R0 := 2bv64, true; goto get_two_basil_return; get_two_basil_return: - R0_out := 2bv64; - Gamma_R0_out := true; + assume {:captureState "get_two_basil_return"} true; return; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R29, R30, R31, R8, R9, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1956bv64) == 1bv8); - free requires (memory_load8_le(mem, 1957bv64) == 0bv8); - free requires (memory_load8_le(mem, 1958bv64) == 2bv8); - free requires (memory_load8_le(mem, 1959bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load32_le(mem, 1956bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var Gamma_R8_3: bool; - var Gamma_R9_2: bool; - var R0_1: bv64; - var R29_3: bv64; - var R30_3: bv64; - var R8_3: bv64; - var R9_2: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002f0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002f6"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 1bv32), gamma_store32(Gamma_mem, R9_2, true); - call R0_1, Gamma_R0_1 := get_two(); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000319"} true; + R30, Gamma_R30 := 1904bv64, true; + call get_two(); goto l0000032c; l0000032c: + assume {:captureState "l0000032c"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - assert (L(mem, R8_3) ==> Gamma_R0_1); - mem, Gamma_mem := memory_store32_le(mem, R8_3, R0_1[32:0]), gamma_store32(Gamma_mem, R8_3, Gamma_R0_1); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assert (L(mem, R8) ==> Gamma_R0); + mem, Gamma_mem := memory_store32_le(mem, R8, R0[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R0); + assume {:captureState "%0000033e"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out, R9_out := 0bv64, R29_3, R30_3, R31_in, R8_3, R9_2; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in, Gamma_R8_3, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/function/clang_pic/function_gtirb.expected b/src/test/correct/function/clang_pic/function_gtirb.expected index eff74f3ff..044491d73 100644 --- a/src/test/correct/function/clang_pic/function_gtirb.expected +++ b/src/test/correct/function/clang_pic/function_gtirb.expected @@ -1,30 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,52 +32,45 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -92,100 +83,100 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R29, R30, R31, R8, R9, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1956bv64) == 1bv8); - free requires (memory_load8_le(mem, 1957bv64) == 0bv8); - free requires (memory_load8_le(mem, 1958bv64) == 2bv8); - free requires (memory_load8_le(mem, 1959bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load32_le(mem, 1956bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var Gamma_R8_3: bool; - var Gamma_R9_2: bool; - var R0_1: bv64; - var R29_3: bv64; - var R30_3: bv64; - var R8_3: bv64; - var R9_2: bv64; + var Cse0__5$0$0: bv64; + var Gamma_Cse0__5$0$0: bool; $main$__0__$NmMrnPbhSNuHmxHjD8po9A: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "$main$__0__$NmMrnPbhSNuHmxHjD8po9A"} true; + Cse0__5$0$0, Gamma_Cse0__5$0$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$0, R29), gamma_store64(Gamma_stack, Cse0__5$0$0, Gamma_R29); + assume {:captureState "1876$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$0, 8bv64), Gamma_R30); + assume {:captureState "1876$2"} true; + R31, Gamma_R31 := Cse0__5$0$0, Gamma_Cse0__5$0$0; + R29, Gamma_R29 := R31, Gamma_R31; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 1bv32), gamma_store32(Gamma_mem, R9_2, true); - call R0_1, Gamma_R0_1 := get_two(); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1896$0"} true; + R30, Gamma_R30 := 1904bv64, true; + call get_two(); goto $main$__1__$tJ_OTc5AS_~oGm8pJbb5Ew; $main$__1__$tJ_OTc5AS_~oGm8pJbb5Ew: + assume {:captureState "$main$__1__$tJ_OTc5AS_~oGm8pJbb5Ew"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - assert (L(mem, R8_3) ==> Gamma_R0_1); - mem, Gamma_mem := memory_store32_le(mem, R8_3, R0_1[32:0]), gamma_store32(Gamma_mem, R8_3, Gamma_R0_1); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assert (L(mem, R8) ==> Gamma_R0); + mem, Gamma_mem := memory_store32_le(mem, R8, R0[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R0); + assume {:captureState "1912$0"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out, R9_out := 0bv64, R29_3, R30_3, R31_in, R8_3, R9_2; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in, Gamma_R8_3, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } -procedure get_two() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1956bv64) == 1bv8); - free requires (memory_load8_le(mem, 1957bv64) == 0bv8); - free requires (memory_load8_le(mem, 1958bv64) == 2bv8); - free requires (memory_load8_le(mem, 1959bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); +procedure get_two(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1956bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - ensures (Gamma_R0_out == true); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + ensures (Gamma_R0 == true); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation get_two() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation get_two() { $get_two$__0__$FEI1g2gcQAqE4UEurbd17A: + assume {:captureState "$get_two$__0__$FEI1g2gcQAqE4UEurbd17A"} true; + R0, Gamma_R0 := 2bv64, true; goto get_two_basil_return; get_two_basil_return: - R0_out := 2bv64; - Gamma_R0_out := true; + assume {:captureState "get_two_basil_return"} true; return; } diff --git a/src/test/correct/function/gcc/function.expected b/src/test/correct/function/gcc/function.expected index 2b315b9b9..933d00e90 100644 --- a/src/test/correct/function/gcc/function.expected +++ b/src/test/correct/function/gcc/function.expected @@ -1,30 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,42 +30,35 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -77,8 +66,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -91,87 +80,91 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure get_two() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); +procedure get_two(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - ensures (Gamma_R0_out == true); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (Gamma_R0 == true); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation get_two() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation get_two() { lget_two: + assume {:captureState "lget_two"} true; + R0, Gamma_R0 := 2bv64, true; goto get_two_basil_return; get_two_basil_return: - R0_out := 2bv64; - Gamma_R0_out := true; + assume {:captureState "get_two_basil_return"} true; return; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R29, R30, R31, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R1_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var R0_3: bv64; - var R1_2: bv64; - var R29_3: bv64; - var R30_3: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000090b"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000911"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); - call R0_3, Gamma_R0_3 := get_two(); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000933"} true; + R30, Gamma_R30 := 1840bv64, true; + call get_two(); goto l00000946; l00000946: - R1_2, Gamma_R1_2 := zero_extend32_32(R0_3[32:0]), Gamma_R0_3; + assume {:captureState "l00000946"} true; + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, R1_2[32:0]), gamma_store32(Gamma_mem, 69656bv64, Gamma_R1_2); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000095d"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_2, R29_3, R30_3, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/function/gcc/function_gtirb.expected b/src/test/correct/function/gcc/function_gtirb.expected index 708a5e9b0..e1acd3896 100644 --- a/src/test/correct/function/gcc/function_gtirb.expected +++ b/src/test/correct/function/gcc/function_gtirb.expected @@ -1,30 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,42 +30,35 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -77,8 +66,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -91,87 +80,91 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure get_two() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); +procedure get_two(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - ensures (Gamma_R0_out == true); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (Gamma_R0 == true); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation get_two() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation get_two() { $get_two$__0__$lT8LeRkcS4eNr99yLhlABA: + assume {:captureState "$get_two$__0__$lT8LeRkcS4eNr99yLhlABA"} true; + R0, Gamma_R0 := 2bv64, true; goto get_two_basil_return; get_two_basil_return: - R0_out := 2bv64; - Gamma_R0_out := true; + assume {:captureState "get_two_basil_return"} true; return; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R29, R30, R31, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R1_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var R0_3: bv64; - var R1_2: bv64; - var R29_3: bv64; - var R30_3: bv64; + var Cse0__5$0$0: bv64; + var Gamma_Cse0__5$0$0: bool; $main$__0__$Hr_crFnzTBCWNR~lsvKo~A: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "$main$__0__$Hr_crFnzTBCWNR~lsvKo~A"} true; + Cse0__5$0$0, Gamma_Cse0__5$0$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$0, R29), gamma_store64(Gamma_stack, Cse0__5$0$0, Gamma_R29); + assume {:captureState "1812$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$0, 8bv64), Gamma_R30); + assume {:captureState "1812$2"} true; + R31, Gamma_R31 := Cse0__5$0$0, Gamma_Cse0__5$0$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); - call R0_3, Gamma_R0_3 := get_two(); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1832$0"} true; + R30, Gamma_R30 := 1840bv64, true; + call get_two(); goto $main$__1__$Js1exVANQd~fHOhEeBDuvw; $main$__1__$Js1exVANQd~fHOhEeBDuvw: - R1_2, Gamma_R1_2 := zero_extend32_32(R0_3[32:0]), Gamma_R0_3; + assume {:captureState "$main$__1__$Js1exVANQd~fHOhEeBDuvw"} true; + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, R1_2[32:0]), gamma_store32(Gamma_mem, 69656bv64, Gamma_R1_2); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1852$0"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_2, R29_3, R30_3, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/function/gcc_pic/function.expected b/src/test/correct/function/gcc_pic/function.expected index f202f43ac..cc6c7f4f6 100644 --- a/src/test/correct/function/gcc_pic/function.expected +++ b/src/test/correct/function/gcc_pic/function.expected @@ -1,30 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,53 +30,46 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -93,103 +82,101 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure get_two() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1960bv64) == 1bv8); - free requires (memory_load8_le(mem, 1961bv64) == 0bv8); - free requires (memory_load8_le(mem, 1962bv64) == 2bv8); - free requires (memory_load8_le(mem, 1963bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); +procedure get_two(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1960bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - ensures (Gamma_R0_out == true); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + ensures (Gamma_R0 == true); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation get_two() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation get_two() { lget_two: + assume {:captureState "lget_two"} true; + R0, Gamma_R0 := 2bv64, true; goto get_two_basil_return; get_two_basil_return: - R0_out := 2bv64; - Gamma_R0_out := true; + assume {:captureState "get_two_basil_return"} true; return; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R29, R30, R31, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1960bv64) == 1bv8); - free requires (memory_load8_le(mem, 1961bv64) == 0bv8); - free requires (memory_load8_le(mem, 1962bv64) == 2bv8); - free requires (memory_load8_le(mem, 1963bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1960bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R1_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var R0_2: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R1_2: bv64; - var R29_3: bv64; - var R30_3: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002f4"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002fa"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_2, 1bv32), gamma_store32(Gamma_mem, R0_2, true); - call R0_3, Gamma_R0_3 := get_two(); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000031d"} true; + R30, Gamma_R30 := 1904bv64, true; + call get_two(); goto l00000330; l00000330: - R1_2, Gamma_R1_2 := zero_extend32_32(R0_3[32:0]), Gamma_R0_3; + assume {:captureState "l00000330"} true; + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_2[32:0]), gamma_store32(Gamma_mem, R0_5, Gamma_R1_2); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000348"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_2, R29_3, R30_3, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/function/gcc_pic/function_gtirb.expected b/src/test/correct/function/gcc_pic/function_gtirb.expected index 6fe2752a9..70b62c99d 100644 --- a/src/test/correct/function/gcc_pic/function_gtirb.expected +++ b/src/test/correct/function/gcc_pic/function_gtirb.expected @@ -1,30 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -34,53 +30,46 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -93,103 +82,101 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R29, R30, R31, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $y_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1960bv64) == 1bv8); - free requires (memory_load8_le(mem, 1961bv64) == 0bv8); - free requires (memory_load8_le(mem, 1962bv64) == 2bv8); - free requires (memory_load8_le(mem, 1963bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1960bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R1_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var R0_2: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R1_2: bv64; - var R29_3: bv64; - var R30_3: bv64; + var Cse0__5$0$0: bv64; + var Gamma_Cse0__5$0$0: bool; $main$__0__$CDIUh9GHRvaZeUA_w4~N8g: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "$main$__0__$CDIUh9GHRvaZeUA_w4~N8g"} true; + Cse0__5$0$0, Gamma_Cse0__5$0$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$0, R29), gamma_store64(Gamma_stack, Cse0__5$0$0, Gamma_R29); + assume {:captureState "1876$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$0, 8bv64), Gamma_R30); + assume {:captureState "1876$2"} true; + R31, Gamma_R31 := Cse0__5$0$0, Gamma_Cse0__5$0$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_2, 1bv32), gamma_store32(Gamma_mem, R0_2, true); - call R0_3, Gamma_R0_3 := get_two(); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1896$0"} true; + R30, Gamma_R30 := 1904bv64, true; + call get_two(); goto $main$__1__$ILFoiTaWSQyMZ9c2qMX3nA; $main$__1__$ILFoiTaWSQyMZ9c2qMX3nA: - R1_2, Gamma_R1_2 := zero_extend32_32(R0_3[32:0]), Gamma_R0_3; + assume {:captureState "$main$__1__$ILFoiTaWSQyMZ9c2qMX3nA"} true; + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_2[32:0]), gamma_store32(Gamma_mem, R0_5, Gamma_R1_2); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1916$0"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_2, R29_3, R30_3, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } -procedure get_two() returns (R0_out: bv64, Gamma_R0_out: bool); - free requires (memory_load8_le(mem, 1960bv64) == 1bv8); - free requires (memory_load8_le(mem, 1961bv64) == 0bv8); - free requires (memory_load8_le(mem, 1962bv64) == 2bv8); - free requires (memory_load8_le(mem, 1963bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); +procedure get_two(); + modifies Gamma_R0, R0; + free requires (memory_load32_le(mem, 1960bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - ensures (Gamma_R0_out == true); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + ensures (Gamma_R0 == true); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation get_two() returns (R0_out: bv64, Gamma_R0_out: bool) +implementation get_two() { $get_two$__0__$3vTRMgrHQjWHoxnq48nf0w: + assume {:captureState "$get_two$__0__$3vTRMgrHQjWHoxnq48nf0w"} true; + R0, Gamma_R0 := 2bv64, true; goto get_two_basil_return; get_two_basil_return: - R0_out := 2bv64; - Gamma_R0_out := true; + assume {:captureState "get_two_basil_return"} true; return; } diff --git a/src/test/correct/function1/clang/function1.expected b/src/test/correct/function1/clang/function1.expected index e2f9fea24..458e75574 100644 --- a/src/test/correct/function1/clang/function1.expected +++ b/src/test/correct/function1/clang/function1.expected @@ -1,9 +1,25 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -12,26 +28,12 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69696bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -45,21 +47,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -73,15 +71,15 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "sign_extend 32"} sign_extend32_32(bv32) returns (bv64); @@ -89,8 +87,8 @@ function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2024bv64) == 2924859843805185bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); @@ -99,8 +97,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -113,52 +111,47 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure get_two(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; +procedure get_two(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_stack, R0, R31, R8, R9, stack; free requires (memory_load64_le(mem, 2024bv64) == 2924859843805185bv64); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1924bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2024bv64) == 2924859843805185bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1924bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation get_two(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation get_two() { - var Gamma_R0_2: bool; - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var R0_2: bv64; - var R8_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R9_1: bv32; - var R9_2: bv32; lget_two: - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R0_in[8:0]), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R1_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R1_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R2_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R2_in); - R8_1, Gamma_R8_1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); - R9_1, Gamma_R9_1 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - R9_2, Gamma_R9_2 := bvadd32(R8_1[32:0], R9_1), (Gamma_R9_1 && Gamma_R8_1); - R8_2, Gamma_R8_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R8_3, Gamma_R8_3 := bvadd64(R8_2, sign_extend32_32(R9_2)), (Gamma_R9_2 && Gamma_R8_2); - R0_2, Gamma_R0_2 := zero_extend32_32(R8_3[32:0]), Gamma_R8_3; + assume {:captureState "lget_two"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%00000336"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R1); + assume {:captureState "%0000033e"} true; + stack, Gamma_stack := memory_store64_le(stack, R31, R2), gamma_store64(Gamma_stack, R31, Gamma_R2); + assume {:captureState "%00000346"} true; + R8, Gamma_R8 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R9, Gamma_R9 := zero_extend32_32(bvadd32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); + R8, Gamma_R8 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R8, Gamma_R8 := bvadd64(R8, sign_extend32_32(R9[32:0])), (Gamma_R9 && Gamma_R8); + R0, Gamma_R0 := zero_extend32_32(R8[32:0]), Gamma_R8; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto get_two_basil_return; get_two_basil_return: - R0_out, R31_out := R0_2, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_2, Gamma_R31_in; + assume {:captureState "get_two_basil_return"} true; return; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R2, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R2, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69672bv64) == 0bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free requires (memory_load64_le(mem, 2024bv64) == 2924859843805185bv64); @@ -166,163 +159,70 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1924bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2024bv64) == 2924859843805185bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1924bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_5: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R2_4: bool; - var Gamma_R3: bool; - var Gamma_R30_4: bool; - var Gamma_R30_5: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8_3: bool; - var Gamma_R9_2: bool; - var R0_2: bv64; - var R0_5: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16: bv64; - var R16_1: bv64; - var R17: bv64; - var R17_1: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_2: bv64; - var R1_3: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R2_4: bv64; - var R3: bv64; - var R30_4: bv64; - var R30_5: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8_3: bv64; - var R9_2: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000386"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000038c"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69692bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, 1bv32), gamma_store32(Gamma_mem, 69692bv64, true); - call R0_2, Gamma_R0_2, R31_3, Gamma_R31_3 := get_two(97bv64, true, 10bv64, true, 10000000000bv64, true, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in); + assert (L(mem, bvadd64(R9, 60bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 60bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 60bv64), Gamma_R8); + assume {:captureState "%000003a8"} true; + R0, Gamma_R0 := 97bv64, true; + R1, Gamma_R1 := 10bv64, true; + R2, Gamma_R2 := 58368bv64, true; + R2, Gamma_R2 := (R2[64:32] ++ (21515bv16 ++ R2[16:0])), Gamma_R2; + R2, Gamma_R2 := (R2[64:48] ++ (2bv16 ++ R2[32:0])), Gamma_R2; + R30, Gamma_R30 := 1968bv64, true; + call get_two(); goto l000003ce; l000003ce: + assume {:captureState "l000003ce"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69696bv64) ==> Gamma_R0_2); - mem, Gamma_mem := memory_store32_le(mem, 69696bv64, R0_2[32:0]), gamma_store32(Gamma_mem, 69696bv64, Gamma_R0_2); + assert (L(mem, bvadd64(R8, 64bv64)) ==> Gamma_R0); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 64bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 64bv64), Gamma_R0); + assume {:captureState "%000003d9"} true; call rely(); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(mem, 69696bv64)), (gamma_load32(Gamma_mem, 69696bv64) || L(mem, 69696bv64)); - call R0_5, Gamma_R0_5, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_3, Gamma_R1_3, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_4, Gamma_R2_4, R30_4, Gamma_R30_4, R31_4, Gamma_R31_4, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_3, Gamma_R8_3, R9_2, Gamma_R9_2 := printf(2028bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1_2, Gamma_R1_2, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, 10000000000bv64, true, 1992bv64, true, R31_3, Gamma_R31_3, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, 69632bv64, true, 69632bv64, true); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 64bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 64bv64)) || L(mem, bvadd64(R8, 64bv64))); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2028bv64), Gamma_R0; + R30, Gamma_R30 := 1992bv64, true; + call printf(); goto l000003f5; l000003f5: - R29_4, Gamma_R29_4 := memory_load64_le(stack, R31_4), gamma_load64(Gamma_stack, R31_4); - R30_5, Gamma_R30_5 := memory_load64_le(stack, bvadd64(R31_4, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 8bv64)); + assume {:captureState "l000003f5"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R2_out, R30_out, R31_out, R8_out, R9_out := 0bv64, R1_3, R29_4, R2_4, R30_5, bvadd64(R31_4, 16bv64), R8_3, R9_2; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R1_3, Gamma_R29_4, Gamma_R2_4, Gamma_R30_5, Gamma_R31_4, Gamma_R8_3, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2024bv64) == 2924859843805185bv64); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); diff --git a/src/test/correct/function1/clang/function1_gtirb.expected b/src/test/correct/function1/clang/function1_gtirb.expected index 39a9fbb0e..c05abc07c 100644 --- a/src/test/correct/function1/clang/function1_gtirb.expected +++ b/src/test/correct/function1/clang/function1_gtirb.expected @@ -1,5 +1,25 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -8,26 +28,12 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69696bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +47,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,24 +71,24 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "sign_extend 32"} sign_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2024bv64) == 2924859843805185bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); @@ -95,8 +97,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -109,8 +111,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R2, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R2, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69672bv64) == 0bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free requires (memory_load64_le(mem, 2024bv64) == 2924859843805185bv64); @@ -118,58 +120,71 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1924bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2024bv64) == 2924859843805185bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1924bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var Gamma_R1_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_4: bool; - var Gamma_R31_3: bool; - var R0_2: bv64; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; - var R1_2: bv64; - var R29_3: bv64; - var R30_4: bv64; - var R31_3: bv64; + var Cse0__5$1$0: bv64; + var Gamma_Cse0__5$1$0: bool; $main$__0__$KJRMRffwQj~dxGE4yyDNOg: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "$main$__0__$KJRMRffwQj~dxGE4yyDNOg"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$0, R29), gamma_store64(Gamma_stack, Cse0__5$1$0, Gamma_R29); + assume {:captureState "1924$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$0, 8bv64), Gamma_R30); + assume {:captureState "1924$2"} true; + R31, Gamma_R31 := Cse0__5$1$0, Gamma_Cse0__5$1$0; + R29, Gamma_R29 := R31, Gamma_R31; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69692bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, 1bv32), gamma_store32(Gamma_mem, 69692bv64, true); - call R0_2, Gamma_R0_2, R31_3, Gamma_R31_3 := get_two(97bv64, true, 10bv64, true, 10000000000bv64, true, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in); + assert (L(mem, bvadd64(R9, 60bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 60bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 60bv64), Gamma_R8); + assume {:captureState "1940$0"} true; + R0, Gamma_R0 := 97bv64, true; + R1, Gamma_R1 := 10bv64, true; + R2, Gamma_R2 := 58368bv64, true; + R2, Gamma_R2 := (R2[64:32] ++ (21515bv16 ++ R2[16:0])), Gamma_R2; + R2, Gamma_R2 := (R2[64:48] ++ (2bv16 ++ R2[32:0])), Gamma_R2; + R30, Gamma_R30 := 1968bv64, true; + call get_two(); goto $main$__1__$YtzF~ruPSxeKxDQFuoMNCA; $main$__1__$YtzF~ruPSxeKxDQFuoMNCA: + assume {:captureState "$main$__1__$YtzF~ruPSxeKxDQFuoMNCA"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69696bv64) ==> Gamma_R0_2); - mem, Gamma_mem := memory_store32_le(mem, 69696bv64, R0_2[32:0]), gamma_store32(Gamma_mem, 69696bv64, Gamma_R0_2); + assert (L(mem, bvadd64(R8, 64bv64)) ==> Gamma_R0); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 64bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 64bv64), Gamma_R0); + assume {:captureState "1972$0"} true; call rely(); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(mem, 69696bv64)), (gamma_load32(Gamma_mem, 69696bv64) || L(mem, 69696bv64)); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_630(R16, Gamma_R16); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 64bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 64bv64)) || L(mem, bvadd64(R8, 64bv64))); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2028bv64), Gamma_R0; + R30, Gamma_R30 := 1992bv64, true; + call FUN_630(); goto $main$__2__$CEYnN9k9SmuiVVhWQDVk8Q; $main$__2__$CEYnN9k9SmuiVVhWQDVk8Q: - R29_3, Gamma_R29_3 := memory_load64_le(stack, R31_3), gamma_load64(Gamma_stack, R31_3); - R30_4, Gamma_R30_4 := memory_load64_le(stack, bvadd64(R31_3, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 8bv64)); + assume {:captureState "$main$__2__$CEYnN9k9SmuiVVhWQDVk8Q"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R2_out, R30_out, R31_out, R8_out, R9_out := 0bv64, R1_2, R29_3, 10000000000bv64, R30_4, bvadd64(R31_3, 16bv64), 69632bv64, 69632bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R1_2, Gamma_R29_3, true, Gamma_R30_4, Gamma_R31_3, true, true; + assume {:captureState "main_basil_return"} true; return; } -procedure FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_630(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2024bv64) == 2924859843805185bv64); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); @@ -181,186 +196,58 @@ procedure FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 1924bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_630() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_630$__0__$NZBDTAx8S7uixhiUTM36gA: + assume {:captureState "$FUN_630$__0__$NZBDTAx8S7uixhiUTM36gA"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69664bv64), (gamma_load64(Gamma_mem, 69664bv64) || L(mem, 69664bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69664bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 32bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 32bv64)) || L(mem, bvadd64(R16, 32bv64))); + R16, Gamma_R16 := bvadd64(R16, 32bv64), Gamma_R16; + call printf(); assume false; } -procedure get_two(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; +procedure get_two(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_stack, R0, R31, R8, R9, stack; free requires (memory_load64_le(mem, 2024bv64) == 2924859843805185bv64); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1924bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2024bv64) == 2924859843805185bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1924bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation get_two(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation get_two() { - var Gamma_R0_2: bool; - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var R0_2: bv64; - var R8_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R9_1: bv32; - var R9_2: bv32; $get_two$__0__$p4Q_YT4qRRGcIyXB48MM3g: - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R0_in[8:0]), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R1_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R1_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R2_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R2_in); - R8_1, Gamma_R8_1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); - R9_1, Gamma_R9_1 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - R9_2, Gamma_R9_2 := bvadd32(R8_1[32:0], R9_1), (Gamma_R9_1 && Gamma_R8_1); - R8_2, Gamma_R8_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R8_3, Gamma_R8_3 := bvadd64(R8_2, sign_extend32_32(R9_2)), (Gamma_R9_2 && Gamma_R8_2); - R0_2, Gamma_R0_2 := zero_extend32_32(R8_3[32:0]), Gamma_R8_3; + assume {:captureState "$get_two$__0__$p4Q_YT4qRRGcIyXB48MM3g"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "1880$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R1); + assume {:captureState "1884$0"} true; + stack, Gamma_stack := memory_store64_le(stack, R31, R2), gamma_store64(Gamma_stack, R31, Gamma_R2); + assume {:captureState "1888$0"} true; + R8, Gamma_R8 := zero_extend32_32(zero_extend24_8(memory_load8_le(stack, bvadd64(R31, 15bv64)))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R9, Gamma_R9 := zero_extend32_32(bvadd32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); + R8, Gamma_R8 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R8, Gamma_R8 := bvadd64(R8, sign_extend32_32(R9[32:0])), (Gamma_R9 && Gamma_R8); + R0, Gamma_R0 := zero_extend32_32(R8[32:0]), Gamma_R8; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto get_two_basil_return; get_two_basil_return: - R0_out, R31_out := R0_2, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_2, Gamma_R31_in; + assume {:captureState "get_two_basil_return"} true; return; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load64_le(mem, 2024bv64) == 2924859843805185bv64); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); diff --git a/src/test/correct/function1/clang_O2/function1.expected b/src/test/correct/function1/clang_O2/function1.expected index 1fefaaefe..07be739dc 100644 --- a/src/test/correct/function1/clang_O2/function1.expected +++ b/src/test/correct/function1/clang_O2/function1.expected @@ -1,9 +1,27 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -12,39 +30,21 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69696bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { @@ -52,17 +52,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 1976bv64) == 2924859843805185bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); @@ -71,8 +72,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -85,8 +86,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R10, Gamma_R11, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R10, R11, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69672bv64) == 0bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free requires (memory_load64_le(mem, 1976bv64) == 2924859843805185bv64); @@ -94,150 +95,62 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1888bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 1976bv64) == 2924859843805185bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1888bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R10_2: bool; - var Gamma_R11_3: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_3: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30_3: bool; - var Gamma_R30_4: bool; - var Gamma_R31_3: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8_2: bool; - var Gamma_R9_2: bool; - var R0_3: bv64; - var R10_2: bv64; - var R11_3: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16: bv64; - var R16_1: bv64; - var R17: bv64; - var R17_1: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_3: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R2_1: bv64; - var R3: bv64; - var R30_3: bv64; - var R30_4: bv64; - var R31_3: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8_2: bv64; - var R9_2: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000317"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000031d"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R11, Gamma_R11 := 58475bv64, true; + R1, Gamma_R1 := 58475bv64, true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 1bv64, true; + R10, Gamma_R10 := 69632bv64, true; + R11, Gamma_R11 := zero_extend32_32((21515bv16 ++ R11[16:0])), Gamma_R11; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 1980bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32((21515bv16 ++ R1[16:0])), Gamma_R1; call rely(); - assert (L(mem, 69692bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, 1bv32), gamma_store32(Gamma_mem, 69692bv64, true); + assert (L(mem, bvadd64(R8, 60bv64)) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), Gamma_R9); + assume {:captureState "%0000035f"} true; call rely(); - assert (L(mem, 69696bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69696bv64, 1410065515bv32), gamma_store32(Gamma_mem, 69696bv64, true); - call R0_3, Gamma_R0_3, R10_2, Gamma_R10_2, R11_3, Gamma_R11_3, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_3, Gamma_R1_3, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2 := printf(1980bv64, true, 69632bv64, true, 1410065515bv64, true, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, 1410065515bv64, true, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, R2, Gamma_R2, 1944bv64, true, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, 69632bv64, true, 1bv64, true); + assert (L(mem, bvadd64(R10, 64bv64)) ==> Gamma_R11); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 64bv64), R11[32:0]), gamma_store32(Gamma_mem, bvadd64(R10, 64bv64), Gamma_R11); + assume {:captureState "%00000367"} true; + R30, Gamma_R30 := 1944bv64, true; + call printf(); goto l00000371; l00000371: - R29_4, Gamma_R29_4 := memory_load64_le(stack, R31_3), gamma_load64(Gamma_stack, R31_3); - R30_4, Gamma_R30_4 := memory_load64_le(stack, bvadd64(R31_3, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 8bv64)); + assume {:captureState "l00000371"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R1_out, R29_out, R30_out, R31_out, R8_out, R9_out := 0bv64, R10_2, R11_3, R1_3, R29_4, R30_4, bvadd64(R31_3, 16bv64), R8_2, R9_2; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_2, Gamma_R11_3, Gamma_R1_3, Gamma_R29_4, Gamma_R30_4, Gamma_R31_3, Gamma_R8_2, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 1976bv64) == 2924859843805185bv64); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); diff --git a/src/test/correct/function1/clang_O2/function1_gtirb.expected b/src/test/correct/function1/clang_O2/function1_gtirb.expected index 46f8db85d..15b52ffe0 100644 --- a/src/test/correct/function1/clang_O2/function1_gtirb.expected +++ b/src/test/correct/function1/clang_O2/function1_gtirb.expected @@ -1,5 +1,27 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -8,39 +30,21 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69696bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { @@ -48,17 +52,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 1976bv64) == 2924859843805185bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); @@ -67,8 +72,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -81,8 +86,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_630(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 1976bv64) == 2924859843805185bv64); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); @@ -94,143 +99,20 @@ procedure FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 1888bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_630() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_630$__0__$9vg7iWSEQm2cjmXfKr4x1g: + assume {:captureState "$FUN_630$__0__$9vg7iWSEQm2cjmXfKr4x1g"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69664bv64), (gamma_load64(Gamma_mem, 69664bv64) || L(mem, 69664bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69664bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 32bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 32bv64)) || L(mem, bvadd64(R16, 32bv64))); + R16, Gamma_R16 := bvadd64(R16, 32bv64), Gamma_R16; + call printf(); assume false; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R10, Gamma_R11, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R10, R11, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69672bv64) == 0bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free requires (memory_load64_le(mem, 1976bv64) == 2924859843805185bv64); @@ -238,46 +120,62 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1888bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 1976bv64) == 2924859843805185bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1888bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; - var R29_3: bv64; - var R30_3: bv64; + var Cse0__5$1$0: bv64; + var Gamma_Cse0__5$1$0: bool; $main$__0__$~V6GfTEGRo6iegWvB8u~Ng: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "$main$__0__$~V6GfTEGRo6iegWvB8u~Ng"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$0, R29), gamma_store64(Gamma_stack, Cse0__5$1$0, Gamma_R29); + assume {:captureState "1888$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$0, 8bv64), Gamma_R30); + assume {:captureState "1888$2"} true; + R31, Gamma_R31 := Cse0__5$1$0, Gamma_Cse0__5$1$0; + R29, Gamma_R29 := R31, Gamma_R31; + R11, Gamma_R11 := 58475bv64, true; + R1, Gamma_R1 := 58475bv64, true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 1bv64, true; + R10, Gamma_R10 := 69632bv64, true; + R11, Gamma_R11 := zero_extend32_32((21515bv16 ++ R11[16:0])), Gamma_R11; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 1980bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32((21515bv16 ++ R1[16:0])), Gamma_R1; call rely(); - assert (L(mem, 69692bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, 1bv32), gamma_store32(Gamma_mem, 69692bv64, true); + assert (L(mem, bvadd64(R8, 60bv64)) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), Gamma_R9); + assume {:captureState "1932$0"} true; call rely(); - assert (L(mem, 69696bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69696bv64, 1410065515bv32), gamma_store32(Gamma_mem, 69696bv64, true); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_630(R16, Gamma_R16); + assert (L(mem, bvadd64(R10, 64bv64)) ==> Gamma_R11); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 64bv64), R11[32:0]), gamma_store32(Gamma_mem, bvadd64(R10, 64bv64), Gamma_R11); + assume {:captureState "1936$0"} true; + R30, Gamma_R30 := 1944bv64, true; + call FUN_630(); goto $main$__1__$FJjmKBZVSk~WIQ57oU6MUA; $main$__1__$FJjmKBZVSk~WIQ57oU6MUA: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__1__$FJjmKBZVSk~WIQ57oU6MUA"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R16_out, R17_out, R1_out, R29_out, R30_out, R31_out, R8_out, R9_out := 0bv64, 69632bv64, 1410065515bv64, R16_1, R17_1, 1410065515bv64, R29_3, R30_3, R31_in, 69632bv64, 1bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R16_out, Gamma_R17_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, true, true, Gamma_R16_1, Gamma_R17_1, true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in, true, true; + assume {:captureState "main_basil_return"} true; return; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load64_le(mem, 1976bv64) == 2924859843805185bv64); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); diff --git a/src/test/correct/function1/gcc/function1.expected b/src/test/correct/function1/gcc/function1.expected index 8243e2531..7679162c5 100644 --- a/src/test/correct/function1/gcc/function1.expected +++ b/src/test/correct/function1/gcc/function1.expected @@ -1,9 +1,21 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -12,26 +24,12 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -45,21 +43,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -73,23 +67,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load8_le(mem, 2056bv64) == 37bv8); free ensures (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -102,8 +96,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -116,8 +110,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure get_two(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; +procedure get_two(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_stack, R0, R1, R31, stack; free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); free requires (memory_load8_le(mem, 2056bv64) == 37bv8); free requires (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -127,6 +121,8 @@ procedure get_two(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1924bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load8_le(mem, 2056bv64) == 37bv8); free ensures (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -137,39 +133,32 @@ procedure get_two(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool free ensures (memory_load64_le(mem, 69616bv64) == 1924bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation get_two(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation get_two() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var R0_2: bv32; - var R0_3: bv32; - var R0_4: bv64; - var R0_5: bv64; - var R1_2: bv64; - var R1_3: bv32; lget_two: - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R0_in[8:0]), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R1_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R1_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R2_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R2_in); - R1_2, Gamma_R1_2 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); - R0_2, Gamma_R0_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - R0_3, Gamma_R0_3 := bvadd32(R1_2[32:0], R0_2), (Gamma_R0_2 && Gamma_R1_2); - R1_3, Gamma_R1_3 := R0_3, Gamma_R0_3; - R0_4, Gamma_R0_4 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R0_5, Gamma_R0_5 := zero_extend32_32(bvadd32(R1_3, R0_4[32:0])), (Gamma_R0_4 && Gamma_R1_3); + assume {:captureState "lget_two"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%0000034e"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R1); + assume {:captureState "%00000356"} true; + stack, Gamma_stack := memory_store64_le(stack, R31, R2), gamma_store64(Gamma_stack, R31, Gamma_R2); + assume {:captureState "%0000035e"} true; + R1, Gamma_R1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto get_two_basil_return; get_two_basil_return: - R0_out, R31_out := R0_5, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_5, Gamma_R31_in; + assume {:captureState "get_two_basil_return"} true; return; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R2, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R2, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); @@ -181,6 +170,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1924bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load8_le(mem, 2056bv64) == 37bv8); free ensures (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -191,167 +184,66 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 1924bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_12: bool; - var Gamma_R0_4: bool; - var Gamma_R0_9: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R2_4: bool; - var Gamma_R3: bool; - var Gamma_R30_4: bool; - var Gamma_R30_5: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0_12: bv64; - var R0_4: bv64; - var R0_9: bv32; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16: bv64; - var R16_1: bv64; - var R17: bv64; - var R17_1: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_3: bv32; - var R1_4: bv64; - var R1_5: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R2_4: bv64; - var R3: bv64; - var R30_4: bv64; - var R30_5: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000039e"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000003a4"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); - call R0_4, Gamma_R0_4, R31_3, Gamma_R31_3 := get_two(97bv64, true, 10bv64, true, 10000000000bv64, true, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003c6"} true; + R2, Gamma_R2 := 58368bv64, true; + R2, Gamma_R2 := (R2[64:32] ++ (21515bv16 ++ R2[16:0])), Gamma_R2; + R2, Gamma_R2 := (R2[64:48] ++ (2bv16 ++ R2[32:0])), Gamma_R2; + R1, Gamma_R1 := 10bv64, true; + R0, Gamma_R0 := 97bv64, true; + R30, Gamma_R30 := 1972bv64, true; + call get_two(); goto l000003ec; l000003ec: - R1_3, Gamma_R1_3 := R0_4[32:0], Gamma_R0_4; + assume {:captureState "l000003ec"} true; + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R1_3); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, R1_3), gamma_store32(Gamma_mem, 69656bv64, Gamma_R1_3); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000403"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_9, Gamma_R0_9 := memory_load32_le(mem, 69656bv64), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - R1_4, Gamma_R1_4 := zero_extend32_32(R0_9), Gamma_R0_9; - call R0_12, Gamma_R0_12, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_5, Gamma_R1_5, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_4, Gamma_R2_4, R30_4, Gamma_R30_4, R31_4, Gamma_R31_4, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(2056bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1_4, Gamma_R1_4, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, 10000000000bv64, true, 2016bv64, true, R31_3, Gamma_R31_3, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2056bv64), Gamma_R0; + R30, Gamma_R30 := 2016bv64, true; + call printf(); goto l00000430; l00000430: - R29_4, Gamma_R29_4 := memory_load64_le(stack, R31_4), gamma_load64(Gamma_stack, R31_4); - R30_5, Gamma_R30_5 := memory_load64_le(stack, bvadd64(R31_4, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 8bv64)); + assume {:captureState "l00000430"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R2_out, R30_out, R31_out := 0bv64, R1_5, R29_4, R2_4, R30_5, bvadd64(R31_4, 16bv64); - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_5, Gamma_R29_4, Gamma_R2_4, Gamma_R30_5, Gamma_R31_4; + assume {:captureState "main_basil_return"} true; return; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); free requires (memory_load8_le(mem, 2056bv64) == 37bv8); diff --git a/src/test/correct/function1/gcc/function1_gtirb.expected b/src/test/correct/function1/gcc/function1_gtirb.expected index 360c408af..7c618985e 100644 --- a/src/test/correct/function1/gcc/function1_gtirb.expected +++ b/src/test/correct/function1/gcc/function1_gtirb.expected @@ -1,5 +1,21 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -8,26 +24,12 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +43,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,23 +67,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load8_le(mem, 2056bv64) == 37bv8); free ensures (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -98,8 +96,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -112,8 +110,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_630(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); free requires (memory_load8_le(mem, 2056bv64) == 37bv8); free requires (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -133,143 +131,20 @@ procedure FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 1924bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_630() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_630$__0__$NUvwqOE3TwyanEIZ0P7t5g: + assume {:captureState "$FUN_630$__0__$NUvwqOE3TwyanEIZ0P7t5g"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69576bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4040bv64)) || L(mem, bvadd64(R16, 4040bv64))); + R16, Gamma_R16 := bvadd64(R16, 4040bv64), Gamma_R16; + call printf(); assume false; } -procedure get_two(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; +procedure get_two(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_stack, R0, R1, R31, stack; free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); free requires (memory_load8_le(mem, 2056bv64) == 37bv8); free requires (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -279,6 +154,8 @@ procedure get_two(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1924bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load8_le(mem, 2056bv64) == 37bv8); free ensures (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -289,39 +166,32 @@ procedure get_two(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool free ensures (memory_load64_le(mem, 69616bv64) == 1924bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation get_two(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation get_two() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var R0_2: bv32; - var R0_3: bv32; - var R0_4: bv64; - var R0_5: bv64; - var R1_2: bv64; - var R1_3: bv32; $get_two$__0__$lkvQp5JbQXmQ~jsXqPsRSw: - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R0_in[8:0]), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R1_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R1_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R2_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R2_in); - R1_2, Gamma_R1_2 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); - R0_2, Gamma_R0_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - R0_3, Gamma_R0_3 := bvadd32(R1_2[32:0], R0_2), (Gamma_R0_2 && Gamma_R1_2); - R1_3, Gamma_R1_3 := R0_3, Gamma_R0_3; - R0_4, Gamma_R0_4 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R0_5, Gamma_R0_5 := zero_extend32_32(bvadd32(R1_3, R0_4[32:0])), (Gamma_R0_4 && Gamma_R1_3); + assume {:captureState "$get_two$__0__$lkvQp5JbQXmQ~jsXqPsRSw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "1880$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R1); + assume {:captureState "1884$0"} true; + stack, Gamma_stack := memory_store64_le(stack, R31, R2), gamma_store64(Gamma_stack, R31, Gamma_R2); + assume {:captureState "1888$0"} true; + R1, Gamma_R1 := zero_extend32_32(zero_extend24_8(memory_load8_le(stack, bvadd64(R31, 15bv64)))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto get_two_basil_return; get_two_basil_return: - R0_out, R31_out := R0_5, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_5, Gamma_R31_in; + assume {:captureState "get_two_basil_return"} true; return; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R2, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R2, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); @@ -333,6 +203,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1924bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load8_le(mem, 2056bv64) == 37bv8); free ensures (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -343,57 +217,66 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 1924bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_4: bool; - var Gamma_R0_9: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; - var Gamma_R29_3: bool; - var Gamma_R30_4: bool; - var Gamma_R31_3: bool; - var R0_4: bv64; - var R0_9: bv32; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; - var R1_3: bv32; - var R1_4: bv64; - var R29_3: bv64; - var R30_4: bv64; - var R31_3: bv64; + var Cse0__5$0$0: bv64; + var Gamma_Cse0__5$0$0: bool; $main$__0__$esMR8CLvRH6F_3cHhuaI0Q: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "$main$__0__$esMR8CLvRH6F_3cHhuaI0Q"} true; + Cse0__5$0$0, Gamma_Cse0__5$0$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$0, R29), gamma_store64(Gamma_stack, Cse0__5$0$0, Gamma_R29); + assume {:captureState "1924$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$0, 8bv64), Gamma_R30); + assume {:captureState "1924$2"} true; + R31, Gamma_R31 := Cse0__5$0$0, Gamma_Cse0__5$0$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); - call R0_4, Gamma_R0_4, R31_3, Gamma_R31_3 := get_two(97bv64, true, 10bv64, true, 10000000000bv64, true, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1944$0"} true; + R2, Gamma_R2 := 58368bv64, true; + R2, Gamma_R2 := (R2[64:32] ++ (21515bv16 ++ R2[16:0])), Gamma_R2; + R2, Gamma_R2 := (R2[64:48] ++ (2bv16 ++ R2[32:0])), Gamma_R2; + R1, Gamma_R1 := 10bv64, true; + R0, Gamma_R0 := 97bv64, true; + R30, Gamma_R30 := 1972bv64, true; + call get_two(); goto $main$__1__$zo98bL2YRTak5~76VWgMlQ; $main$__1__$zo98bL2YRTak5~76VWgMlQ: - R1_3, Gamma_R1_3 := R0_4[32:0], Gamma_R0_4; + assume {:captureState "$main$__1__$zo98bL2YRTak5~76VWgMlQ"} true; + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R1_3); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, R1_3), gamma_store32(Gamma_mem, 69656bv64, Gamma_R1_3); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1984$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_9, Gamma_R0_9 := memory_load32_le(mem, 69656bv64), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - R1_4, Gamma_R1_4 := zero_extend32_32(R0_9), Gamma_R0_9; - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_630(R16, Gamma_R16); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2056bv64), Gamma_R0; + R30, Gamma_R30 := 2016bv64, true; + call FUN_630(); goto $main$__2__$gcXQRbmQRZq8EOqfqswOIw; $main$__2__$gcXQRbmQRZq8EOqfqswOIw: - R29_3, Gamma_R29_3 := memory_load64_le(stack, R31_3), gamma_load64(Gamma_stack, R31_3); - R30_4, Gamma_R30_4 := memory_load64_le(stack, bvadd64(R31_3, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 8bv64)); + assume {:captureState "$main$__2__$gcXQRbmQRZq8EOqfqswOIw"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R1_out, R29_out, R2_out, R30_out, R31_out := 0bv64, R16_1, R17_1, R1_4, R29_3, 10000000000bv64, R30_4, bvadd64(R31_3, 16bv64); - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R1_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R16_1, Gamma_R17_1, Gamma_R1_4, Gamma_R29_3, true, Gamma_R30_4, Gamma_R31_3; + assume {:captureState "main_basil_return"} true; return; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); free requires (memory_load8_le(mem, 2056bv64) == 37bv8); free requires (memory_load8_le(mem, 2057bv64) == 100bv8); diff --git a/src/test/correct/function1/gcc_O2/function1.expected b/src/test/correct/function1/gcc_O2/function1.expected index 0f8e03fbf..d2d1638ca 100644 --- a/src/test/correct/function1/gcc_O2/function1.expected +++ b/src/test/correct/function1/gcc_O2/function1.expected @@ -1,9 +1,23 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R3: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -12,39 +26,21 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { @@ -56,17 +52,18 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load8_le(mem, 2056bv64) == 37bv8); free ensures (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -79,8 +76,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -93,7 +90,7 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure __printf_chk(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure __printf_chk(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); free requires (memory_load8_le(mem, 2056bv64) == 37bv8); @@ -114,8 +111,8 @@ procedure __printf_chk(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_i free ensures (memory_load64_le(mem, 69616bv64) == 1664bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R2, Gamma_R29, Gamma_R3, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R2, R29, R3, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); @@ -127,6 +124,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69016bv64) == 1920bv64); free requires (memory_load64_le(mem, 69616bv64) == 1664bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load8_le(mem, 2056bv64) == 37bv8); free ensures (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -137,144 +138,46 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 1664bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_4: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R2_3: bool; - var Gamma_R30_3: bool; - var Gamma_R30_4: bool; - var Gamma_R31_3: bool; - var Gamma_R3_2: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0_2: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16: bv64; - var R16_1: bv64; - var R17: bv64; - var R17_1: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_4: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R2_3: bv64; - var R30_3: bv64; - var R30_4: bv64; - var R31_3: bv64; - var R3_2: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; + var #1: bv64; + var Gamma_#1: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "lmain"} true; + #1, Gamma_#1 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #1, R29), gamma_store64(Gamma_stack, #1, Gamma_R29); + assume {:captureState "%000001ca"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#1, 8bv64), Gamma_R30); + assume {:captureState "%000001d0"} true; + R31, Gamma_R31 := #1, Gamma_#1; + R1, Gamma_R1 := 69632bv64, true; + R3, Gamma_R3 := bvadd64(R1, 20bv64), Gamma_R1; + R29, Gamma_R29 := R31, Gamma_R31; + R2, Gamma_R2 := 58475bv64, true; + R2, Gamma_R2 := zero_extend32_32((21515bv16 ++ R2[16:0])), Gamma_R2; + R0, Gamma_R0 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R0); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R0); + assume {:captureState "%000001fd"} true; + R1, Gamma_R1 := 0bv64, true; + R1, Gamma_R1 := bvadd64(R1, 2056bv64), Gamma_R1; call rely(); - assert (L(mem, 69656bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 1410065515bv32), gamma_store32(Gamma_mem, 69656bv64, true); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_4, Gamma_R1_4, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_3, Gamma_R2_3, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_2, Gamma_R3_2, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := __printf_chk(1bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, 2056bv64, true, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, 1410065515bv64, true, 1712bv64, true, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, 69652bv64, true, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + assert (L(mem, bvadd64(R3, 4bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R3, 4bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R3, 4bv64), Gamma_R2); + assume {:captureState "%00000210"} true; + R30, Gamma_R30 := 1712bv64, true; + call __printf_chk(); goto l0000021a; l0000021a: - R29_4, Gamma_R29_4 := memory_load64_le(stack, R31_3), gamma_load64(Gamma_stack, R31_3); - R30_4, Gamma_R30_4 := memory_load64_le(stack, bvadd64(R31_3, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 8bv64)); + assume {:captureState "l0000021a"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R2_out, R30_out, R31_out, R3_out := 0bv64, R1_4, R29_4, R2_3, R30_4, bvadd64(R31_3, 16bv64), R3_2; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out, Gamma_R3_out := true, Gamma_R1_4, Gamma_R29_4, Gamma_R2_3, Gamma_R30_4, Gamma_R31_3, Gamma_R3_2; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/function1/gcc_O2/function1_gtirb.expected b/src/test/correct/function1/gcc_O2/function1_gtirb.expected index 3bc2fc907..65932f0f8 100644 --- a/src/test/correct/function1/gcc_O2/function1_gtirb.expected +++ b/src/test/correct/function1/gcc_O2/function1_gtirb.expected @@ -1,5 +1,23 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R3: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -8,39 +26,21 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { @@ -52,17 +52,18 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load8_le(mem, 2056bv64) == 37bv8); free ensures (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -75,8 +76,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -89,8 +90,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R2, Gamma_R29, Gamma_R3, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R2, R29, R3, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); @@ -102,6 +103,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69016bv64) == 1920bv64); free requires (memory_load64_le(mem, 69616bv64) == 1664bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load8_le(mem, 2056bv64) == 37bv8); free ensures (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -112,41 +117,51 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 1664bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool) +implementation main() { - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; - var R29_3: bv64; - var R30_3: bv64; + var Cse0__5$0$0: bv64; + var Gamma_Cse0__5$0$0: bool; $main$__0__$SdgQNRc1S~eXoTDCYKgVbQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "$main$__0__$SdgQNRc1S~eXoTDCYKgVbQ"} true; + Cse0__5$0$0, Gamma_Cse0__5$0$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$0, R29), gamma_store64(Gamma_stack, Cse0__5$0$0, Gamma_R29); + assume {:captureState "1664$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$0, 8bv64), Gamma_R30); + assume {:captureState "1664$2"} true; + R31, Gamma_R31 := Cse0__5$0$0, Gamma_Cse0__5$0$0; + R1, Gamma_R1 := 69632bv64, true; + R3, Gamma_R3 := bvadd64(R1, 20bv64), Gamma_R1; + R29, Gamma_R29 := R31, Gamma_R31; + R2, Gamma_R2 := 58475bv64, true; + R2, Gamma_R2 := zero_extend32_32((21515bv16 ++ R2[16:0])), Gamma_R2; + R0, Gamma_R0 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R0); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R0); + assume {:captureState "1692$0"} true; + R1, Gamma_R1 := 0bv64, true; + R1, Gamma_R1 := bvadd64(R1, 2056bv64), Gamma_R1; call rely(); - assert (L(mem, 69656bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 1410065515bv32), gamma_store32(Gamma_mem, 69656bv64, true); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_620(R16, Gamma_R16); + assert (L(mem, bvadd64(R3, 4bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R3, 4bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R3, 4bv64), Gamma_R2); + assume {:captureState "1704$0"} true; + R30, Gamma_R30 := 1712bv64, true; + call FUN_620(); goto $main$__1__$jvvJx~HNQlaw7eS3PvnGyQ; $main$__1__$jvvJx~HNQlaw7eS3PvnGyQ: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__1__$jvvJx~HNQlaw7eS3PvnGyQ"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R2_out, R30_out, R31_out, R3_out := 0bv64, 2056bv64, R29_3, 1410065515bv64, R30_3, R31_in, 69652bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out, Gamma_R3_out := true, true, Gamma_R29_3, true, Gamma_R30_3, Gamma_R31_in, true; + assume {:captureState "main_basil_return"} true; return; } -procedure FUN_620(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_620(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); free requires (memory_load8_le(mem, 2056bv64) == 37bv8); free requires (memory_load8_le(mem, 2057bv64) == 100bv8); @@ -166,142 +181,19 @@ procedure FUN_620(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 1664bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_620(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_620() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_620$__0__$FzaZGObNRFyyU87ZY5JbcQ: + assume {:captureState "$FUN_620$__0__$FzaZGObNRFyyU87ZY5JbcQ"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69560bv64), (gamma_load64(Gamma_mem, 69560bv64) || L(mem, 69560bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := __printf_chk(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69560bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4024bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4024bv64)) || L(mem, bvadd64(R16, 4024bv64))); + R16, Gamma_R16 := bvadd64(R16, 4024bv64), Gamma_R16; + call __printf_chk(); assume false; } -procedure __printf_chk(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure __printf_chk(); free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); free requires (memory_load8_le(mem, 2056bv64) == 37bv8); free requires (memory_load8_le(mem, 2057bv64) == 100bv8); diff --git a/src/test/correct/functionpointer/clang/functionpointer_gtirb.expected b/src/test/correct/functionpointer/clang/functionpointer_gtirb.expected index 3695be6a5..291e95a84 100644 --- a/src/test/correct/functionpointer/clang/functionpointer_gtirb.expected +++ b/src/test/correct/functionpointer/clang/functionpointer_gtirb.expected @@ -1,26 +1,37 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -30,15 +41,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -49,26 +56,22 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1860bv64); @@ -76,8 +79,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -91,19 +94,13 @@ procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure set_seven(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2052bv64) == 1bv8); - free requires (memory_load8_le(mem, 2053bv64) == 0bv8); - free requires (memory_load8_le(mem, 2054bv64) == 2bv8); - free requires (memory_load8_le(mem, 2055bv64) == 0bv8); + modifies Gamma_R8, Gamma_R9, Gamma_mem, R8, R9, mem; + free requires (memory_load32_le(mem, 2052bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1860bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1860bv64); @@ -112,28 +109,27 @@ procedure set_seven(); implementation set_seven() { $set_seven$__0__$GYdDLawJSPSwhQJx8RNe6g: + assume {:captureState "$set_seven$__0__$GYdDLawJSPSwhQJx8RNe6g"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 7bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 7bv32), gamma_store32(Gamma_mem, 69684bv64, true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "1852$0"} true; goto set_seven_basil_return; set_seven_basil_return: + assume {:captureState "set_seven_basil_return"} true; return; } procedure set_six(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2052bv64) == 1bv8); - free requires (memory_load8_le(mem, 2053bv64) == 0bv8); - free requires (memory_load8_le(mem, 2054bv64) == 2bv8); - free requires (memory_load8_le(mem, 2055bv64) == 0bv8); + modifies Gamma_R8, Gamma_R9, Gamma_mem, R8, R9, mem; + free requires (memory_load32_le(mem, 2052bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1860bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1860bv64); @@ -142,28 +138,27 @@ procedure set_six(); implementation set_six() { $set_six$__0__$TW~TmrKcRPK8KwdrX6QBgg: + assume {:captureState "$set_six$__0__$TW~TmrKcRPK8KwdrX6QBgg"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 6bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 6bv32), gamma_store32(Gamma_mem, 69684bv64, true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "1836$0"} true; goto set_six_basil_return; set_six_basil_return: + assume {:captureState "set_six_basil_return"} true; return; } procedure set_two(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2052bv64) == 1bv8); - free requires (memory_load8_le(mem, 2053bv64) == 0bv8); - free requires (memory_load8_le(mem, 2054bv64) == 2bv8); - free requires (memory_load8_le(mem, 2055bv64) == 0bv8); + modifies Gamma_R8, Gamma_R9, Gamma_mem, R8, R9, mem; + free requires (memory_load32_le(mem, 2052bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1860bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1860bv64); @@ -172,187 +167,224 @@ procedure set_two(); implementation set_two() { $set_two$__0__$ZGCFxZYOSZCYCnRYI0pW4w: + assume {:captureState "$set_two$__0__$ZGCFxZYOSZCYCnRYI0pW4w"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 2bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 2bv32), gamma_store32(Gamma_mem, 69684bv64, true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "1820$0"} true; goto set_two_basil_return; set_two_basil_return: + assume {:captureState "set_two_basil_return"} true; return; } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == true); +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R29, R30, R31, R8, R9, VF, ZF, mem, stack; + requires (Gamma_R0 == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 2052bv64) == 1bv8); - free requires (memory_load8_le(mem, 2053bv64) == 0bv8); - free requires (memory_load8_le(mem, 2054bv64) == 2bv8); - free requires (memory_load8_le(mem, 2055bv64) == 0bv8); + free requires (memory_load32_le(mem, 2052bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1860bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1860bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var Gamma_R8_1: bool; - var Gamma_R8_14: bool; - var Gamma_R8_15: bool; - var Gamma_R8_21: bool; - var Gamma_R8_24: bool; - var Gamma_R8_27: bool; - var Gamma_R8_30: bool; - var Gamma_R8_33: bool; - var Gamma_R8_7: bool; - var Gamma_R8_8: bool; - var Gamma_R9: bool; - var R29_3: bv64; - var R30_3: bv64; - var R8_1: bv32; - var R8_14: bv64; - var R8_15: bv32; - var R8_21: bv64; - var R8_24: bv64; - var R8_27: bv64; - var R8_30: bv64; - var R8_33: bv64; - var R8_7: bv64; - var R8_8: bv32; - var R9: bv64; + var Cse0__5$0$1: bv32; + var Cse0__5$5$1: bv64; + var Cse0__5$7$1: bv32; + var Cse0__5$9$1: bv64; + var Cse0__5$9$7: bv32; + var Gamma_Cse0__5$0$1: bool; + var Gamma_Cse0__5$5$1: bool; + var Gamma_Cse0__5$7$1: bool; + var Gamma_Cse0__5$9$1: bool; + var Gamma_Cse0__5$9$7: bool; $main$__0__$rboiQVDCQyC6FKdIfNmCPw: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R0_in); - R8_1, Gamma_R8_1 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551580bv64), R8_1), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64), Gamma_R8_1); - assert Gamma_R8_1; + assume {:captureState "$main$__0__$rboiQVDCQyC6FKdIfNmCPw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + Cse0__5$9$1, Gamma_Cse0__5$9$1 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$9$1, R29), gamma_store64(Gamma_stack, Cse0__5$9$1, Gamma_R29); + assume {:captureState "1864$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$9$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$9$1, 8bv64), Gamma_R30); + assume {:captureState "1864$2"} true; + R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "1872$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551608bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551608bv64), Gamma_R0); + assume {:captureState "1876$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551608bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1884$0"} true; + Cse0__5$9$7, Gamma_Cse0__5$9$7 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$9$7, Cse0__5$9$7)), Gamma_Cse0__5$9$7; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$9$7), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$9$7); + ZF, Gamma_ZF := bvcomp32(Cse0__5$9$7, 0bv32), Gamma_Cse0__5$9$7; + NF, Gamma_NF := Cse0__5$9$7[32:31], Gamma_Cse0__5$9$7; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$9$7), Gamma_Cse0__5$9$7; + assert Gamma_ZF; goto $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__0, $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__1; - $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__1: - assume (R8_1 == 0bv32); - goto $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__1_phi_$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__6__$JHDryML5TjOA3hQf2kM0Cg_phi_back_$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__6__$JHDryML5TjOA3hQf2kM0Cg, $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__1_phi_$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__1__$RQAiG6zTRPieGXtg8phNzg_phi_back_$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__1__$RQAiG6zTRPieGXtg8phNzg; - $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__1_phi_$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__1__$RQAiG6zTRPieGXtg8phNzg_phi_back_$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__1__$RQAiG6zTRPieGXtg8phNzg: - R8_7, Gamma_R8_7 := 1bv64, true; - assert Gamma_R8_7; - goto $main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__1__$RQAiG6zTRPieGXtg8phNzg; - $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__1_phi_$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__6__$JHDryML5TjOA3hQf2kM0Cg_phi_back_$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__6__$JHDryML5TjOA3hQf2kM0Cg: - R8_30, Gamma_R8_30 := 1bv64, true; - assert Gamma_R8_30; - goto $main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__6__$JHDryML5TjOA3hQf2kM0Cg; - $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__0: - assume (!(R8_1 == 0bv32)); - goto $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__0_phi_back_$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__1__$RQAiG6zTRPieGXtg8phNzg, $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__0_phi_back_$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__6__$JHDryML5TjOA3hQf2kM0Cg; - $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__0_phi_back_$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__6__$JHDryML5TjOA3hQf2kM0Cg: - R8_30, Gamma_R8_30 := 0bv64, true; - assert Gamma_R8_30; - goto $main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__6__$JHDryML5TjOA3hQf2kM0Cg; - $main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__6__$JHDryML5TjOA3hQf2kM0Cg: - assume (R8_30[1:0] == 1bv1); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), 1812bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), true); - goto $main$__10__$97Y0dwDdTcSoq5o31slpCQ; - $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__0_phi_back_$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__1__$RQAiG6zTRPieGXtg8phNzg: - R8_7, Gamma_R8_7 := 0bv64, true; - assert Gamma_R8_7; - goto $main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__1__$RQAiG6zTRPieGXtg8phNzg; - $main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__1__$RQAiG6zTRPieGXtg8phNzg: - assume (!(R8_7[1:0] == 1bv1)); - R8_8, Gamma_R8_8 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551580bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64)); - assert Gamma_R8_8; + $main$__1__$RQAiG6zTRPieGXtg8phNzg: + assume {:captureState "$main$__1__$RQAiG6zTRPieGXtg8phNzg"} true; + goto $main$__2__$AkRBc3htTB6hp_enLsE9xA; + $main$__2__$AkRBc3htTB6hp_enLsE9xA: + assume {:captureState "$main$__2__$AkRBc3htTB6hp_enLsE9xA"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + Cse0__5$7$1, Gamma_Cse0__5$7$1 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$7$1), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_Cse0__5$7$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$7$1), bvadd33(zero_extend1_32(R8[32:0]), 4294967295bv33))), (Gamma_R8 && Gamma_Cse0__5$7$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$7$1, 0bv32), Gamma_Cse0__5$7$1; + NF, Gamma_NF := Cse0__5$7$1[32:31], Gamma_Cse0__5$7$1; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$7$1), Gamma_Cse0__5$7$1; + assert Gamma_ZF; goto $main$__2__$AkRBc3htTB6hp_enLsE9xA$__0, $main$__2__$AkRBc3htTB6hp_enLsE9xA$__1; - $main$__2__$AkRBc3htTB6hp_enLsE9xA$__1: - assume (R8_8 == 1bv32); - goto $main$__2__$AkRBc3htTB6hp_enLsE9xA$__1_phi_$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__7__$esd5Zx0TR0e4D_8HsKRPlw_phi_back_$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__7__$esd5Zx0TR0e4D_8HsKRPlw, $main$__2__$AkRBc3htTB6hp_enLsE9xA$__1_phi_$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ_phi_back_$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ; - $main$__2__$AkRBc3htTB6hp_enLsE9xA$__1_phi_$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ_phi_back_$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ: - R8_14, Gamma_R8_14 := 1bv64, true; - assert Gamma_R8_14; - goto $main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ; - $main$__2__$AkRBc3htTB6hp_enLsE9xA$__1_phi_$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__7__$esd5Zx0TR0e4D_8HsKRPlw_phi_back_$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__7__$esd5Zx0TR0e4D_8HsKRPlw: - R8_27, Gamma_R8_27 := 1bv64, true; - assert Gamma_R8_27; - goto $main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__7__$esd5Zx0TR0e4D_8HsKRPlw; - $main$__2__$AkRBc3htTB6hp_enLsE9xA$__0: - assume (!(R8_8 == 1bv32)); - goto $main$__2__$AkRBc3htTB6hp_enLsE9xA$__0_phi_back_$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ, $main$__2__$AkRBc3htTB6hp_enLsE9xA$__0_phi_back_$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__7__$esd5Zx0TR0e4D_8HsKRPlw; - $main$__2__$AkRBc3htTB6hp_enLsE9xA$__0_phi_back_$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__7__$esd5Zx0TR0e4D_8HsKRPlw: - R8_27, Gamma_R8_27 := 0bv64, true; - assert Gamma_R8_27; - goto $main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__7__$esd5Zx0TR0e4D_8HsKRPlw; - $main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__7__$esd5Zx0TR0e4D_8HsKRPlw: - assume (R8_27[1:0] == 1bv1); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), 1828bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), true); - goto $main$__10__$97Y0dwDdTcSoq5o31slpCQ; - $main$__2__$AkRBc3htTB6hp_enLsE9xA$__0_phi_back_$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ: - R8_14, Gamma_R8_14 := 0bv64, true; - assert Gamma_R8_14; - goto $main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ; - $main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ: - assume (!(R8_14[1:0] == 1bv1)); - R8_15, Gamma_R8_15 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551580bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64)); - assert Gamma_R8_15; + $main$__3__$I8FZ352ZRO~IEf~R_0OuJQ: + assume {:captureState "$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ"} true; + goto $main$__4__$70RWhLkDTe~EhsDioLw8WQ; + $main$__4__$70RWhLkDTe~EhsDioLw8WQ: + assume {:captureState "$main$__4__$70RWhLkDTe~EhsDioLw8WQ"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + Cse0__5$0$1, Gamma_Cse0__5$0$1 := bvadd32(R8[32:0], 4294967294bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$0$1), bvadd33(sign_extend1_32(R8[32:0]), 8589934590bv33))), (Gamma_R8 && Gamma_Cse0__5$0$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$1), bvadd33(zero_extend1_32(R8[32:0]), 4294967294bv33))), (Gamma_R8 && Gamma_Cse0__5$0$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$1, 0bv32), Gamma_Cse0__5$0$1; + NF, Gamma_NF := Cse0__5$0$1[32:31], Gamma_Cse0__5$0$1; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$0$1), Gamma_Cse0__5$0$1; + assert Gamma_ZF; goto $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__0, $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__1; - $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__1: - assume (R8_15 == 2bv32); - goto $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__1_phi_$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__8__$5eLcB2fBTiuduOLFrI7HMQ_phi_back_$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__8__$5eLcB2fBTiuduOLFrI7HMQ, $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__1_phi_$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__5__$y41iXcMRRS60gPiNTMEqUA_phi_back_$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__5__$y41iXcMRRS60gPiNTMEqUA; - $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__1_phi_$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__5__$y41iXcMRRS60gPiNTMEqUA_phi_back_$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__5__$y41iXcMRRS60gPiNTMEqUA: - R8_21, Gamma_R8_21 := 1bv64, true; - assert Gamma_R8_21; - goto $main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__5__$y41iXcMRRS60gPiNTMEqUA; - $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__1_phi_$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__8__$5eLcB2fBTiuduOLFrI7HMQ_phi_back_$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__8__$5eLcB2fBTiuduOLFrI7HMQ: - R8_24, Gamma_R8_24 := 1bv64, true; - assert Gamma_R8_24; - goto $main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__8__$5eLcB2fBTiuduOLFrI7HMQ; - $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__0: - assume (!(R8_15 == 2bv32)); - goto $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__0_phi_back_$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__5__$y41iXcMRRS60gPiNTMEqUA, $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__0_phi_back_$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__8__$5eLcB2fBTiuduOLFrI7HMQ; - $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__0_phi_back_$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__8__$5eLcB2fBTiuduOLFrI7HMQ: - R8_24, Gamma_R8_24 := 0bv64, true; - assert Gamma_R8_24; - goto $main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__8__$5eLcB2fBTiuduOLFrI7HMQ; - $main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__8__$5eLcB2fBTiuduOLFrI7HMQ: - assume (R8_24[1:0] == 1bv1); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), 1844bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), true); + $main$__5__$y41iXcMRRS60gPiNTMEqUA: + assume {:captureState "$main$__5__$y41iXcMRRS60gPiNTMEqUA"} true; + goto $main$__9__$AsLE5WYARJCWvKLiwF4hRQ; + $main$__6__$JHDryML5TjOA3hQf2kM0Cg: + assume {:captureState "$main$__6__$JHDryML5TjOA3hQf2kM0Cg"} true; + R8, Gamma_R8 := 0bv64, true; + R8, Gamma_R8 := bvadd64(R8, 1812bv64), Gamma_R8; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R8); + assume {:captureState "1952$0"} true; goto $main$__10__$97Y0dwDdTcSoq5o31slpCQ; - $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__0_phi_back_$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__5__$y41iXcMRRS60gPiNTMEqUA: - R8_21, Gamma_R8_21 := 0bv64, true; - assert Gamma_R8_21; - goto $main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__5__$y41iXcMRRS60gPiNTMEqUA; - $main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__5__$y41iXcMRRS60gPiNTMEqUA: - assume (!(R8_21[1:0] == 1bv1)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), 1812bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), true); + $main$__7__$esd5Zx0TR0e4D_8HsKRPlw: + assume {:captureState "$main$__7__$esd5Zx0TR0e4D_8HsKRPlw"} true; + R8, Gamma_R8 := 0bv64, true; + R8, Gamma_R8 := bvadd64(R8, 1828bv64), Gamma_R8; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R8); + assume {:captureState "1968$0"} true; + goto $main$__10__$97Y0dwDdTcSoq5o31slpCQ; + $main$__8__$5eLcB2fBTiuduOLFrI7HMQ: + assume {:captureState "$main$__8__$5eLcB2fBTiuduOLFrI7HMQ"} true; + R8, Gamma_R8 := 0bv64, true; + R8, Gamma_R8 := bvadd64(R8, 1844bv64), Gamma_R8; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R8); + assume {:captureState "1984$0"} true; + goto $main$__10__$97Y0dwDdTcSoq5o31slpCQ; + $main$__9__$AsLE5WYARJCWvKLiwF4hRQ: + assume {:captureState "$main$__9__$AsLE5WYARJCWvKLiwF4hRQ"} true; + R8, Gamma_R8 := 0bv64, true; + R8, Gamma_R8 := bvadd64(R8, 1812bv64), Gamma_R8; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R8); + assume {:captureState "2000$0"} true; goto $main$__10__$97Y0dwDdTcSoq5o31slpCQ; $main$__10__$97Y0dwDdTcSoq5o31slpCQ: - R8_33, Gamma_R8_33 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); + assume {:captureState "$main$__10__$97Y0dwDdTcSoq5o31slpCQ"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R30, Gamma_R30 := 2016bv64, true; goto $main$__10__$97Y0dwDdTcSoq5o31slpCQ$set_two, $main$__10__$97Y0dwDdTcSoq5o31slpCQ$set_six, $main$__10__$97Y0dwDdTcSoq5o31slpCQ$set_seven; - $main$__10__$97Y0dwDdTcSoq5o31slpCQ$set_seven: - assume (R8_33 == 1844bv64); - call set_seven(); + $main$__11__$jAHnJBxNS3WjIRJVHu5UsQ: + assume {:captureState "$main$__11__$jAHnJBxNS3WjIRJVHu5UsQ"} true; + R0, Gamma_R0 := 0bv64, true; + Cse0__5$5$1, Gamma_Cse0__5$5$1 := bvadd64(R31, 32bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$5$1), gamma_load64(Gamma_stack, Cse0__5$5$1); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$5$1, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$5$1, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; + goto main_basil_return; + $main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__8__$5eLcB2fBTiuduOLFrI7HMQ: + assume {:captureState "$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__8__$5eLcB2fBTiuduOLFrI7HMQ"} true; + assume (R8[1:0] == 1bv1); + goto $main$__8__$5eLcB2fBTiuduOLFrI7HMQ; + $main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__5__$y41iXcMRRS60gPiNTMEqUA: + assume {:captureState "$main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__5__$y41iXcMRRS60gPiNTMEqUA"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__5__$y41iXcMRRS60gPiNTMEqUA; + $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__0: + assume {:captureState "$main$__4__$70RWhLkDTe~EhsDioLw8WQ$__0"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__8__$5eLcB2fBTiuduOLFrI7HMQ, $main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__5__$y41iXcMRRS60gPiNTMEqUA; + $main$__4__$70RWhLkDTe~EhsDioLw8WQ$__1: + assume {:captureState "$main$__4__$70RWhLkDTe~EhsDioLw8WQ$__1"} true; + assume (!(!(ZF == 1bv1))); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__8__$5eLcB2fBTiuduOLFrI7HMQ, $main$__4__$70RWhLkDTe~EhsDioLw8WQ_goto_$main$__5__$y41iXcMRRS60gPiNTMEqUA; + $main$__10__$97Y0dwDdTcSoq5o31slpCQ$set_two: + assume {:captureState "$main$__10__$97Y0dwDdTcSoq5o31slpCQ$set_two"} true; + assume (R8 == 1812bv64); + call set_two(); goto $main$__11__$jAHnJBxNS3WjIRJVHu5UsQ; $main$__10__$97Y0dwDdTcSoq5o31slpCQ$set_six: - assume (R8_33 == 1828bv64); + assume {:captureState "$main$__10__$97Y0dwDdTcSoq5o31slpCQ$set_six"} true; + assume (R8 == 1828bv64); call set_six(); goto $main$__11__$jAHnJBxNS3WjIRJVHu5UsQ; - $main$__10__$97Y0dwDdTcSoq5o31slpCQ$set_two: - assume (R8_33 == 1812bv64); - call set_two(); + $main$__10__$97Y0dwDdTcSoq5o31slpCQ$set_seven: + assume {:captureState "$main$__10__$97Y0dwDdTcSoq5o31slpCQ$set_seven"} true; + assume (R8 == 1844bv64); + call set_seven(); goto $main$__11__$jAHnJBxNS3WjIRJVHu5UsQ; - $main$__11__$jAHnJBxNS3WjIRJVHu5UsQ: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - goto main_basil_return; + $main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__7__$esd5Zx0TR0e4D_8HsKRPlw: + assume {:captureState "$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__7__$esd5Zx0TR0e4D_8HsKRPlw"} true; + assume (R8[1:0] == 1bv1); + goto $main$__7__$esd5Zx0TR0e4D_8HsKRPlw; + $main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ: + assume {:captureState "$main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__3__$I8FZ352ZRO~IEf~R_0OuJQ; + $main$__2__$AkRBc3htTB6hp_enLsE9xA$__0: + assume {:captureState "$main$__2__$AkRBc3htTB6hp_enLsE9xA$__0"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__7__$esd5Zx0TR0e4D_8HsKRPlw, $main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ; + $main$__2__$AkRBc3htTB6hp_enLsE9xA$__1: + assume {:captureState "$main$__2__$AkRBc3htTB6hp_enLsE9xA$__1"} true; + assume (!(!(ZF == 1bv1))); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__7__$esd5Zx0TR0e4D_8HsKRPlw, $main$__2__$AkRBc3htTB6hp_enLsE9xA_goto_$main$__3__$I8FZ352ZRO~IEf~R_0OuJQ; + $main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__6__$JHDryML5TjOA3hQf2kM0Cg: + assume {:captureState "$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__6__$JHDryML5TjOA3hQf2kM0Cg"} true; + assume (R8[1:0] == 1bv1); + goto $main$__6__$JHDryML5TjOA3hQf2kM0Cg; + $main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__1__$RQAiG6zTRPieGXtg8phNzg: + assume {:captureState "$main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__1__$RQAiG6zTRPieGXtg8phNzg"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$RQAiG6zTRPieGXtg8phNzg; + $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__0: + assume {:captureState "$main$__0__$rboiQVDCQyC6FKdIfNmCPw$__0"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__6__$JHDryML5TjOA3hQf2kM0Cg, $main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__1__$RQAiG6zTRPieGXtg8phNzg; + $main$__0__$rboiQVDCQyC6FKdIfNmCPw$__1: + assume {:captureState "$main$__0__$rboiQVDCQyC6FKdIfNmCPw$__1"} true; + assume (!(!(ZF == 1bv1))); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__6__$JHDryML5TjOA3hQf2kM0Cg, $main$__0__$rboiQVDCQyC6FKdIfNmCPw_goto_$main$__1__$RQAiG6zTRPieGXtg8phNzg; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out, R9_out := 0bv64, R29_3, R30_3, R31_in, R8_33, R9; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in, Gamma_R8_33, Gamma_R9; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/functionpointer/clang_pic/functionpointer_gtirb.expected b/src/test/correct/functionpointer/clang_pic/functionpointer_gtirb.expected index d1908f78a..520e1d13b 100644 --- a/src/test/correct/functionpointer/clang_pic/functionpointer_gtirb.expected +++ b/src/test/correct/functionpointer/clang_pic/functionpointer_gtirb.expected @@ -1,26 +1,37 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -30,15 +41,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -49,39 +56,35 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2192bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2193bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2194bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2195bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 1960bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 2000bv64); - free ensures (memory_load64_le(mem, 69552bv64) == 69684bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2192bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69040bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69552bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69568bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 1960bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1980bv64); - free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -95,328 +98,339 @@ procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure set_seven(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2192bv64) == 1bv8); - free requires (memory_load8_le(mem, 2193bv64) == 0bv8); - free requires (memory_load8_le(mem, 2194bv64) == 2bv8); - free requires (memory_load8_le(mem, 2195bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 1960bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 2000bv64); - free requires (memory_load64_le(mem, 69552bv64) == 69684bv64); + modifies Gamma_R8, Gamma_R9, Gamma_mem, R8, R9, mem; + free requires (memory_load32_le(mem, 2192bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69032bv64) == 1936bv64); free requires (memory_load64_le(mem, 69040bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69552bv64) == 69684bv64); free requires (memory_load64_le(mem, 69568bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69576bv64) == 1960bv64); + free requires (memory_load64_le(mem, 69584bv64) == 2000bv64); free requires (memory_load64_le(mem, 69592bv64) == 1980bv64); - free requires (memory_load64_le(mem, 69032bv64) == 1936bv64); - free ensures (memory_load8_le(mem, 2192bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2193bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2194bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2195bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 1960bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 2000bv64); - free ensures (memory_load64_le(mem, 69552bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 2192bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69040bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69552bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69568bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 1960bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1980bv64); - free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); implementation set_seven() { - var Gamma_R9_2: bool; - var R9_2: bv64; $set_seven$__0__$kTg_e3tbRpqCznoQ8obi7A: + assume {:captureState "$set_seven$__0__$kTg_e3tbRpqCznoQ8obi7A"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69552bv64), (gamma_load64(Gamma_mem, 69552bv64) || L(mem, 69552bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4016bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4016bv64)) || L(mem, bvadd64(R9, 4016bv64))); + R8, Gamma_R8 := 7bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 7bv32), gamma_store32(Gamma_mem, R9_2, true); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1992$0"} true; goto set_seven_basil_return; set_seven_basil_return: + assume {:captureState "set_seven_basil_return"} true; return; } procedure set_six(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2192bv64) == 1bv8); - free requires (memory_load8_le(mem, 2193bv64) == 0bv8); - free requires (memory_load8_le(mem, 2194bv64) == 2bv8); - free requires (memory_load8_le(mem, 2195bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 1960bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 2000bv64); - free requires (memory_load64_le(mem, 69552bv64) == 69684bv64); + modifies Gamma_R8, Gamma_R9, Gamma_mem, R8, R9, mem; + free requires (memory_load32_le(mem, 2192bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69032bv64) == 1936bv64); free requires (memory_load64_le(mem, 69040bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69552bv64) == 69684bv64); free requires (memory_load64_le(mem, 69568bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69576bv64) == 1960bv64); + free requires (memory_load64_le(mem, 69584bv64) == 2000bv64); free requires (memory_load64_le(mem, 69592bv64) == 1980bv64); - free requires (memory_load64_le(mem, 69032bv64) == 1936bv64); - free ensures (memory_load8_le(mem, 2192bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2193bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2194bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2195bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 1960bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 2000bv64); - free ensures (memory_load64_le(mem, 69552bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 2192bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69040bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69552bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69568bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 1960bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1980bv64); - free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); implementation set_six() { - var Gamma_R9_2: bool; - var R9_2: bv64; $set_six$__0__$ciqx_PCBQwevaWTzDpNJDQ: + assume {:captureState "$set_six$__0__$ciqx_PCBQwevaWTzDpNJDQ"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69552bv64), (gamma_load64(Gamma_mem, 69552bv64) || L(mem, 69552bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4016bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4016bv64)) || L(mem, bvadd64(R9, 4016bv64))); + R8, Gamma_R8 := 6bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 6bv32), gamma_store32(Gamma_mem, R9_2, true); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1972$0"} true; goto set_six_basil_return; set_six_basil_return: + assume {:captureState "set_six_basil_return"} true; return; } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == true); +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R29, R30, R31, R8, R9, VF, ZF, mem, stack; + requires (Gamma_R0 == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 2192bv64) == 1bv8); - free requires (memory_load8_le(mem, 2193bv64) == 0bv8); - free requires (memory_load8_le(mem, 2194bv64) == 2bv8); - free requires (memory_load8_le(mem, 2195bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 1960bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 2000bv64); - free requires (memory_load64_le(mem, 69552bv64) == 69684bv64); + free requires (memory_load32_le(mem, 2192bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69032bv64) == 1936bv64); free requires (memory_load64_le(mem, 69040bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69552bv64) == 69684bv64); free requires (memory_load64_le(mem, 69568bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69576bv64) == 1960bv64); + free requires (memory_load64_le(mem, 69584bv64) == 2000bv64); free requires (memory_load64_le(mem, 69592bv64) == 1980bv64); - free requires (memory_load64_le(mem, 69032bv64) == 1936bv64); - free ensures (memory_load8_le(mem, 2192bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2193bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2194bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2195bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 1960bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 2000bv64); - free ensures (memory_load64_le(mem, 69552bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2192bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69040bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69552bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69568bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 1960bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1980bv64); - free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var Gamma_R8_1: bool; - var Gamma_R8_14: bool; - var Gamma_R8_15: bool; - var Gamma_R8_21: bool; - var Gamma_R8_23: bool; - var Gamma_R8_24: bool; - var Gamma_R8_26: bool; - var Gamma_R8_27: bool; - var Gamma_R8_29: bool; - var Gamma_R8_30: bool; - var Gamma_R8_32: bool; - var Gamma_R8_33: bool; - var Gamma_R8_7: bool; - var Gamma_R8_8: bool; - var Gamma_R9: bool; - var R29_3: bv64; - var R30_3: bv64; - var R8_1: bv32; - var R8_14: bv64; - var R8_15: bv32; - var R8_21: bv64; - var R8_23: bv64; - var R8_24: bv64; - var R8_26: bv64; - var R8_27: bv64; - var R8_29: bv64; - var R8_30: bv64; - var R8_32: bv64; - var R8_33: bv64; - var R8_7: bv64; - var R8_8: bv32; - var R9: bv64; + var Cse0__5$10$1: bv64; + var Cse0__5$5$1: bv32; + var Cse0__5$6$1: bv64; + var Cse0__5$6$7: bv32; + var Cse0__5$7$1: bv32; + var Gamma_Cse0__5$10$1: bool; + var Gamma_Cse0__5$5$1: bool; + var Gamma_Cse0__5$6$1: bool; + var Gamma_Cse0__5$6$7: bool; + var Gamma_Cse0__5$7$1: bool; $main$__0__$G_1Y6jALRC~8UvxN~Oh74A: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R0_in); - R8_1, Gamma_R8_1 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551580bv64), R8_1), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64), Gamma_R8_1); - assert Gamma_R8_1; + assume {:captureState "$main$__0__$G_1Y6jALRC~8UvxN~Oh74A"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + Cse0__5$6$1, Gamma_Cse0__5$6$1 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$6$1, R29), gamma_store64(Gamma_stack, Cse0__5$6$1, Gamma_R29); + assume {:captureState "2004$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$6$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$6$1, 8bv64), Gamma_R30); + assume {:captureState "2004$2"} true; + R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "2012$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551608bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551608bv64), Gamma_R0); + assume {:captureState "2016$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551608bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "2024$0"} true; + Cse0__5$6$7, Gamma_Cse0__5$6$7 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$6$7, Cse0__5$6$7)), Gamma_Cse0__5$6$7; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$6$7), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$6$7); + ZF, Gamma_ZF := bvcomp32(Cse0__5$6$7, 0bv32), Gamma_Cse0__5$6$7; + NF, Gamma_NF := Cse0__5$6$7[32:31], Gamma_Cse0__5$6$7; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$6$7), Gamma_Cse0__5$6$7; + assert Gamma_ZF; goto $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__0, $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__1; - $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__1: - assume (R8_1 == 0bv32); - goto $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__1_phi_$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__6__$f4nhHXxoReqZDuDK6zxsSQ_phi_back_$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__6__$f4nhHXxoReqZDuDK6zxsSQ, $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__1_phi_$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__1__$9glsOoBtTsagmZpc7KXoEQ_phi_back_$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__1__$9glsOoBtTsagmZpc7KXoEQ; - $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__1_phi_$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__1__$9glsOoBtTsagmZpc7KXoEQ_phi_back_$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__1__$9glsOoBtTsagmZpc7KXoEQ: - R8_7, Gamma_R8_7 := 1bv64, true; - assert Gamma_R8_7; - goto $main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__1__$9glsOoBtTsagmZpc7KXoEQ; - $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__1_phi_$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__6__$f4nhHXxoReqZDuDK6zxsSQ_phi_back_$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__6__$f4nhHXxoReqZDuDK6zxsSQ: - R8_30, Gamma_R8_30 := 1bv64, true; - assert Gamma_R8_30; - goto $main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__6__$f4nhHXxoReqZDuDK6zxsSQ; - $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__0: - assume (!(R8_1 == 0bv32)); - goto $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__0_phi_back_$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__1__$9glsOoBtTsagmZpc7KXoEQ, $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__0_phi_back_$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__6__$f4nhHXxoReqZDuDK6zxsSQ; - $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__0_phi_back_$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__6__$f4nhHXxoReqZDuDK6zxsSQ: - R8_30, Gamma_R8_30 := 0bv64, true; - assert Gamma_R8_30; - goto $main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__6__$f4nhHXxoReqZDuDK6zxsSQ; - $main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__6__$f4nhHXxoReqZDuDK6zxsSQ: - assume (R8_30[1:0] == 1bv1); + $main$__1__$9glsOoBtTsagmZpc7KXoEQ: + assume {:captureState "$main$__1__$9glsOoBtTsagmZpc7KXoEQ"} true; + goto $main$__2__$A0okiAJhRZaNrB4lOPZtTw; + $main$__2__$A0okiAJhRZaNrB4lOPZtTw: + assume {:captureState "$main$__2__$A0okiAJhRZaNrB4lOPZtTw"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + Cse0__5$5$1, Gamma_Cse0__5$5$1 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$5$1), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_Cse0__5$5$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$5$1), bvadd33(zero_extend1_32(R8[32:0]), 4294967295bv33))), (Gamma_R8 && Gamma_Cse0__5$5$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$5$1, 0bv32), Gamma_Cse0__5$5$1; + NF, Gamma_NF := Cse0__5$5$1[32:31], Gamma_Cse0__5$5$1; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$5$1), Gamma_Cse0__5$5$1; + assert Gamma_ZF; + goto $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__0, $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__1; + $main$__3__$BN0TEK1EQNeAY2qOwIEG5g: + assume {:captureState "$main$__3__$BN0TEK1EQNeAY2qOwIEG5g"} true; + goto $main$__4__$ZMwLE9GySQC4wAmL8es_Tw; + $main$__4__$ZMwLE9GySQC4wAmL8es_Tw: + assume {:captureState "$main$__4__$ZMwLE9GySQC4wAmL8es_Tw"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + Cse0__5$7$1, Gamma_Cse0__5$7$1 := bvadd32(R8[32:0], 4294967294bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$7$1), bvadd33(sign_extend1_32(R8[32:0]), 8589934590bv33))), (Gamma_R8 && Gamma_Cse0__5$7$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$7$1), bvadd33(zero_extend1_32(R8[32:0]), 4294967294bv33))), (Gamma_R8 && Gamma_Cse0__5$7$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$7$1, 0bv32), Gamma_Cse0__5$7$1; + NF, Gamma_NF := Cse0__5$7$1[32:31], Gamma_Cse0__5$7$1; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$7$1), Gamma_Cse0__5$7$1; + assert Gamma_ZF; + goto $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__0, $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__1; + $main$__5__$tQCpvwKrSeCFPREd7E8FUA: + assume {:captureState "$main$__5__$tQCpvwKrSeCFPREd7E8FUA"} true; + goto $main$__9__$zMmLxlHWR8mJqTkM1yPBaQ; + $main$__6__$f4nhHXxoReqZDuDK6zxsSQ: + assume {:captureState "$main$__6__$f4nhHXxoReqZDuDK6zxsSQ"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_32, Gamma_R8_32 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R8_32), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R8_32); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R8); + assume {:captureState "2092$0"} true; goto $main$__10__$0TNylRK6RmS5UECtsNwwsA; - $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__0_phi_back_$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__1__$9glsOoBtTsagmZpc7KXoEQ: - R8_7, Gamma_R8_7 := 0bv64, true; - assert Gamma_R8_7; - goto $main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__1__$9glsOoBtTsagmZpc7KXoEQ; - $main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__1__$9glsOoBtTsagmZpc7KXoEQ: - assume (!(R8_7[1:0] == 1bv1)); - R8_8, Gamma_R8_8 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551580bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64)); - assert Gamma_R8_8; - goto $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__0, $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__1; - $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__1: - assume (R8_8 == 1bv32); - goto $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__1_phi_$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__7__$WBIrr~FJQGaywM0EFL_~lQ_phi_back_$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__7__$WBIrr~FJQGaywM0EFL_~lQ, $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__1_phi_$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__3__$BN0TEK1EQNeAY2qOwIEG5g_phi_back_$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__3__$BN0TEK1EQNeAY2qOwIEG5g; - $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__1_phi_$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__3__$BN0TEK1EQNeAY2qOwIEG5g_phi_back_$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__3__$BN0TEK1EQNeAY2qOwIEG5g: - R8_14, Gamma_R8_14 := 1bv64, true; - assert Gamma_R8_14; - goto $main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__3__$BN0TEK1EQNeAY2qOwIEG5g; - $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__1_phi_$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__7__$WBIrr~FJQGaywM0EFL_~lQ_phi_back_$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__7__$WBIrr~FJQGaywM0EFL_~lQ: - R8_27, Gamma_R8_27 := 1bv64, true; - assert Gamma_R8_27; - goto $main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__7__$WBIrr~FJQGaywM0EFL_~lQ; - $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__0: - assume (!(R8_8 == 1bv32)); - goto $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__0_phi_back_$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__3__$BN0TEK1EQNeAY2qOwIEG5g, $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__0_phi_back_$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__7__$WBIrr~FJQGaywM0EFL_~lQ; - $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__0_phi_back_$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__7__$WBIrr~FJQGaywM0EFL_~lQ: - R8_27, Gamma_R8_27 := 0bv64, true; - assert Gamma_R8_27; - goto $main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__7__$WBIrr~FJQGaywM0EFL_~lQ; - $main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__7__$WBIrr~FJQGaywM0EFL_~lQ: - assume (R8_27[1:0] == 1bv1); + $main$__7__$WBIrr~FJQGaywM0EFL_~lQ: + assume {:captureState "$main$__7__$WBIrr~FJQGaywM0EFL_~lQ"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_29, Gamma_R8_29 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R8_29), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R8_29); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R8); + assume {:captureState "2108$0"} true; goto $main$__10__$0TNylRK6RmS5UECtsNwwsA; - $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__0_phi_back_$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__3__$BN0TEK1EQNeAY2qOwIEG5g: - R8_14, Gamma_R8_14 := 0bv64, true; - assert Gamma_R8_14; - goto $main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__3__$BN0TEK1EQNeAY2qOwIEG5g; - $main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__3__$BN0TEK1EQNeAY2qOwIEG5g: - assume (!(R8_14[1:0] == 1bv1)); - R8_15, Gamma_R8_15 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551580bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64)); - assert Gamma_R8_15; - goto $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__0, $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__1; - $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__1: - assume (R8_15 == 2bv32); - goto $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__1_phi_$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__8__$MFGHilZOSS~y6mrYfWAhnQ_phi_back_$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__8__$MFGHilZOSS~y6mrYfWAhnQ, $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__1_phi_$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__5__$tQCpvwKrSeCFPREd7E8FUA_phi_back_$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__5__$tQCpvwKrSeCFPREd7E8FUA; - $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__1_phi_$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__5__$tQCpvwKrSeCFPREd7E8FUA_phi_back_$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__5__$tQCpvwKrSeCFPREd7E8FUA: - R8_21, Gamma_R8_21 := 1bv64, true; - assert Gamma_R8_21; - goto $main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__5__$tQCpvwKrSeCFPREd7E8FUA; - $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__1_phi_$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__8__$MFGHilZOSS~y6mrYfWAhnQ_phi_back_$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__8__$MFGHilZOSS~y6mrYfWAhnQ: - R8_24, Gamma_R8_24 := 1bv64, true; - assert Gamma_R8_24; - goto $main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__8__$MFGHilZOSS~y6mrYfWAhnQ; - $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__0: - assume (!(R8_15 == 2bv32)); - goto $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__0_phi_back_$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__5__$tQCpvwKrSeCFPREd7E8FUA, $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__0_phi_back_$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__8__$MFGHilZOSS~y6mrYfWAhnQ; - $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__0_phi_back_$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__8__$MFGHilZOSS~y6mrYfWAhnQ: - R8_24, Gamma_R8_24 := 0bv64, true; - assert Gamma_R8_24; - goto $main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__8__$MFGHilZOSS~y6mrYfWAhnQ; - $main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__8__$MFGHilZOSS~y6mrYfWAhnQ: - assume (R8_24[1:0] == 1bv1); + $main$__8__$MFGHilZOSS~y6mrYfWAhnQ: + assume {:captureState "$main$__8__$MFGHilZOSS~y6mrYfWAhnQ"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_26, Gamma_R8_26 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R8_26), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R8_26); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4056bv64)) || L(mem, bvadd64(R8, 4056bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R8); + assume {:captureState "2124$0"} true; goto $main$__10__$0TNylRK6RmS5UECtsNwwsA; - $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__0_phi_back_$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__5__$tQCpvwKrSeCFPREd7E8FUA: - R8_21, Gamma_R8_21 := 0bv64, true; - assert Gamma_R8_21; - goto $main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__5__$tQCpvwKrSeCFPREd7E8FUA; - $main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__5__$tQCpvwKrSeCFPREd7E8FUA: - assume (!(R8_21[1:0] == 1bv1)); + $main$__9__$zMmLxlHWR8mJqTkM1yPBaQ: + assume {:captureState "$main$__9__$zMmLxlHWR8mJqTkM1yPBaQ"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_23, Gamma_R8_23 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R8_23), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R8_23); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R8); + assume {:captureState "2140$0"} true; goto $main$__10__$0TNylRK6RmS5UECtsNwwsA; $main$__10__$0TNylRK6RmS5UECtsNwwsA: - R8_33, Gamma_R8_33 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); + assume {:captureState "$main$__10__$0TNylRK6RmS5UECtsNwwsA"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R30, Gamma_R30 := 2156bv64, true; goto $main$__10__$0TNylRK6RmS5UECtsNwwsA$set_six, $main$__10__$0TNylRK6RmS5UECtsNwwsA$set_two, $main$__10__$0TNylRK6RmS5UECtsNwwsA$set_seven; - $main$__10__$0TNylRK6RmS5UECtsNwwsA$set_seven: - assume (R8_33 == 1980bv64); - call set_seven(); + $main$__11__$5RCauC7lSbWG2IsnALJTGg: + assume {:captureState "$main$__11__$5RCauC7lSbWG2IsnALJTGg"} true; + R0, Gamma_R0 := 0bv64, true; + Cse0__5$10$1, Gamma_Cse0__5$10$1 := bvadd64(R31, 32bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$10$1), gamma_load64(Gamma_stack, Cse0__5$10$1); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$10$1, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$10$1, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; + goto main_basil_return; + $main$__10__$0TNylRK6RmS5UECtsNwwsA$set_six: + assume {:captureState "$main$__10__$0TNylRK6RmS5UECtsNwwsA$set_six"} true; + assume (R8 == 1960bv64); + call set_six(); goto $main$__11__$5RCauC7lSbWG2IsnALJTGg; $main$__10__$0TNylRK6RmS5UECtsNwwsA$set_two: - assume (R8_33 == 1940bv64); + assume {:captureState "$main$__10__$0TNylRK6RmS5UECtsNwwsA$set_two"} true; + assume (R8 == 1940bv64); call set_two(); goto $main$__11__$5RCauC7lSbWG2IsnALJTGg; - $main$__10__$0TNylRK6RmS5UECtsNwwsA$set_six: - assume (R8_33 == 1960bv64); - call set_six(); + $main$__10__$0TNylRK6RmS5UECtsNwwsA$set_seven: + assume {:captureState "$main$__10__$0TNylRK6RmS5UECtsNwwsA$set_seven"} true; + assume (R8 == 1980bv64); + call set_seven(); goto $main$__11__$5RCauC7lSbWG2IsnALJTGg; - $main$__11__$5RCauC7lSbWG2IsnALJTGg: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - goto main_basil_return; + $main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__7__$WBIrr~FJQGaywM0EFL_~lQ: + assume {:captureState "$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__7__$WBIrr~FJQGaywM0EFL_~lQ"} true; + assume (R8[1:0] == 1bv1); + goto $main$__7__$WBIrr~FJQGaywM0EFL_~lQ; + $main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__3__$BN0TEK1EQNeAY2qOwIEG5g: + assume {:captureState "$main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__3__$BN0TEK1EQNeAY2qOwIEG5g"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__3__$BN0TEK1EQNeAY2qOwIEG5g; + $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__0: + assume {:captureState "$main$__2__$A0okiAJhRZaNrB4lOPZtTw$__0"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__7__$WBIrr~FJQGaywM0EFL_~lQ, $main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__3__$BN0TEK1EQNeAY2qOwIEG5g; + $main$__2__$A0okiAJhRZaNrB4lOPZtTw$__1: + assume {:captureState "$main$__2__$A0okiAJhRZaNrB4lOPZtTw$__1"} true; + assume (!(!(ZF == 1bv1))); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__7__$WBIrr~FJQGaywM0EFL_~lQ, $main$__2__$A0okiAJhRZaNrB4lOPZtTw_goto_$main$__3__$BN0TEK1EQNeAY2qOwIEG5g; + $main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__6__$f4nhHXxoReqZDuDK6zxsSQ: + assume {:captureState "$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__6__$f4nhHXxoReqZDuDK6zxsSQ"} true; + assume (R8[1:0] == 1bv1); + goto $main$__6__$f4nhHXxoReqZDuDK6zxsSQ; + $main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__1__$9glsOoBtTsagmZpc7KXoEQ: + assume {:captureState "$main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__1__$9glsOoBtTsagmZpc7KXoEQ"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$9glsOoBtTsagmZpc7KXoEQ; + $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__0: + assume {:captureState "$main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__0"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__6__$f4nhHXxoReqZDuDK6zxsSQ, $main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__1__$9glsOoBtTsagmZpc7KXoEQ; + $main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__1: + assume {:captureState "$main$__0__$G_1Y6jALRC~8UvxN~Oh74A$__1"} true; + assume (!(!(ZF == 1bv1))); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__6__$f4nhHXxoReqZDuDK6zxsSQ, $main$__0__$G_1Y6jALRC~8UvxN~Oh74A_goto_$main$__1__$9glsOoBtTsagmZpc7KXoEQ; + $main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__8__$MFGHilZOSS~y6mrYfWAhnQ: + assume {:captureState "$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__8__$MFGHilZOSS~y6mrYfWAhnQ"} true; + assume (R8[1:0] == 1bv1); + goto $main$__8__$MFGHilZOSS~y6mrYfWAhnQ; + $main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__5__$tQCpvwKrSeCFPREd7E8FUA: + assume {:captureState "$main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__5__$tQCpvwKrSeCFPREd7E8FUA"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__5__$tQCpvwKrSeCFPREd7E8FUA; + $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__0: + assume {:captureState "$main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__0"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__8__$MFGHilZOSS~y6mrYfWAhnQ, $main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__5__$tQCpvwKrSeCFPREd7E8FUA; + $main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__1: + assume {:captureState "$main$__4__$ZMwLE9GySQC4wAmL8es_Tw$__1"} true; + assume (!(!(ZF == 1bv1))); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__8__$MFGHilZOSS~y6mrYfWAhnQ, $main$__4__$ZMwLE9GySQC4wAmL8es_Tw_goto_$main$__5__$tQCpvwKrSeCFPREd7E8FUA; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out, R9_out := 0bv64, R29_3, R30_3, R31_in, R8_33, R9; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in, Gamma_R8_33, Gamma_R9; + assume {:captureState "main_basil_return"} true; return; } procedure set_two(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2192bv64) == 1bv8); - free requires (memory_load8_le(mem, 2193bv64) == 0bv8); - free requires (memory_load8_le(mem, 2194bv64) == 2bv8); - free requires (memory_load8_le(mem, 2195bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 1960bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 2000bv64); - free requires (memory_load64_le(mem, 69552bv64) == 69684bv64); + modifies Gamma_R8, Gamma_R9, Gamma_mem, R8, R9, mem; + free requires (memory_load32_le(mem, 2192bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69032bv64) == 1936bv64); free requires (memory_load64_le(mem, 69040bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69552bv64) == 69684bv64); free requires (memory_load64_le(mem, 69568bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69576bv64) == 1960bv64); + free requires (memory_load64_le(mem, 69584bv64) == 2000bv64); free requires (memory_load64_le(mem, 69592bv64) == 1980bv64); - free requires (memory_load64_le(mem, 69032bv64) == 1936bv64); - free ensures (memory_load8_le(mem, 2192bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2193bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2194bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2195bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 1960bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 2000bv64); - free ensures (memory_load64_le(mem, 69552bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 2192bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69040bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69552bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69568bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 1960bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 2000bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1980bv64); - free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); implementation set_two() { - var Gamma_R9_2: bool; - var R9_2: bv64; $set_two$__0__$AzAVXZGMSrCSi1E8o7VxfQ: + assume {:captureState "$set_two$__0__$AzAVXZGMSrCSi1E8o7VxfQ"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69552bv64), (gamma_load64(Gamma_mem, 69552bv64) || L(mem, 69552bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4016bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4016bv64)) || L(mem, bvadd64(R9, 4016bv64))); + R8, Gamma_R8 := 2bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 2bv32), gamma_store32(Gamma_mem, R9_2, true); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1952$0"} true; goto set_two_basil_return; set_two_basil_return: + assume {:captureState "set_two_basil_return"} true; return; } diff --git a/src/test/correct/functionpointer/gcc/functionpointer_gtirb.expected b/src/test/correct/functionpointer/gcc/functionpointer_gtirb.expected index f928ab1c2..42c6797e6 100644 --- a/src/test/correct/functionpointer/gcc/functionpointer_gtirb.expected +++ b/src/test/correct/functionpointer/gcc/functionpointer_gtirb.expected @@ -1,28 +1,35 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsgt"} bvsgt32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -32,15 +39,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -51,26 +54,22 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); @@ -78,8 +77,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -93,19 +92,13 @@ procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure set_six(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2052bv64) == 1bv8); - free requires (memory_load8_le(mem, 2053bv64) == 0bv8); - free requires (memory_load8_le(mem, 2054bv64) == 2bv8); - free requires (memory_load8_le(mem, 2055bv64) == 0bv8); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2052bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1884bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); @@ -114,136 +107,204 @@ procedure set_six(); implementation set_six() { $set_six$__0__$fFBUlQZnQASntc8S7REItw: + assume {:captureState "$set_six$__0__$fFBUlQZnQASntc8S7REItw"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 6bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 6bv32), gamma_store32(Gamma_mem, 69652bv64, true); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1848$0"} true; goto set_six_basil_return; set_six_basil_return: + assume {:captureState "set_six_basil_return"} true; return; } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == true); +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R1, R29, R30, R31, VF, ZF, mem, stack; + requires (Gamma_R0 == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 2052bv64) == 1bv8); - free requires (memory_load8_le(mem, 2053bv64) == 0bv8); - free requires (memory_load8_le(mem, 2054bv64) == 2bv8); - free requires (memory_load8_le(mem, 2055bv64) == 0bv8); + free requires (memory_load32_le(mem, 2052bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1884bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_14: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var R0_14: bv64; - var R0_2: bv32; - var R0_3: bv32; - var R0_4: bv32; - var R0_5: bv32; - var R1: bv64; - var R29_3: bv64; - var R30_3: bv64; + var Cse0__5$0$1: bv32; + var Cse0__5$1$1: bv32; + var Cse0__5$10$1: bv32; + var Cse0__5$3$0: bv64; + var Cse0__5$3$4: bv32; + var Gamma_Cse0__5$0$1: bool; + var Gamma_Cse0__5$1$1: bool; + var Gamma_Cse0__5$10$1: bool; + var Gamma_Cse0__5$3$0: bool; + var Gamma_Cse0__5$3$4: bool; $main$__0__$_D9FajgJRbSw2iGYcpsBIw: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551576bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - R0_2, Gamma_R0_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - assert Gamma_R0_2; + assume {:captureState "$main$__0__$_D9FajgJRbSw2iGYcpsBIw"} true; + Cse0__5$3$0, Gamma_Cse0__5$3$0 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$3$0, R29), gamma_store64(Gamma_stack, Cse0__5$3$0, Gamma_R29); + assume {:captureState "1884$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$3$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$3$0, 8bv64), Gamma_R30); + assume {:captureState "1884$2"} true; + R31, Gamma_R31 := Cse0__5$3$0, Gamma_Cse0__5$3$0; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1892$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + Cse0__5$3$4, Gamma_Cse0__5$3$4 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$3$4), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_Cse0__5$3$4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$4), bvadd33(zero_extend1_32(R0[32:0]), 4294967294bv33))), (Gamma_R0 && Gamma_Cse0__5$3$4); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$4, 0bv32), Gamma_Cse0__5$3$4; + NF, Gamma_NF := Cse0__5$3$4[32:31], Gamma_Cse0__5$3$4; + assert Gamma_ZF; goto $main$__0__$_D9FajgJRbSw2iGYcpsBIw_goto_$main$__7__$0vBHGw4KTwa~IJS_dHoKWg, $main$__0__$_D9FajgJRbSw2iGYcpsBIw_goto_$main$__1__$f9ntZhvlQY6oxTWcOq0JTg; - $main$__0__$_D9FajgJRbSw2iGYcpsBIw_goto_$main$__1__$f9ntZhvlQY6oxTWcOq0JTg: - assume (!(R0_2 == 2bv32)); - R0_3, Gamma_R0_3 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - assert Gamma_R0_3; + $main$__1__$f9ntZhvlQY6oxTWcOq0JTg: + assume {:captureState "$main$__1__$f9ntZhvlQY6oxTWcOq0JTg"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + Cse0__5$0$1, Gamma_Cse0__5$0$1 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$0$1), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_Cse0__5$0$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$1), bvadd33(zero_extend1_32(R0[32:0]), 4294967294bv33))), (Gamma_R0 && Gamma_Cse0__5$0$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$1, 0bv32), Gamma_Cse0__5$0$1; + NF, Gamma_NF := Cse0__5$0$1[32:31], Gamma_Cse0__5$0$1; + assert ((Gamma_NF && Gamma_VF) && Gamma_ZF); goto $main$__1__$f9ntZhvlQY6oxTWcOq0JTg_goto_$main$__8__$_yFfkL_NQBGG_4FltkEZPA, $main$__1__$f9ntZhvlQY6oxTWcOq0JTg_goto_$main$__2__$DHZJ7cSQSna~nrpNXjA6pQ; - $main$__1__$f9ntZhvlQY6oxTWcOq0JTg_goto_$main$__2__$DHZJ7cSQSna~nrpNXjA6pQ: - assume bvsle32(R0_3, 2bv32); - R0_4, Gamma_R0_4 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - assert Gamma_R0_4; + $main$__2__$DHZJ7cSQSna~nrpNXjA6pQ: + assume {:captureState "$main$__2__$DHZJ7cSQSna~nrpNXjA6pQ"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + Cse0__5$10$1, Gamma_Cse0__5$10$1 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$10$1, Cse0__5$10$1)), Gamma_Cse0__5$10$1; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$10$1), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$10$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$10$1, 0bv32), Gamma_Cse0__5$10$1; + NF, Gamma_NF := Cse0__5$10$1[32:31], Gamma_Cse0__5$10$1; + assert Gamma_ZF; goto $main$__2__$DHZJ7cSQSna~nrpNXjA6pQ_goto_$main$__5__$3a21fgw4S6uXIwvw1rvH7A, $main$__2__$DHZJ7cSQSna~nrpNXjA6pQ_goto_$main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w; - $main$__2__$DHZJ7cSQSna~nrpNXjA6pQ_goto_$main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w: - assume (!(R0_4 == 0bv32)); - R0_5, Gamma_R0_5 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - assert Gamma_R0_5; + $main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w: + assume {:captureState "$main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + Cse0__5$1$1, Gamma_Cse0__5$1$1 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$1$1), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_Cse0__5$1$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$1$1), bvadd33(zero_extend1_32(R0[32:0]), 4294967295bv33))), (Gamma_R0 && Gamma_Cse0__5$1$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$1$1, 0bv32), Gamma_Cse0__5$1$1; + NF, Gamma_NF := Cse0__5$1$1[32:31], Gamma_Cse0__5$1$1; + assert Gamma_ZF; goto $main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w_goto_$main$__6__$c0TNLKEPT3GkfwAOFWCdMw, $main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w_goto_$main$__4__$3NbhKlSfRPah6thY7nGsGQ; - $main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w_goto_$main$__4__$3NbhKlSfRPah6thY7nGsGQ: - assume (!(R0_5 == 1bv32)); + $main$__4__$3NbhKlSfRPah6thY7nGsGQ: + assume {:captureState "$main$__4__$3NbhKlSfRPah6thY7nGsGQ"} true; goto $main$__8__$_yFfkL_NQBGG_4FltkEZPA; - $main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w_goto_$main$__6__$c0TNLKEPT3GkfwAOFWCdMw: - assume (R0_5 == 1bv32); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 1836bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + $main$__5__$3a21fgw4S6uXIwvw1rvH7A: + assume {:captureState "$main$__5__$3a21fgw4S6uXIwvw1rvH7A"} true; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 1812bv64), Gamma_R0; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "1956$0"} true; goto $main$__9__$N87MnmJ9SDqTYx5EXy~u6g; - $main$__2__$DHZJ7cSQSna~nrpNXjA6pQ_goto_$main$__5__$3a21fgw4S6uXIwvw1rvH7A: - assume (R0_4 == 0bv32); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 1812bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + $main$__6__$c0TNLKEPT3GkfwAOFWCdMw: + assume {:captureState "$main$__6__$c0TNLKEPT3GkfwAOFWCdMw"} true; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 1836bv64), Gamma_R0; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "1972$0"} true; goto $main$__9__$N87MnmJ9SDqTYx5EXy~u6g; - $main$__1__$f9ntZhvlQY6oxTWcOq0JTg_goto_$main$__8__$_yFfkL_NQBGG_4FltkEZPA: - assume bvsgt32(R0_3, 2bv32); - goto $main$__8__$_yFfkL_NQBGG_4FltkEZPA; - $main$__8__$_yFfkL_NQBGG_4FltkEZPA: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 1812bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + $main$__7__$0vBHGw4KTwa~IJS_dHoKWg: + assume {:captureState "$main$__7__$0vBHGw4KTwa~IJS_dHoKWg"} true; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 1860bv64), Gamma_R0; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "1988$0"} true; goto $main$__9__$N87MnmJ9SDqTYx5EXy~u6g; - $main$__0__$_D9FajgJRbSw2iGYcpsBIw_goto_$main$__7__$0vBHGw4KTwa~IJS_dHoKWg: - assume (R0_2 == 2bv32); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 1860bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + $main$__8__$_yFfkL_NQBGG_4FltkEZPA: + assume {:captureState "$main$__8__$_yFfkL_NQBGG_4FltkEZPA"} true; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 1812bv64), Gamma_R0; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "2004$0"} true; goto $main$__9__$N87MnmJ9SDqTYx5EXy~u6g; $main$__9__$N87MnmJ9SDqTYx5EXy~u6g: - R0_14, Gamma_R0_14 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__9__$N87MnmJ9SDqTYx5EXy~u6g"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R30, Gamma_R30 := 2020bv64, true; goto $main$__9__$N87MnmJ9SDqTYx5EXy~u6g$set_seven, $main$__9__$N87MnmJ9SDqTYx5EXy~u6g$set_two, $main$__9__$N87MnmJ9SDqTYx5EXy~u6g$set_six; - $main$__9__$N87MnmJ9SDqTYx5EXy~u6g$set_six: - assume (R0_14 == 1836bv64); - call set_six(); + $main$__10__$Y1PxorE9TmC2XsQ0OMAzBg: + assume {:captureState "$main$__10__$Y1PxorE9TmC2XsQ0OMAzBg"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; + goto main_basil_return; + $main$__1__$f9ntZhvlQY6oxTWcOq0JTg_goto_$main$__8__$_yFfkL_NQBGG_4FltkEZPA: + assume {:captureState "$main$__1__$f9ntZhvlQY6oxTWcOq0JTg_goto_$main$__8__$_yFfkL_NQBGG_4FltkEZPA"} true; + assume ((NF == VF) && (ZF == 0bv1)); + goto $main$__8__$_yFfkL_NQBGG_4FltkEZPA; + $main$__1__$f9ntZhvlQY6oxTWcOq0JTg_goto_$main$__2__$DHZJ7cSQSna~nrpNXjA6pQ: + assume {:captureState "$main$__1__$f9ntZhvlQY6oxTWcOq0JTg_goto_$main$__2__$DHZJ7cSQSna~nrpNXjA6pQ"} true; + assume (!((NF == VF) && (ZF == 0bv1))); + goto $main$__2__$DHZJ7cSQSna~nrpNXjA6pQ; + $main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w_goto_$main$__6__$c0TNLKEPT3GkfwAOFWCdMw: + assume {:captureState "$main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w_goto_$main$__6__$c0TNLKEPT3GkfwAOFWCdMw"} true; + assume (ZF == 1bv1); + goto $main$__6__$c0TNLKEPT3GkfwAOFWCdMw; + $main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w_goto_$main$__4__$3NbhKlSfRPah6thY7nGsGQ: + assume {:captureState "$main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w_goto_$main$__4__$3NbhKlSfRPah6thY7nGsGQ"} true; + assume (!(ZF == 1bv1)); + goto $main$__4__$3NbhKlSfRPah6thY7nGsGQ; + $main$__0__$_D9FajgJRbSw2iGYcpsBIw_goto_$main$__7__$0vBHGw4KTwa~IJS_dHoKWg: + assume {:captureState "$main$__0__$_D9FajgJRbSw2iGYcpsBIw_goto_$main$__7__$0vBHGw4KTwa~IJS_dHoKWg"} true; + assume (ZF == 1bv1); + goto $main$__7__$0vBHGw4KTwa~IJS_dHoKWg; + $main$__0__$_D9FajgJRbSw2iGYcpsBIw_goto_$main$__1__$f9ntZhvlQY6oxTWcOq0JTg: + assume {:captureState "$main$__0__$_D9FajgJRbSw2iGYcpsBIw_goto_$main$__1__$f9ntZhvlQY6oxTWcOq0JTg"} true; + assume (!(ZF == 1bv1)); + goto $main$__1__$f9ntZhvlQY6oxTWcOq0JTg; + $main$__9__$N87MnmJ9SDqTYx5EXy~u6g$set_seven: + assume {:captureState "$main$__9__$N87MnmJ9SDqTYx5EXy~u6g$set_seven"} true; + assume (R0 == 1860bv64); + call set_seven(); goto $main$__10__$Y1PxorE9TmC2XsQ0OMAzBg; $main$__9__$N87MnmJ9SDqTYx5EXy~u6g$set_two: - assume (R0_14 == 1812bv64); + assume {:captureState "$main$__9__$N87MnmJ9SDqTYx5EXy~u6g$set_two"} true; + assume (R0 == 1812bv64); call set_two(); goto $main$__10__$Y1PxorE9TmC2XsQ0OMAzBg; - $main$__9__$N87MnmJ9SDqTYx5EXy~u6g$set_seven: - assume (R0_14 == 1860bv64); - call set_seven(); + $main$__9__$N87MnmJ9SDqTYx5EXy~u6g$set_six: + assume {:captureState "$main$__9__$N87MnmJ9SDqTYx5EXy~u6g$set_six"} true; + assume (R0 == 1836bv64); + call set_six(); goto $main$__10__$Y1PxorE9TmC2XsQ0OMAzBg; - $main$__10__$Y1PxorE9TmC2XsQ0OMAzBg: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551568bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551576bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64)); - goto main_basil_return; + $main$__2__$DHZJ7cSQSna~nrpNXjA6pQ_goto_$main$__5__$3a21fgw4S6uXIwvw1rvH7A: + assume {:captureState "$main$__2__$DHZJ7cSQSna~nrpNXjA6pQ_goto_$main$__5__$3a21fgw4S6uXIwvw1rvH7A"} true; + assume (ZF == 1bv1); + goto $main$__5__$3a21fgw4S6uXIwvw1rvH7A; + $main$__2__$DHZJ7cSQSna~nrpNXjA6pQ_goto_$main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w: + assume {:captureState "$main$__2__$DHZJ7cSQSna~nrpNXjA6pQ_goto_$main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w"} true; + assume (!(ZF == 1bv1)); + goto $main$__3__$Y~lfjyGjQ_WvS7i15Hyi6w; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1, R29_3, R30_3, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } procedure set_seven(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2052bv64) == 1bv8); - free requires (memory_load8_le(mem, 2053bv64) == 0bv8); - free requires (memory_load8_le(mem, 2054bv64) == 2bv8); - free requires (memory_load8_le(mem, 2055bv64) == 0bv8); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2052bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1884bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); @@ -252,28 +313,28 @@ procedure set_seven(); implementation set_seven() { $set_seven$__0__$N5CM0prJRzCc8vJXtN888g: + assume {:captureState "$set_seven$__0__$N5CM0prJRzCc8vJXtN888g"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 7bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 7bv32), gamma_store32(Gamma_mem, 69652bv64, true); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1872$0"} true; goto set_seven_basil_return; set_seven_basil_return: + assume {:captureState "set_seven_basil_return"} true; return; } procedure set_two(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2052bv64) == 1bv8); - free requires (memory_load8_le(mem, 2053bv64) == 0bv8); - free requires (memory_load8_le(mem, 2054bv64) == 2bv8); - free requires (memory_load8_le(mem, 2055bv64) == 0bv8); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2052bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1884bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1884bv64); @@ -282,11 +343,17 @@ procedure set_two(); implementation set_two() { $set_two$__0__$pAd9qDTFTLWR4Wy64dKK0A: + assume {:captureState "$set_two$__0__$pAd9qDTFTLWR4Wy64dKK0A"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 2bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 2bv32), gamma_store32(Gamma_mem, 69652bv64, true); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1824$0"} true; goto set_two_basil_return; set_two_basil_return: + assume {:captureState "set_two_basil_return"} true; return; } diff --git a/src/test/correct/functionpointer/gcc_O2/functionpointer_gtirb.expected b/src/test/correct/functionpointer/gcc_O2/functionpointer_gtirb.expected index 6daa3cf65..5efba0883 100644 --- a/src/test/correct/functionpointer/gcc_O2/functionpointer_gtirb.expected +++ b/src/test/correct/functionpointer/gcc_O2/functionpointer_gtirb.expected @@ -1,66 +1,70 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2020bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2021bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2022bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2023bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2020bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -68,8 +72,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -83,19 +87,13 @@ procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure set_six(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2020bv64) == 1bv8); - free requires (memory_load8_le(mem, 2021bv64) == 0bv8); - free requires (memory_load8_le(mem, 2022bv64) == 2bv8); - free requires (memory_load8_le(mem, 2023bv64) == 0bv8); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2020bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1936bv64); free requires (memory_load64_le(mem, 69024bv64) == 1856bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2020bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2021bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2022bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2023bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2020bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -104,77 +102,113 @@ procedure set_six(); implementation set_six() { $set_six$__0__$dX4gaI1OSUabhEuG9un0cA: + assume {:captureState "$set_six$__0__$dX4gaI1OSUabhEuG9un0cA"} true; + R0, Gamma_R0 := 69632bv64, true; + R1, Gamma_R1 := 6bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 6bv32), gamma_store32(Gamma_mem, 69652bv64, true); + assert (L(mem, bvadd64(R0, 20bv64)) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 20bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 20bv64), Gamma_R1); + assume {:captureState "1976$0"} true; goto set_six_basil_return; set_six_basil_return: + assume {:captureState "set_six_basil_return"} true; return; } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == true); +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R1, R29, R30, R31, VF, ZF, mem, stack; + requires (Gamma_R0 == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 2020bv64) == 1bv8); - free requires (memory_load8_le(mem, 2021bv64) == 0bv8); - free requires (memory_load8_le(mem, 2022bv64) == 2bv8); - free requires (memory_load8_le(mem, 2023bv64) == 0bv8); + free requires (memory_load32_le(mem, 2020bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1936bv64); free requires (memory_load64_le(mem, 69024bv64) == 1856bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2020bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2021bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2022bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2023bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2020bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R1: bool; - var Gamma_R1_5: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var R1: bv64; - var R1_5: bv64; - var R29_3: bv64; - var R30_3: bv64; + var Cse0__5$0$0: bv64; + var Cse0__5$0$2: bv32; + var Cse0__5$1$0: bv32; + var Gamma_Cse0__5$0$0: bool; + var Gamma_Cse0__5$0$2: bool; + var Gamma_Cse0__5$1$0: bool; $main$__0__$eOh8YVTlQnKonp~fpb5jKw: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - assert Gamma_R0_in; + assume {:captureState "$main$__0__$eOh8YVTlQnKonp~fpb5jKw"} true; + Cse0__5$0$0, Gamma_Cse0__5$0$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$0, R29), gamma_store64(Gamma_stack, Cse0__5$0$0, Gamma_R29); + assume {:captureState "1536$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$0, 8bv64), Gamma_R30); + assume {:captureState "1536$2"} true; + R31, Gamma_R31 := Cse0__5$0$0, Gamma_Cse0__5$0$0; + R29, Gamma_R29 := R31, Gamma_R31; + Cse0__5$0$2, Gamma_Cse0__5$0$2 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$0$2), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_Cse0__5$0$2); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$2), bvadd33(zero_extend1_32(R0[32:0]), 4294967295bv33))), (Gamma_R0 && Gamma_Cse0__5$0$2); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$2, 0bv32), Gamma_Cse0__5$0$2; + NF, Gamma_NF := Cse0__5$0$2[32:31], Gamma_Cse0__5$0$2; + assert Gamma_ZF; goto $main$__0__$eOh8YVTlQnKonp~fpb5jKw_goto_$main$__4__$S8383WrHT8i~O1Ieq4qHoA, $main$__0__$eOh8YVTlQnKonp~fpb5jKw_goto_$main$__1__$ca5W8ecrTdSh_xILQFKWFg; - $main$__0__$eOh8YVTlQnKonp~fpb5jKw_goto_$main$__1__$ca5W8ecrTdSh_xILQFKWFg: - assume (!(R0_in[32:0] == 1bv32)); - assert Gamma_R0_in; + $main$__1__$ca5W8ecrTdSh_xILQFKWFg: + assume {:captureState "$main$__1__$ca5W8ecrTdSh_xILQFKWFg"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$1$0), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_Cse0__5$1$0); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$1$0), bvadd33(zero_extend1_32(R0[32:0]), 4294967294bv33))), (Gamma_R0 && Gamma_Cse0__5$1$0); + ZF, Gamma_ZF := bvcomp32(Cse0__5$1$0, 0bv32), Gamma_Cse0__5$1$0; + NF, Gamma_NF := Cse0__5$1$0[32:31], Gamma_Cse0__5$1$0; + R1, Gamma_R1 := 0bv64, true; + R0, Gamma_R0 := 0bv64, true; + R1, Gamma_R1 := bvadd64(R1, 1984bv64), Gamma_R1; + R0, Gamma_R0 := bvadd64(R0, 1952bv64), Gamma_R0; + assert Gamma_ZF; goto $main$__1__$ca5W8ecrTdSh_xILQFKWFg$__0, $main$__1__$ca5W8ecrTdSh_xILQFKWFg$__1; - $main$__1__$ca5W8ecrTdSh_xILQFKWFg$__1: - assume (R0_in[32:0] == 2bv32); - R1_5, Gamma_R1_5 := 1984bv64, true; - goto $main$__2__$fEZ8GKsISKaOAJptXmofmg; - $main$__1__$ca5W8ecrTdSh_xILQFKWFg$__0: - assume (!(R0_in[32:0] == 2bv32)); - R1_5, Gamma_R1_5 := 1984bv64, true; - goto $main$__2__$fEZ8GKsISKaOAJptXmofmg; - $main$__0__$eOh8YVTlQnKonp~fpb5jKw_goto_$main$__4__$S8383WrHT8i~O1Ieq4qHoA: - assume (R0_in[32:0] == 1bv32); - R1_5, Gamma_R1_5 := R1, Gamma_R1; - goto $main$__2__$fEZ8GKsISKaOAJptXmofmg; $main$__2__$fEZ8GKsISKaOAJptXmofmg: + assume {:captureState "$main$__2__$fEZ8GKsISKaOAJptXmofmg"} true; + R30, Gamma_R30 := 1580bv64, true; call set_six(); goto $main$__3__$F~EXshFNSrygGBX5dfkWLg; $main$__3__$F~EXshFNSrygGBX5dfkWLg: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__3__$F~EXshFNSrygGBX5dfkWLg"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__4__$S8383WrHT8i~O1Ieq4qHoA: + assume {:captureState "$main$__4__$S8383WrHT8i~O1Ieq4qHoA"} true; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 1968bv64), Gamma_R0; + goto $main$__2__$fEZ8GKsISKaOAJptXmofmg; + $main$__0__$eOh8YVTlQnKonp~fpb5jKw_goto_$main$__4__$S8383WrHT8i~O1Ieq4qHoA: + assume {:captureState "$main$__0__$eOh8YVTlQnKonp~fpb5jKw_goto_$main$__4__$S8383WrHT8i~O1Ieq4qHoA"} true; + assume (ZF == 1bv1); + goto $main$__4__$S8383WrHT8i~O1Ieq4qHoA; + $main$__0__$eOh8YVTlQnKonp~fpb5jKw_goto_$main$__1__$ca5W8ecrTdSh_xILQFKWFg: + assume {:captureState "$main$__0__$eOh8YVTlQnKonp~fpb5jKw_goto_$main$__1__$ca5W8ecrTdSh_xILQFKWFg"} true; + assume (!(ZF == 1bv1)); + goto $main$__1__$ca5W8ecrTdSh_xILQFKWFg; + $main$__1__$ca5W8ecrTdSh_xILQFKWFg$__0: + assume {:captureState "$main$__1__$ca5W8ecrTdSh_xILQFKWFg$__0"} true; + assume (!(ZF == 1bv1)); + R0, Gamma_R0 := R0, Gamma_R0; + goto $main$__2__$fEZ8GKsISKaOAJptXmofmg; + $main$__1__$ca5W8ecrTdSh_xILQFKWFg$__1: + assume {:captureState "$main$__1__$ca5W8ecrTdSh_xILQFKWFg$__1"} true; + assume (!(!(ZF == 1bv1))); + R0, Gamma_R0 := R1, Gamma_R1; + goto $main$__2__$fEZ8GKsISKaOAJptXmofmg; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_5, R29_3, R30_3, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_5, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/functionpointer/gcc_pic/functionpointer_gtirb.expected b/src/test/correct/functionpointer/gcc_pic/functionpointer_gtirb.expected index f70f1a33d..3e7676341 100644 --- a/src/test/correct/functionpointer/gcc_pic/functionpointer_gtirb.expected +++ b/src/test/correct/functionpointer/gcc_pic/functionpointer_gtirb.expected @@ -1,28 +1,35 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsgt"} bvsgt32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -32,15 +39,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -51,39 +54,35 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2180bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2181bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2182bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2183bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69576bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1988bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 1964bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2180bv64) == 131073bv32); free ensures (memory_load64_le(mem, 68984bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69652bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 1964bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 2012bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1988bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -97,260 +96,307 @@ procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure set_seven(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2180bv64) == 1bv8); - free requires (memory_load8_le(mem, 2181bv64) == 0bv8); - free requires (memory_load8_le(mem, 2182bv64) == 2bv8); - free requires (memory_load8_le(mem, 2183bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 2012bv64); - free requires (memory_load64_le(mem, 69576bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1988bv64); - free requires (memory_load64_le(mem, 69600bv64) == 1964bv64); - free requires (memory_load64_le(mem, 68992bv64) == 1856bv64); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2180bv64) == 131073bv32); free requires (memory_load64_le(mem, 68984bv64) == 1936bv64); + free requires (memory_load64_le(mem, 68992bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69652bv64); free requires (memory_load64_le(mem, 69592bv64) == 1940bv64); - free ensures (memory_load8_le(mem, 2180bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2181bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2182bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2183bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69576bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1988bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 1964bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69600bv64) == 1964bv64); + free requires (memory_load64_le(mem, 69608bv64) == 2012bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1988bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 2180bv64) == 131073bv32); free ensures (memory_load64_le(mem, 68984bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69652bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 1964bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 2012bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1988bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); implementation set_seven() { - var Gamma_R0_2: bool; - var R0_2: bv64; $set_seven$__0__$L4yUagLBRvmbr9rJ4OG7AA: + assume {:captureState "$set_seven$__0__$L4yUagLBRvmbr9rJ4OG7AA"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4040bv64)) || L(mem, bvadd64(R0, 4040bv64))); + R1, Gamma_R1 := 7bv64, true; call rely(); - assert (L(mem, R0_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_2, 7bv32), gamma_store32(Gamma_mem, R0_2, true); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2000$0"} true; goto set_seven_basil_return; set_seven_basil_return: + assume {:captureState "set_seven_basil_return"} true; return; } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; - requires (Gamma_R0_in == true); +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R1, R29, R30, R31, VF, ZF, mem, stack; + requires (Gamma_R0 == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 2180bv64) == 1bv8); - free requires (memory_load8_le(mem, 2181bv64) == 0bv8); - free requires (memory_load8_le(mem, 2182bv64) == 2bv8); - free requires (memory_load8_le(mem, 2183bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 2012bv64); - free requires (memory_load64_le(mem, 69576bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1988bv64); - free requires (memory_load64_le(mem, 69600bv64) == 1964bv64); - free requires (memory_load64_le(mem, 68992bv64) == 1856bv64); + free requires (memory_load32_le(mem, 2180bv64) == 131073bv32); free requires (memory_load64_le(mem, 68984bv64) == 1936bv64); + free requires (memory_load64_le(mem, 68992bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69652bv64); free requires (memory_load64_le(mem, 69592bv64) == 1940bv64); - free ensures (memory_load8_le(mem, 2180bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2181bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2182bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2183bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69576bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1988bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 1964bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69600bv64) == 1964bv64); + free requires (memory_load64_le(mem, 69608bv64) == 2012bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1988bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2180bv64) == 131073bv32); free ensures (memory_load64_le(mem, 68984bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69652bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 1964bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 2012bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1988bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_11: bool; - var Gamma_R0_13: bool; - var Gamma_R0_14: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_9: bool; - var Gamma_R1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var R0_11: bv64; - var R0_13: bv64; - var R0_14: bv64; - var R0_2: bv32; - var R0_3: bv32; - var R0_4: bv32; - var R0_5: bv32; - var R0_7: bv64; - var R0_9: bv64; - var R1: bv64; - var R29_3: bv64; - var R30_3: bv64; + var Cse0__5$10$0: bv64; + var Cse0__5$10$4: bv32; + var Cse0__5$2$1: bv32; + var Cse0__5$7$1: bv32; + var Cse0__5$8$1: bv32; + var Gamma_Cse0__5$10$0: bool; + var Gamma_Cse0__5$10$4: bool; + var Gamma_Cse0__5$2$1: bool; + var Gamma_Cse0__5$7$1: bool; + var Gamma_Cse0__5$8$1: bool; $main$__0__$mSqeYLPTTSeWCfH6eJwJtA: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551576bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - R0_2, Gamma_R0_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - assert Gamma_R0_2; + assume {:captureState "$main$__0__$mSqeYLPTTSeWCfH6eJwJtA"} true; + Cse0__5$10$0, Gamma_Cse0__5$10$0 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$10$0, R29), gamma_store64(Gamma_stack, Cse0__5$10$0, Gamma_R29); + assume {:captureState "2012$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$10$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$10$0, 8bv64), Gamma_R30); + assume {:captureState "2012$2"} true; + R31, Gamma_R31 := Cse0__5$10$0, Gamma_Cse0__5$10$0; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "2020$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + Cse0__5$10$4, Gamma_Cse0__5$10$4 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$10$4), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_Cse0__5$10$4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$10$4), bvadd33(zero_extend1_32(R0[32:0]), 4294967294bv33))), (Gamma_R0 && Gamma_Cse0__5$10$4); + ZF, Gamma_ZF := bvcomp32(Cse0__5$10$4, 0bv32), Gamma_Cse0__5$10$4; + NF, Gamma_NF := Cse0__5$10$4[32:31], Gamma_Cse0__5$10$4; + assert Gamma_ZF; goto $main$__0__$mSqeYLPTTSeWCfH6eJwJtA_goto_$main$__7__$CM1tpRQfSBKhPNKoMwfCqQ, $main$__0__$mSqeYLPTTSeWCfH6eJwJtA_goto_$main$__1__$Itcc9ikmRriat4P2PfBY9Q; - $main$__0__$mSqeYLPTTSeWCfH6eJwJtA_goto_$main$__1__$Itcc9ikmRriat4P2PfBY9Q: - assume (!(R0_2 == 2bv32)); - R0_3, Gamma_R0_3 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - assert Gamma_R0_3; + $main$__1__$Itcc9ikmRriat4P2PfBY9Q: + assume {:captureState "$main$__1__$Itcc9ikmRriat4P2PfBY9Q"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + Cse0__5$8$1, Gamma_Cse0__5$8$1 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$8$1), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_Cse0__5$8$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$8$1), bvadd33(zero_extend1_32(R0[32:0]), 4294967294bv33))), (Gamma_R0 && Gamma_Cse0__5$8$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$8$1, 0bv32), Gamma_Cse0__5$8$1; + NF, Gamma_NF := Cse0__5$8$1[32:31], Gamma_Cse0__5$8$1; + assert ((Gamma_NF && Gamma_VF) && Gamma_ZF); goto $main$__1__$Itcc9ikmRriat4P2PfBY9Q_goto_$main$__8__$sD4BTrlRTieCvvugZUYF7A, $main$__1__$Itcc9ikmRriat4P2PfBY9Q_goto_$main$__2__$1AJ~HowZR3iJDHcHLtAuzQ; - $main$__1__$Itcc9ikmRriat4P2PfBY9Q_goto_$main$__2__$1AJ~HowZR3iJDHcHLtAuzQ: - assume bvsle32(R0_3, 2bv32); - R0_4, Gamma_R0_4 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - assert Gamma_R0_4; + $main$__2__$1AJ~HowZR3iJDHcHLtAuzQ: + assume {:captureState "$main$__2__$1AJ~HowZR3iJDHcHLtAuzQ"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + Cse0__5$2$1, Gamma_Cse0__5$2$1 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$2$1, Cse0__5$2$1)), Gamma_Cse0__5$2$1; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$2$1), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$2$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$2$1, 0bv32), Gamma_Cse0__5$2$1; + NF, Gamma_NF := Cse0__5$2$1[32:31], Gamma_Cse0__5$2$1; + assert Gamma_ZF; goto $main$__2__$1AJ~HowZR3iJDHcHLtAuzQ_goto_$main$__5__$cPLOwypmRFeVmHCrCFAc_g, $main$__2__$1AJ~HowZR3iJDHcHLtAuzQ_goto_$main$__3__$09_lQb5MT_SJaYe07Vmc_g; - $main$__2__$1AJ~HowZR3iJDHcHLtAuzQ_goto_$main$__3__$09_lQb5MT_SJaYe07Vmc_g: - assume (!(R0_4 == 0bv32)); - R0_5, Gamma_R0_5 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - assert Gamma_R0_5; + $main$__3__$09_lQb5MT_SJaYe07Vmc_g: + assume {:captureState "$main$__3__$09_lQb5MT_SJaYe07Vmc_g"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + Cse0__5$7$1, Gamma_Cse0__5$7$1 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$7$1), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_Cse0__5$7$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$7$1), bvadd33(zero_extend1_32(R0[32:0]), 4294967295bv33))), (Gamma_R0 && Gamma_Cse0__5$7$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$7$1, 0bv32), Gamma_Cse0__5$7$1; + NF, Gamma_NF := Cse0__5$7$1[32:31], Gamma_Cse0__5$7$1; + assert Gamma_ZF; goto $main$__3__$09_lQb5MT_SJaYe07Vmc_g_goto_$main$__6__$SujlhOerQhygmgKHSc1XZw, $main$__3__$09_lQb5MT_SJaYe07Vmc_g_goto_$main$__4__$Bt04V5oVRaOM5Ip3wRkfUw; - $main$__3__$09_lQb5MT_SJaYe07Vmc_g_goto_$main$__4__$Bt04V5oVRaOM5Ip3wRkfUw: - assume (!(R0_5 == 1bv32)); + $main$__4__$Bt04V5oVRaOM5Ip3wRkfUw: + assume {:captureState "$main$__4__$Bt04V5oVRaOM5Ip3wRkfUw"} true; goto $main$__8__$sD4BTrlRTieCvvugZUYF7A; - $main$__3__$09_lQb5MT_SJaYe07Vmc_g_goto_$main$__6__$SujlhOerQhygmgKHSc1XZw: - assume (R0_5 == 1bv32); + $main$__5__$cPLOwypmRFeVmHCrCFAc_g: + assume {:captureState "$main$__5__$cPLOwypmRFeVmHCrCFAc_g"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_7), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_7); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "2084$0"} true; goto $main$__9__$7RwlIZnASouKYJ2frkUUKw; - $main$__2__$1AJ~HowZR3iJDHcHLtAuzQ_goto_$main$__5__$cPLOwypmRFeVmHCrCFAc_g: - assume (R0_4 == 0bv32); + $main$__6__$SujlhOerQhygmgKHSc1XZw: + assume {:captureState "$main$__6__$SujlhOerQhygmgKHSc1XZw"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_9, Gamma_R0_9 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_9), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_9); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "2100$0"} true; goto $main$__9__$7RwlIZnASouKYJ2frkUUKw; - $main$__1__$Itcc9ikmRriat4P2PfBY9Q_goto_$main$__8__$sD4BTrlRTieCvvugZUYF7A: - assume bvsgt32(R0_3, 2bv32); - goto $main$__8__$sD4BTrlRTieCvvugZUYF7A; - $main$__8__$sD4BTrlRTieCvvugZUYF7A: + $main$__7__$CM1tpRQfSBKhPNKoMwfCqQ: + assume {:captureState "$main$__7__$CM1tpRQfSBKhPNKoMwfCqQ"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_11, Gamma_R0_11 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_11), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_11); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4080bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4080bv64)) || L(mem, bvadd64(R0, 4080bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "2116$0"} true; goto $main$__9__$7RwlIZnASouKYJ2frkUUKw; - $main$__0__$mSqeYLPTTSeWCfH6eJwJtA_goto_$main$__7__$CM1tpRQfSBKhPNKoMwfCqQ: - assume (R0_2 == 2bv32); + $main$__8__$sD4BTrlRTieCvvugZUYF7A: + assume {:captureState "$main$__8__$sD4BTrlRTieCvvugZUYF7A"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_13, Gamma_R0_13 := memory_load64_le(mem, 69616bv64), (gamma_load64(Gamma_mem, 69616bv64) || L(mem, 69616bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_13), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_13); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "2132$0"} true; goto $main$__9__$7RwlIZnASouKYJ2frkUUKw; $main$__9__$7RwlIZnASouKYJ2frkUUKw: - R0_14, Gamma_R0_14 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__9__$7RwlIZnASouKYJ2frkUUKw"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R30, Gamma_R30 := 2148bv64, true; goto $main$__9__$7RwlIZnASouKYJ2frkUUKw$set_six, $main$__9__$7RwlIZnASouKYJ2frkUUKw$set_two, $main$__9__$7RwlIZnASouKYJ2frkUUKw$set_seven; - $main$__9__$7RwlIZnASouKYJ2frkUUKw$set_seven: - assume (R0_14 == 1988bv64); - call set_seven(); + $main$__10__$~6BcLPrzR_qqeDcEFjH5oA: + assume {:captureState "$main$__10__$~6BcLPrzR_qqeDcEFjH5oA"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; + goto main_basil_return; + $main$__2__$1AJ~HowZR3iJDHcHLtAuzQ_goto_$main$__5__$cPLOwypmRFeVmHCrCFAc_g: + assume {:captureState "$main$__2__$1AJ~HowZR3iJDHcHLtAuzQ_goto_$main$__5__$cPLOwypmRFeVmHCrCFAc_g"} true; + assume (ZF == 1bv1); + goto $main$__5__$cPLOwypmRFeVmHCrCFAc_g; + $main$__2__$1AJ~HowZR3iJDHcHLtAuzQ_goto_$main$__3__$09_lQb5MT_SJaYe07Vmc_g: + assume {:captureState "$main$__2__$1AJ~HowZR3iJDHcHLtAuzQ_goto_$main$__3__$09_lQb5MT_SJaYe07Vmc_g"} true; + assume (!(ZF == 1bv1)); + goto $main$__3__$09_lQb5MT_SJaYe07Vmc_g; + $main$__9__$7RwlIZnASouKYJ2frkUUKw$set_six: + assume {:captureState "$main$__9__$7RwlIZnASouKYJ2frkUUKw$set_six"} true; + assume (R0 == 1964bv64); + call set_six(); goto $main$__10__$~6BcLPrzR_qqeDcEFjH5oA; $main$__9__$7RwlIZnASouKYJ2frkUUKw$set_two: - assume (R0_14 == 1940bv64); + assume {:captureState "$main$__9__$7RwlIZnASouKYJ2frkUUKw$set_two"} true; + assume (R0 == 1940bv64); call set_two(); goto $main$__10__$~6BcLPrzR_qqeDcEFjH5oA; - $main$__9__$7RwlIZnASouKYJ2frkUUKw$set_six: - assume (R0_14 == 1964bv64); - call set_six(); + $main$__9__$7RwlIZnASouKYJ2frkUUKw$set_seven: + assume {:captureState "$main$__9__$7RwlIZnASouKYJ2frkUUKw$set_seven"} true; + assume (R0 == 1988bv64); + call set_seven(); goto $main$__10__$~6BcLPrzR_qqeDcEFjH5oA; - $main$__10__$~6BcLPrzR_qqeDcEFjH5oA: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551568bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551576bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64)); - goto main_basil_return; + $main$__3__$09_lQb5MT_SJaYe07Vmc_g_goto_$main$__6__$SujlhOerQhygmgKHSc1XZw: + assume {:captureState "$main$__3__$09_lQb5MT_SJaYe07Vmc_g_goto_$main$__6__$SujlhOerQhygmgKHSc1XZw"} true; + assume (ZF == 1bv1); + goto $main$__6__$SujlhOerQhygmgKHSc1XZw; + $main$__3__$09_lQb5MT_SJaYe07Vmc_g_goto_$main$__4__$Bt04V5oVRaOM5Ip3wRkfUw: + assume {:captureState "$main$__3__$09_lQb5MT_SJaYe07Vmc_g_goto_$main$__4__$Bt04V5oVRaOM5Ip3wRkfUw"} true; + assume (!(ZF == 1bv1)); + goto $main$__4__$Bt04V5oVRaOM5Ip3wRkfUw; + $main$__1__$Itcc9ikmRriat4P2PfBY9Q_goto_$main$__8__$sD4BTrlRTieCvvugZUYF7A: + assume {:captureState "$main$__1__$Itcc9ikmRriat4P2PfBY9Q_goto_$main$__8__$sD4BTrlRTieCvvugZUYF7A"} true; + assume ((NF == VF) && (ZF == 0bv1)); + goto $main$__8__$sD4BTrlRTieCvvugZUYF7A; + $main$__1__$Itcc9ikmRriat4P2PfBY9Q_goto_$main$__2__$1AJ~HowZR3iJDHcHLtAuzQ: + assume {:captureState "$main$__1__$Itcc9ikmRriat4P2PfBY9Q_goto_$main$__2__$1AJ~HowZR3iJDHcHLtAuzQ"} true; + assume (!((NF == VF) && (ZF == 0bv1))); + goto $main$__2__$1AJ~HowZR3iJDHcHLtAuzQ; + $main$__0__$mSqeYLPTTSeWCfH6eJwJtA_goto_$main$__7__$CM1tpRQfSBKhPNKoMwfCqQ: + assume {:captureState "$main$__0__$mSqeYLPTTSeWCfH6eJwJtA_goto_$main$__7__$CM1tpRQfSBKhPNKoMwfCqQ"} true; + assume (ZF == 1bv1); + goto $main$__7__$CM1tpRQfSBKhPNKoMwfCqQ; + $main$__0__$mSqeYLPTTSeWCfH6eJwJtA_goto_$main$__1__$Itcc9ikmRriat4P2PfBY9Q: + assume {:captureState "$main$__0__$mSqeYLPTTSeWCfH6eJwJtA_goto_$main$__1__$Itcc9ikmRriat4P2PfBY9Q"} true; + assume (!(ZF == 1bv1)); + goto $main$__1__$Itcc9ikmRriat4P2PfBY9Q; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1, R29_3, R30_3, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } procedure set_two(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2180bv64) == 1bv8); - free requires (memory_load8_le(mem, 2181bv64) == 0bv8); - free requires (memory_load8_le(mem, 2182bv64) == 2bv8); - free requires (memory_load8_le(mem, 2183bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 2012bv64); - free requires (memory_load64_le(mem, 69576bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1988bv64); - free requires (memory_load64_le(mem, 69600bv64) == 1964bv64); - free requires (memory_load64_le(mem, 68992bv64) == 1856bv64); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2180bv64) == 131073bv32); free requires (memory_load64_le(mem, 68984bv64) == 1936bv64); + free requires (memory_load64_le(mem, 68992bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69652bv64); free requires (memory_load64_le(mem, 69592bv64) == 1940bv64); - free ensures (memory_load8_le(mem, 2180bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2181bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2182bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2183bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69576bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1988bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 1964bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69600bv64) == 1964bv64); + free requires (memory_load64_le(mem, 69608bv64) == 2012bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1988bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 2180bv64) == 131073bv32); free ensures (memory_load64_le(mem, 68984bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69652bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 1964bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 2012bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1988bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); implementation set_two() { - var Gamma_R0_2: bool; - var R0_2: bv64; $set_two$__0__$pc4EEuLAT5~NeDl373acBA: + assume {:captureState "$set_two$__0__$pc4EEuLAT5~NeDl373acBA"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4040bv64)) || L(mem, bvadd64(R0, 4040bv64))); + R1, Gamma_R1 := 2bv64, true; call rely(); - assert (L(mem, R0_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_2, 2bv32), gamma_store32(Gamma_mem, R0_2, true); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1952$0"} true; goto set_two_basil_return; set_two_basil_return: + assume {:captureState "set_two_basil_return"} true; return; } procedure set_six(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2180bv64) == 1bv8); - free requires (memory_load8_le(mem, 2181bv64) == 0bv8); - free requires (memory_load8_le(mem, 2182bv64) == 2bv8); - free requires (memory_load8_le(mem, 2183bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 2012bv64); - free requires (memory_load64_le(mem, 69576bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1988bv64); - free requires (memory_load64_le(mem, 69600bv64) == 1964bv64); - free requires (memory_load64_le(mem, 68992bv64) == 1856bv64); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2180bv64) == 131073bv32); free requires (memory_load64_le(mem, 68984bv64) == 1936bv64); + free requires (memory_load64_le(mem, 68992bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69652bv64); free requires (memory_load64_le(mem, 69592bv64) == 1940bv64); - free ensures (memory_load8_le(mem, 2180bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2181bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2182bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2183bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69576bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1988bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 1964bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69600bv64) == 1964bv64); + free requires (memory_load64_le(mem, 69608bv64) == 2012bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1988bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 2180bv64) == 131073bv32); free ensures (memory_load64_le(mem, 68984bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69652bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 1964bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 2012bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1988bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); implementation set_six() { - var Gamma_R0_2: bool; - var R0_2: bv64; $set_six$__0__$MeJQ5u2GT2qTPkmi76_Clg: + assume {:captureState "$set_six$__0__$MeJQ5u2GT2qTPkmi76_Clg"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4040bv64)) || L(mem, bvadd64(R0, 4040bv64))); + R1, Gamma_R1 := 6bv64, true; call rely(); - assert (L(mem, R0_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_2, 6bv32), gamma_store32(Gamma_mem, R0_2, true); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1976$0"} true; goto set_six_basil_return; set_six_basil_return: + assume {:captureState "set_six_basil_return"} true; return; } diff --git a/src/test/correct/functions_with_params/clang/functions_with_params.expected b/src/test/correct/functions_with_params/clang/functions_with_params.expected index 52554d286..26a4ae5d6 100644 --- a/src/test/correct/functions_with_params/clang/functions_with_params.expected +++ b/src/test/correct/functions_with_params/clang/functions_with_params.expected @@ -1,25 +1,21 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1912bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,15 +25,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -48,27 +40,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -76,8 +61,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -90,91 +75,93 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_stack, R0, R29, R30, R31, R8, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1912bv64) == 1bv8); - free requires (memory_load8_le(mem, 1913bv64) == 0bv8); - free requires (memory_load8_le(mem, 1914bv64) == 2bv8); - free requires (memory_load8_le(mem, 1915bv64) == 0bv8); + free requires (memory_load32_le(mem, 1912bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R0_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var Gamma_R31_3: bool; - var R0_1: bv64; - var R0_2: bv64; - var R29_3: bv64; - var R30_3: bv64; - var R31_3: bv64; + var #4: bv64; + var #5: bv64; + var Gamma_#4: bool; + var Gamma_#5: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), 2bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), true); - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - call R0_2, Gamma_R0_2, R31_3, Gamma_R31_3 := plus_one(R0_1, Gamma_R0_1, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + #4, Gamma_#4 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000030a"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000310"} true; + R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R8); + assume {:captureState "%00000323"} true; + R8, Gamma_R8 := 2bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000330"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64)); + R30, Gamma_R30 := 1848bv64, true; + call plus_one(); goto l00000366; l00000366: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_2[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_2); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_3, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 16bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_3, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 24bv64)); + assume {:captureState "l00000366"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R0); + assume {:captureState "%0000036c"} true; + R0, Gamma_R0 := 0bv64, true; + #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#5, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out := 0bv64, R29_3, R30_3, bvadd64(R31_3, 32bv64), 2bv64; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_3, true; + assume {:captureState "main_basil_return"} true; return; } -procedure plus_one(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; - free requires (memory_load8_le(mem, 1912bv64) == 1bv8); - free requires (memory_load8_le(mem, 1913bv64) == 0bv8); - free requires (memory_load8_le(mem, 1914bv64) == 2bv8); - free requires (memory_load8_le(mem, 1915bv64) == 0bv8); +procedure plus_one(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_stack, R0, R31, R8, stack; + free requires (memory_load32_le(mem, 1912bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation plus_one(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation plus_one() { - var Gamma_R0_2: bool; - var Gamma_R8_1: bool; - var R0_2: bv64; - var R8_1: bv32; lplus_one: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - R8_1, Gamma_R8_1 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - R0_2, Gamma_R0_2 := zero_extend32_32(bvadd32(R8_1, 1bv32)), Gamma_R8_1; + assume {:captureState "lplus_one"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000034c"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto plus_one_basil_return; plus_one_basil_return: - R0_out, R31_out := R0_2, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_2, Gamma_R31_in; + assume {:captureState "plus_one_basil_return"} true; return; } diff --git a/src/test/correct/functions_with_params/clang/functions_with_params_gtirb.expected b/src/test/correct/functions_with_params/clang/functions_with_params_gtirb.expected index 3253afad1..e73fc78e3 100644 --- a/src/test/correct/functions_with_params/clang/functions_with_params_gtirb.expected +++ b/src/test/correct/functions_with_params/clang/functions_with_params_gtirb.expected @@ -1,25 +1,21 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1912bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,15 +25,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -48,27 +40,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -76,8 +61,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -90,91 +75,93 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_stack, R0, R29, R30, R31, R8, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1912bv64) == 1bv8); - free requires (memory_load8_le(mem, 1913bv64) == 0bv8); - free requires (memory_load8_le(mem, 1914bv64) == 2bv8); - free requires (memory_load8_le(mem, 1915bv64) == 0bv8); + free requires (memory_load32_le(mem, 1912bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R0_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var Gamma_R31_3: bool; - var R0_1: bv64; - var R0_2: bv64; - var R29_3: bv64; - var R30_3: bv64; - var R31_3: bv64; + var Cse0__5$0$2: bv64; + var Cse0__5$1$1: bv64; + var Gamma_Cse0__5$0$2: bool; + var Gamma_Cse0__5$1$1: bool; $main$__0__$_kmZuIukTa2pHUJW~uCGfQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), 2bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), true); - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - call R0_2, Gamma_R0_2, R31_3, Gamma_R31_3 := plus_one(R0_1, Gamma_R0_1, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in); + assume {:captureState "$main$__0__$_kmZuIukTa2pHUJW~uCGfQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + Cse0__5$1$1, Gamma_Cse0__5$1$1 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$1, R29), gamma_store64(Gamma_stack, Cse0__5$1$1, Gamma_R29); + assume {:captureState "1816$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$1, 8bv64), Gamma_R30); + assume {:captureState "1816$2"} true; + R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R8); + assume {:captureState "1828$0"} true; + R8, Gamma_R8 := 2bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1836$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64)); + R30, Gamma_R30 := 1848bv64, true; + call plus_one(); goto $main$__1__$HspZq7YwQ4y0NoLabaih0w; $main$__1__$HspZq7YwQ4y0NoLabaih0w: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_2[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_2); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_3, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 16bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_3, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 24bv64)); + assume {:captureState "$main$__1__$HspZq7YwQ4y0NoLabaih0w"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R0); + assume {:captureState "1848$0"} true; + R0, Gamma_R0 := 0bv64, true; + Cse0__5$0$2, Gamma_Cse0__5$0$2 := bvadd64(R31, 16bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$0$2), gamma_load64(Gamma_stack, Cse0__5$0$2); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$0$2, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$0$2, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out := 0bv64, R29_3, R30_3, bvadd64(R31_3, 32bv64), 2bv64; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_3, true; + assume {:captureState "main_basil_return"} true; return; } -procedure plus_one(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; - free requires (memory_load8_le(mem, 1912bv64) == 1bv8); - free requires (memory_load8_le(mem, 1913bv64) == 0bv8); - free requires (memory_load8_le(mem, 1914bv64) == 2bv8); - free requires (memory_load8_le(mem, 1915bv64) == 0bv8); +procedure plus_one(); + modifies Gamma_R0, Gamma_R31, Gamma_R8, Gamma_stack, R0, R31, R8, stack; + free requires (memory_load32_le(mem, 1912bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation plus_one(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation plus_one() { - var Gamma_R0_2: bool; - var Gamma_R8_1: bool; - var R0_2: bv64; - var R8_1: bv32; $plus_one$__0__$Pl39SFHHQI2EffBjodiSvA: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - R8_1, Gamma_R8_1 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - R0_2, Gamma_R0_2 := zero_extend32_32(bvadd32(R8_1, 1bv32)), Gamma_R8_1; + assume {:captureState "$plus_one$__0__$Pl39SFHHQI2EffBjodiSvA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1872$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto plus_one_basil_return; plus_one_basil_return: - R0_out, R31_out := R0_2, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_2, Gamma_R31_in; + assume {:captureState "plus_one_basil_return"} true; return; } diff --git a/src/test/correct/functions_with_params/gcc/functions_with_params.expected b/src/test/correct/functions_with_params/gcc/functions_with_params.expected index 4f511d33e..c1563536b 100644 --- a/src/test/correct/functions_with_params/gcc/functions_with_params.expected +++ b/src/test/correct/functions_with_params/gcc/functions_with_params.expected @@ -1,25 +1,19 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1904bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,15 +23,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -48,27 +38,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1904bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1905bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1906bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1907bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1904bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -76,8 +59,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -90,91 +73,90 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_stack, R0, R29, R30, R31, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1904bv64) == 1bv8); - free requires (memory_load8_le(mem, 1905bv64) == 0bv8); - free requires (memory_load8_le(mem, 1906bv64) == 2bv8); - free requires (memory_load8_le(mem, 1907bv64) == 0bv8); + free requires (memory_load32_le(mem, 1904bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1904bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1905bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1906bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1907bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1904bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var Gamma_R31_3: bool; - var R0_3: bv64; - var R0_4: bv64; - var R29_3: bv64; - var R30_3: bv64; - var R31_3: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 2bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R0_3, Gamma_R0_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - call R0_4, Gamma_R0_4, R31_3, Gamma_R31_3 := plus_one(R0_3, Gamma_R0_3, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002fc"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000302"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000319"} true; + R0, Gamma_R0 := 2bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000326"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); + R30, Gamma_R30 := 1844bv64, true; + call plus_one(); goto l0000035c; l0000035c: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_3, 24bv64), R0_4[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_3, 24bv64), Gamma_R0_4); - R29_3, Gamma_R29_3 := memory_load64_le(stack, R31_3), gamma_load64(Gamma_stack, R31_3); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_3, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 8bv64)); + assume {:captureState "l0000035c"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000362"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out := 0bv64, R29_3, R30_3, bvadd64(R31_3, 32bv64); - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_3; + assume {:captureState "main_basil_return"} true; return; } -procedure plus_one(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; - free requires (memory_load8_le(mem, 1904bv64) == 1bv8); - free requires (memory_load8_le(mem, 1905bv64) == 0bv8); - free requires (memory_load8_le(mem, 1906bv64) == 2bv8); - free requires (memory_load8_le(mem, 1907bv64) == 0bv8); +procedure plus_one(); + modifies Gamma_R0, Gamma_R31, Gamma_stack, R0, R31, stack; + free requires (memory_load32_le(mem, 1904bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1904bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1905bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1906bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1907bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1904bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation plus_one(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation plus_one() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var R0_2: bv32; - var R0_3: bv64; lplus_one: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - R0_2, Gamma_R0_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - R0_3, Gamma_R0_3 := zero_extend32_32(bvadd32(R0_2, 1bv32)), Gamma_R0_2; + assume {:captureState "lplus_one"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000342"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto plus_one_basil_return; plus_one_basil_return: - R0_out, R31_out := R0_3, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_3, Gamma_R31_in; + assume {:captureState "plus_one_basil_return"} true; return; } diff --git a/src/test/correct/functions_with_params/gcc/functions_with_params_gtirb.expected b/src/test/correct/functions_with_params/gcc/functions_with_params_gtirb.expected index 2d9f7249a..98806b657 100644 --- a/src/test/correct/functions_with_params/gcc/functions_with_params_gtirb.expected +++ b/src/test/correct/functions_with_params/gcc/functions_with_params_gtirb.expected @@ -1,25 +1,19 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1904bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,15 +23,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -48,27 +38,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1904bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1905bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1906bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1907bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1904bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -76,8 +59,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -90,91 +73,90 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure plus_one(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; - free requires (memory_load8_le(mem, 1904bv64) == 1bv8); - free requires (memory_load8_le(mem, 1905bv64) == 0bv8); - free requires (memory_load8_le(mem, 1906bv64) == 2bv8); - free requires (memory_load8_le(mem, 1907bv64) == 0bv8); +procedure plus_one(); + modifies Gamma_R0, Gamma_R31, Gamma_stack, R0, R31, stack; + free requires (memory_load32_le(mem, 1904bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1904bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1905bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1906bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1907bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1904bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation plus_one(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation plus_one() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var R0_2: bv32; - var R0_3: bv64; $plus_one$__0__$aniLEBpwTwWecL~mJKhdww: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - R0_2, Gamma_R0_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - R0_3, Gamma_R0_3 := zero_extend32_32(bvadd32(R0_2, 1bv32)), Gamma_R0_2; + assume {:captureState "$plus_one$__0__$aniLEBpwTwWecL~mJKhdww"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1864$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto plus_one_basil_return; plus_one_basil_return: - R0_out, R31_out := R0_3, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_3, Gamma_R31_in; + assume {:captureState "plus_one_basil_return"} true; return; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_stack, R0, R29, R30, R31, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1904bv64) == 1bv8); - free requires (memory_load8_le(mem, 1905bv64) == 0bv8); - free requires (memory_load8_le(mem, 1906bv64) == 2bv8); - free requires (memory_load8_le(mem, 1907bv64) == 0bv8); + free requires (memory_load32_le(mem, 1904bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1904bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1905bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1906bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1907bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1904bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var Gamma_R31_3: bool; - var R0_3: bv64; - var R0_4: bv64; - var R29_3: bv64; - var R30_3: bv64; - var R31_3: bv64; + var Cse0__5$0$0: bv64; + var Gamma_Cse0__5$0$0: bool; $main$__0__$yXI5g~EeQ_GieNYkY~buoQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 2bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R0_3, Gamma_R0_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - call R0_4, Gamma_R0_4, R31_3, Gamma_R31_3 := plus_one(R0_3, Gamma_R0_3, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in); + assume {:captureState "$main$__0__$yXI5g~EeQ_GieNYkY~buoQ"} true; + Cse0__5$0$0, Gamma_Cse0__5$0$0 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$0, R29), gamma_store64(Gamma_stack, Cse0__5$0$0, Gamma_R29); + assume {:captureState "1812$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$0, 8bv64), Gamma_R30); + assume {:captureState "1812$2"} true; + R31, Gamma_R31 := Cse0__5$0$0, Gamma_Cse0__5$0$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := 2bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1832$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); + R30, Gamma_R30 := 1844bv64, true; + call plus_one(); goto $main$__1__$4Vr1A4uzTlqLZDSUKeLWQA; $main$__1__$4Vr1A4uzTlqLZDSUKeLWQA: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_3, 24bv64), R0_4[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_3, 24bv64), Gamma_R0_4); - R29_3, Gamma_R29_3 := memory_load64_le(stack, R31_3), gamma_load64(Gamma_stack, R31_3); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_3, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 8bv64)); + assume {:captureState "$main$__1__$4Vr1A4uzTlqLZDSUKeLWQA"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "1844$0"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out := 0bv64, R29_3, R30_3, bvadd64(R31_3, 32bv64); - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R29_3, Gamma_R30_3, Gamma_R31_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifbranches/clang/ifbranches.expected b/src/test/correct/ifbranches/clang/ifbranches.expected index 58d7fdd0e..60d8d807e 100644 --- a/src/test/correct/ifbranches/clang/ifbranches.expected +++ b/src/test/correct/ifbranches/clang/ifbranches.expected @@ -1,37 +1,40 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,27 +45,22 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -70,8 +68,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -84,76 +82,102 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_stack, stack; - requires (Gamma_R0_in == true); +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R0, R31, R8, VF, ZF, stack; + requires (Gamma_R0 == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R8_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_6: bool; - var Gamma_R8_9: bool; - var R0_2: bv64; - var R8_1: bv32; - var R8_10: bv64; - var R8_6: bv64; - var R8_9: bv32; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R1_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - R8_1, Gamma_R8_1 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - assert Gamma_R8_1; + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%0000030d"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000315"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%0000031d"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000324"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l0000034c, lmain_goto_l0000034f; - lmain_goto_l0000034f: - assume (!(R8_1 == 0bv32)); - R8_6, Gamma_R8_6 := 1bv64, true; + l0000034f: + assume {:captureState "l0000034f"} true; + R8, Gamma_R8 := 1bv64, true; goto l00000352; - lmain_goto_l0000034c: - assume (R8_1 == 0bv32); - R8_6, Gamma_R8_6 := 0bv64, true; + l0000034c: + assume {:captureState "l0000034c"} true; + R8, Gamma_R8 := 0bv64, true; goto l00000352; l00000352: - assert Gamma_R8_6; + assume {:captureState "l00000352"} true; + assert Gamma_R8; goto l00000352_goto_l0000035a, l00000352_goto_l00000397; - l00000352_goto_l00000397: - assume (!(R8_6[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); + l0000035a: + assume {:captureState "l0000035a"} true; + R8, Gamma_R8 := 2bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%0000036a"} true; goto l0000036d; - l00000352_goto_l0000035a: - assume (R8_6[1:0] == 1bv1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 2bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); + l00000397: + assume {:captureState "l00000397"} true; + goto l00000398; + l00000398: + assume {:captureState "l00000398"} true; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%000003a6"} true; goto l0000036d; l0000036d: - R8_9, Gamma_R8_9 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - R8_10, Gamma_R8_10 := zero_extend32_32(bvadd32(R8_9, 1bv32)), Gamma_R8_9; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R8_10[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R8_10); - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "l0000036d"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000383"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l0000034c: + assume {:captureState "lmain_goto_l0000034c"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l0000034c; + lmain_goto_l0000034f: + assume {:captureState "lmain_goto_l0000034f"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l0000034f; + l00000352_goto_l0000035a: + assume {:captureState "l00000352_goto_l0000035a"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l0000035a; + l00000352_goto_l00000397: + assume {:captureState "l00000352_goto_l00000397"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000397; main_basil_return: - R0_out, R31_out, R8_out := R0_2, R31_in, R8_10; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_2, Gamma_R31_in, Gamma_R8_10; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifbranches/clang/ifbranches_gtirb.expected b/src/test/correct/ifbranches/clang/ifbranches_gtirb.expected index 3523718f4..19655971a 100644 --- a/src/test/correct/ifbranches/clang/ifbranches_gtirb.expected +++ b/src/test/correct/ifbranches/clang/ifbranches_gtirb.expected @@ -1,37 +1,39 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,27 +44,21 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -70,8 +66,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -84,89 +80,94 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_stack, stack; - requires (Gamma_R0_in == true); +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R0, R31, R8, VF, ZF, stack; + requires (Gamma_R0 == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R8_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_12: bool; - var Gamma_R8_7: bool; - var Gamma_R8_9: bool; - var R0_2: bv64; - var R8_1: bv32; - var R8_11: bv32; - var R8_12: bv64; - var R8_7: bv64; - var R8_9: bv64; + var Cse0__5$3$6: bv32; + var Gamma_Cse0__5$3$6: bool; $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R1_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - R8_1, Gamma_R8_1 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - assert Gamma_R8_1; + assume {:captureState "$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "1816$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "1820$0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "1824$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1828$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); + Cse0__5$3$6, Gamma_Cse0__5$3$6 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$3$6, Cse0__5$3$6)), Gamma_Cse0__5$3$6; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$6), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$3$6); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$6, 0bv32), Gamma_Cse0__5$3$6; + NF, Gamma_NF := Cse0__5$3$6[32:31], Gamma_Cse0__5$3$6; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$3$6), Gamma_Cse0__5$3$6; + assert Gamma_ZF; goto $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__0, $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__1; - $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__1: - assume (!(R8_1 == 0bv32)); - goto $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__1_phi_$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__3__$AzuUI8EJR~~zZ4LRu_atQA_phi_back_$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__3__$AzuUI8EJR~~zZ4LRu_atQA, $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__1_phi_$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__1__$22DSnEAzTL6vU9qI4utrZA_phi_back_$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__1__$22DSnEAzTL6vU9qI4utrZA; - $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__1_phi_$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__1__$22DSnEAzTL6vU9qI4utrZA_phi_back_$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__1__$22DSnEAzTL6vU9qI4utrZA: - R8_7, Gamma_R8_7 := 1bv64, true; - assert Gamma_R8_7; - goto $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__1__$22DSnEAzTL6vU9qI4utrZA; - $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__1_phi_$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__3__$AzuUI8EJR~~zZ4LRu_atQA_phi_back_$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__3__$AzuUI8EJR~~zZ4LRu_atQA: - R8_9, Gamma_R8_9 := 1bv64, true; - assert Gamma_R8_9; - goto $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__3__$AzuUI8EJR~~zZ4LRu_atQA; - $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__0: - assume (R8_1 == 0bv32); - goto $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__0_phi_back_$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__1__$22DSnEAzTL6vU9qI4utrZA, $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__0_phi_back_$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__3__$AzuUI8EJR~~zZ4LRu_atQA; - $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__0_phi_back_$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__3__$AzuUI8EJR~~zZ4LRu_atQA: - R8_9, Gamma_R8_9 := 0bv64, true; - assert Gamma_R8_9; - goto $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__3__$AzuUI8EJR~~zZ4LRu_atQA; - $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__3__$AzuUI8EJR~~zZ4LRu_atQA: - assume (R8_9[1:0] == 1bv1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 2bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); + $main$__1__$22DSnEAzTL6vU9qI4utrZA: + assume {:captureState "$main$__1__$22DSnEAzTL6vU9qI4utrZA"} true; + goto $main$__2__$UnO2T_q8SO22cZ~w_xJwoA; + $main$__2__$UnO2T_q8SO22cZ~w_xJwoA: + assume {:captureState "$main$__2__$UnO2T_q8SO22cZ~w_xJwoA"} true; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1856$0"} true; goto $main$__4__$hiOAUbGYTmCyjtnuNPouiQ; - $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__0_phi_back_$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__1__$22DSnEAzTL6vU9qI4utrZA: - R8_7, Gamma_R8_7 := 0bv64, true; - assert Gamma_R8_7; - goto $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__1__$22DSnEAzTL6vU9qI4utrZA; - $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__1__$22DSnEAzTL6vU9qI4utrZA: - assume (!(R8_7[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); + $main$__3__$AzuUI8EJR~~zZ4LRu_atQA: + assume {:captureState "$main$__3__$AzuUI8EJR~~zZ4LRu_atQA"} true; + R8, Gamma_R8 := 2bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1868$0"} true; goto $main$__4__$hiOAUbGYTmCyjtnuNPouiQ; $main$__4__$hiOAUbGYTmCyjtnuNPouiQ: - R8_11, Gamma_R8_11 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - R8_12, Gamma_R8_12 := zero_extend32_32(bvadd32(R8_11, 1bv32)), Gamma_R8_11; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R8_12[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R8_12); - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551592bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "$main$__4__$hiOAUbGYTmCyjtnuNPouiQ"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1884$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__3__$AzuUI8EJR~~zZ4LRu_atQA: + assume {:captureState "$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__3__$AzuUI8EJR~~zZ4LRu_atQA"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$AzuUI8EJR~~zZ4LRu_atQA; + $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__1__$22DSnEAzTL6vU9qI4utrZA: + assume {:captureState "$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__1__$22DSnEAzTL6vU9qI4utrZA"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$22DSnEAzTL6vU9qI4utrZA; + $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__0: + assume {:captureState "$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__3__$AzuUI8EJR~~zZ4LRu_atQA, $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__1__$22DSnEAzTL6vU9qI4utrZA; + $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__1: + assume {:captureState "$main$__0__$z7dsAZ41QYe9rvbDt1JoIQ$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__3__$AzuUI8EJR~~zZ4LRu_atQA, $main$__0__$z7dsAZ41QYe9rvbDt1JoIQ_goto_$main$__1__$22DSnEAzTL6vU9qI4utrZA; main_basil_return: - R0_out, R31_out, R8_out := R0_2, R31_in, R8_12; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_2, Gamma_R31_in, Gamma_R8_12; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifbranches/clang_O2/ifbranches.expected b/src/test/correct/ifbranches/clang_O2/ifbranches.expected index ffa7c3aa3..8f7c7b621 100644 --- a/src/test/correct/ifbranches/clang_O2/ifbranches.expected +++ b/src/test/correct/ifbranches/clang_O2/ifbranches.expected @@ -1,22 +1,40 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { - (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { + (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1848bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1849bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1850bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1851bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1848bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -24,8 +42,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -38,47 +56,57 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool); - requires (Gamma_R0_in == true); +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R8, Gamma_VF, Gamma_ZF, NF, R0, R8, VF, ZF; + requires (Gamma_R0 == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1848bv64) == 1bv8); - free requires (memory_load8_le(mem, 1849bv64) == 0bv8); - free requires (memory_load8_le(mem, 1850bv64) == 2bv8); - free requires (memory_load8_le(mem, 1851bv64) == 0bv8); + free requires (memory_load32_le(mem, 1848bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1848bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1849bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1850bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1851bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1848bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_5: bool; - var R0_5: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - assert Gamma_R0_in; + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 2bv64, true; + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l000002db, lmain_goto_l000002df; - lmain_goto_l000002df: - assume (!(R0_in[32:0] == 0bv32)); - R0_5, Gamma_R0_5 := 3bv64, true; + l000002df: + assume {:captureState "l000002df"} true; + R0, Gamma_R0 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; goto l000002e2; - lmain_goto_l000002db: - assume (R0_in[32:0] == 0bv32); - R0_5, Gamma_R0_5 := 2bv64, true; + l000002db: + assume {:captureState "l000002db"} true; + R0, Gamma_R0 := zero_extend32_32(R8[32:0]), Gamma_R8; goto l000002e2; l000002e2: + assume {:captureState "l000002e2"} true; goto main_basil_return; + lmain_goto_l000002db: + assume {:captureState "lmain_goto_l000002db"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l000002db; + lmain_goto_l000002df: + assume {:captureState "lmain_goto_l000002df"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l000002df; main_basil_return: - R0_out, R8_out := R0_5, 2bv64; - Gamma_R0_out, Gamma_R8_out := Gamma_R0_5, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifbranches/clang_O2/ifbranches_gtirb.expected b/src/test/correct/ifbranches/clang_O2/ifbranches_gtirb.expected index b077eb562..59e353194 100644 --- a/src/test/correct/ifbranches/clang_O2/ifbranches_gtirb.expected +++ b/src/test/correct/ifbranches/clang_O2/ifbranches_gtirb.expected @@ -1,22 +1,38 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { - (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { + (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1848bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1849bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1850bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1851bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1848bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -24,8 +40,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -38,45 +54,48 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool); - requires (Gamma_R0_in == true); +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R8, Gamma_VF, Gamma_ZF, NF, R0, R8, VF, ZF; + requires (Gamma_R0 == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1848bv64) == 1bv8); - free requires (memory_load8_le(mem, 1849bv64) == 0bv8); - free requires (memory_load8_le(mem, 1850bv64) == 2bv8); - free requires (memory_load8_le(mem, 1851bv64) == 0bv8); + free requires (memory_load32_le(mem, 1848bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1848bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1849bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1850bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1851bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1848bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_5: bool; - var R0_5: bv64; + var Cse0__5$0$1: bv32; + var Gamma_Cse0__5$0$1: bool; $main$__0__$VPrxPsvYQmW1iyrj_de8Iw: - assert Gamma_R0_in; + assume {:captureState "$main$__0__$VPrxPsvYQmW1iyrj_de8Iw"} true; + R8, Gamma_R8 := 2bv64, true; + Cse0__5$0$1, Gamma_Cse0__5$0$1 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$1, Cse0__5$0$1)), Gamma_Cse0__5$0$1; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$1), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$0$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$1, 0bv32), Gamma_Cse0__5$0$1; + NF, Gamma_NF := Cse0__5$0$1[32:31], Gamma_Cse0__5$0$1; + assert Gamma_ZF; goto $main$__0__$VPrxPsvYQmW1iyrj_de8Iw$__0, $main$__0__$VPrxPsvYQmW1iyrj_de8Iw$__1; - $main$__0__$VPrxPsvYQmW1iyrj_de8Iw$__1: - assume (!(R0_in[32:0] == 0bv32)); - R0_5, Gamma_R0_5 := 3bv64, true; - goto main_basil_return; $main$__0__$VPrxPsvYQmW1iyrj_de8Iw$__0: - assume (R0_in[32:0] == 0bv32); - R0_5, Gamma_R0_5 := 2bv64, true; + assume {:captureState "$main$__0__$VPrxPsvYQmW1iyrj_de8Iw$__0"} true; + assume (ZF == 1bv1); + R0, Gamma_R0 := zero_extend32_32(R8[32:0]), Gamma_R8; + goto main_basil_return; + $main$__0__$VPrxPsvYQmW1iyrj_de8Iw$__1: + assume {:captureState "$main$__0__$VPrxPsvYQmW1iyrj_de8Iw$__1"} true; + assume (!(ZF == 1bv1)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; goto main_basil_return; main_basil_return: - R0_out, R8_out := R0_5, 2bv64; - Gamma_R0_out, Gamma_R8_out := Gamma_R0_5, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifbranches/gcc/ifbranches.expected b/src/test/correct/ifbranches/gcc/ifbranches.expected index 09ea6e94d..1488af65e 100644 --- a/src/test/correct/ifbranches/gcc/ifbranches.expected +++ b/src/test/correct/ifbranches/gcc/ifbranches.expected @@ -1,37 +1,38 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,27 +43,22 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1904bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1905bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1906bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1907bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1904bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -70,8 +66,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -84,62 +80,76 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; - requires (Gamma_R0_in == true); +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R0, R31, VF, ZF, stack; + requires (Gamma_R0 == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1904bv64) == 1bv8); - free requires (memory_load8_le(mem, 1905bv64) == 0bv8); - free requires (memory_load8_le(mem, 1906bv64) == 2bv8); - free requires (memory_load8_le(mem, 1907bv64) == 0bv8); + free requires (memory_load32_le(mem, 1904bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1904bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1905bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1906bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1907bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1904bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var R0_2: bv32; - var R0_5: bv32; - var R0_6: bv32; - var R0_7: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R1_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R0_2, Gamma_R0_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - assert Gamma_R0_2; + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002fe"} true; + stack, Gamma_stack := memory_store64_le(stack, R31, R1), gamma_store64(Gamma_stack, R31, Gamma_R1); + assume {:captureState "%00000306"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), true); + assume {:captureState "%0000030d"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000330, lmain_goto_l00000369; - lmain_goto_l00000369: - assume (R0_2 == 0bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + l00000330: + assume {:captureState "l00000330"} true; + R0, Gamma_R0 := 2bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000340"} true; goto l00000342; - lmain_goto_l00000330: - assume (!(R0_2 == 0bv32)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 2bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + l00000369: + assume {:captureState "l00000369"} true; + R0, Gamma_R0 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000374"} true; goto l00000342; l00000342: - R0_5, Gamma_R0_5 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - R0_6, Gamma_R0_6 := bvadd32(R0_5, 1bv32), Gamma_R0_5; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_6), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_6); - R0_7, Gamma_R0_7 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l00000342"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000355"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000330: + assume {:captureState "lmain_goto_l00000330"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000330; + lmain_goto_l00000369: + assume {:captureState "lmain_goto_l00000369"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000369; main_basil_return: - R0_out, R31_out := R0_7, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_7, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifbranches/gcc/ifbranches_gtirb.expected b/src/test/correct/ifbranches/gcc/ifbranches_gtirb.expected index f86eb7550..46089e34d 100644 --- a/src/test/correct/ifbranches/gcc/ifbranches_gtirb.expected +++ b/src/test/correct/ifbranches/gcc/ifbranches_gtirb.expected @@ -1,37 +1,37 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,27 +42,21 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1904bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1905bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1906bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1907bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1904bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -70,8 +64,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -84,62 +78,76 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; - requires (Gamma_R0_in == true); +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R0, R31, VF, ZF, stack; + requires (Gamma_R0 == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1904bv64) == 1bv8); - free requires (memory_load8_le(mem, 1905bv64) == 0bv8); - free requires (memory_load8_le(mem, 1906bv64) == 2bv8); - free requires (memory_load8_le(mem, 1907bv64) == 0bv8); + free requires (memory_load32_le(mem, 1904bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1904bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1905bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1906bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1907bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1904bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var R0_2: bv32; - var R0_5: bv32; - var R0_6: bv32; - var R0_7: bv64; + var Cse0__5$0$5: bv32; + var Gamma_Cse0__5$0$5: bool; $main$__0__$HREQex45QTmTaqW9AKOrww: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R1_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R0_2, Gamma_R0_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - assert Gamma_R0_2; + assume {:captureState "$main$__0__$HREQex45QTmTaqW9AKOrww"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1816$0"} true; + stack, Gamma_stack := memory_store64_le(stack, R31, R1), gamma_store64(Gamma_stack, R31, Gamma_R1); + assume {:captureState "1820$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), true); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + Cse0__5$0$5, Gamma_Cse0__5$0$5 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$5, Cse0__5$0$5)), Gamma_Cse0__5$0$5; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$5), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$0$5); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$5, 0bv32), Gamma_Cse0__5$0$5; + NF, Gamma_NF := Cse0__5$0$5[32:31], Gamma_Cse0__5$0$5; + assert Gamma_ZF; goto $main$__0__$HREQex45QTmTaqW9AKOrww_goto_$main$__2__$pc5c5kDrQe25Hv3XM4X5VA, $main$__0__$HREQex45QTmTaqW9AKOrww_goto_$main$__1__$mUDMeuR3T76Jfb1u23xaOA; - $main$__0__$HREQex45QTmTaqW9AKOrww_goto_$main$__1__$mUDMeuR3T76Jfb1u23xaOA: - assume (R0_2 == 0bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + $main$__1__$mUDMeuR3T76Jfb1u23xaOA: + assume {:captureState "$main$__1__$mUDMeuR3T76Jfb1u23xaOA"} true; + R0, Gamma_R0 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "1844$0"} true; goto $main$__3__$aU3DvXsmR~eEJl7F4Wc4Ww; - $main$__0__$HREQex45QTmTaqW9AKOrww_goto_$main$__2__$pc5c5kDrQe25Hv3XM4X5VA: - assume (!(R0_2 == 0bv32)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 2bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + $main$__2__$pc5c5kDrQe25Hv3XM4X5VA: + assume {:captureState "$main$__2__$pc5c5kDrQe25Hv3XM4X5VA"} true; + R0, Gamma_R0 := 2bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "1856$0"} true; goto $main$__3__$aU3DvXsmR~eEJl7F4Wc4Ww; $main$__3__$aU3DvXsmR~eEJl7F4Wc4Ww: - R0_5, Gamma_R0_5 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - R0_6, Gamma_R0_6 := bvadd32(R0_5, 1bv32), Gamma_R0_5; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_6), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_6); - R0_7, Gamma_R0_7 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__3__$aU3DvXsmR~eEJl7F4Wc4Ww"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1868$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + $main$__0__$HREQex45QTmTaqW9AKOrww_goto_$main$__2__$pc5c5kDrQe25Hv3XM4X5VA: + assume {:captureState "$main$__0__$HREQex45QTmTaqW9AKOrww_goto_$main$__2__$pc5c5kDrQe25Hv3XM4X5VA"} true; + assume (!(ZF == 1bv1)); + goto $main$__2__$pc5c5kDrQe25Hv3XM4X5VA; + $main$__0__$HREQex45QTmTaqW9AKOrww_goto_$main$__1__$mUDMeuR3T76Jfb1u23xaOA: + assume {:captureState "$main$__0__$HREQex45QTmTaqW9AKOrww_goto_$main$__1__$mUDMeuR3T76Jfb1u23xaOA"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__1__$mUDMeuR3T76Jfb1u23xaOA; main_basil_return: - R0_out, R31_out := R0_7, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_7, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifbranches/gcc_O2/ifbranches.expected b/src/test/correct/ifbranches/gcc_O2/ifbranches.expected index 7fb4cd91a..1fd37da61 100644 --- a/src/test/correct/ifbranches/gcc_O2/ifbranches.expected +++ b/src/test/correct/ifbranches/gcc_O2/ifbranches.expected @@ -1,24 +1,38 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { - (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { + (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -26,8 +40,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -40,50 +54,57 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool); - requires (Gamma_R0_in == true); +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_VF, Gamma_ZF, NF, R0, VF, ZF; + requires (Gamma_R0 == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool) +implementation main() { - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var R0_5: bv64; - var R0_6: bv64; + var #1: bv32; + var Gamma_#1: bool; lmain: - assert Gamma_R0_in; + assume {:captureState "lmain"} true; + #1, Gamma_#1 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#1, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#1, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#1); + ZF, Gamma_ZF := bvcomp32(bvadd32(#1, 1bv32), 0bv32), Gamma_#1; + NF, Gamma_NF := bvadd32(#1, 1bv32)[32:31], Gamma_#1; + assert Gamma_ZF; goto lmain_goto_l000001c3, lmain_goto_l000001c6; - lmain_goto_l000001c6: - assume (!(R0_in[32:0] == 0bv32)); - R0_5, Gamma_R0_5 := 1bv64, true; + l000001c6: + assume {:captureState "l000001c6"} true; + R0, Gamma_R0 := 1bv64, true; goto l000001c9; - lmain_goto_l000001c3: - assume (R0_in[32:0] == 0bv32); - R0_5, Gamma_R0_5 := 0bv64, true; + l000001c3: + assume {:captureState "l000001c3"} true; + R0, Gamma_R0 := 0bv64, true; goto l000001c9; l000001c9: - R0_6, Gamma_R0_6 := zero_extend32_32(bvadd32(R0_5[32:0], 2bv32)), Gamma_R0_5; + assume {:captureState "l000001c9"} true; + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 2bv32)), Gamma_R0; goto main_basil_return; + lmain_goto_l000001c3: + assume {:captureState "lmain_goto_l000001c3"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l000001c3; + lmain_goto_l000001c6: + assume {:captureState "lmain_goto_l000001c6"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l000001c6; main_basil_return: - R0_out := R0_6; - Gamma_R0_out := Gamma_R0_6; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifbranches/gcc_O2/ifbranches_gtirb.expected b/src/test/correct/ifbranches/gcc_O2/ifbranches_gtirb.expected index 96b2b9456..54cf79dd7 100644 --- a/src/test/correct/ifbranches/gcc_O2/ifbranches_gtirb.expected +++ b/src/test/correct/ifbranches/gcc_O2/ifbranches_gtirb.expected @@ -1,24 +1,36 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { - (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { + (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -26,8 +38,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -40,50 +52,51 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool); - requires (Gamma_R0_in == true); +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_VF, Gamma_ZF, NF, R0, VF, ZF; + requires (Gamma_R0 == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool) +implementation main() { - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var R0_5: bv64; - var R0_6: bv64; + var Cse0__5$1$0: bv32; + var Gamma_Cse0__5$1$0: bool; $main$__0__$qKNLTTV9SPy8sqABlZokYg: - assert Gamma_R0_in; + assume {:captureState "$main$__0__$qKNLTTV9SPy8sqABlZokYg"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$1$0, Cse0__5$1$0)), Gamma_Cse0__5$1$0; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$1$0), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$1$0); + ZF, Gamma_ZF := bvcomp32(Cse0__5$1$0, 0bv32), Gamma_Cse0__5$1$0; + NF, Gamma_NF := Cse0__5$1$0[32:31], Gamma_Cse0__5$1$0; + assert Gamma_ZF; goto $main$__0__$qKNLTTV9SPy8sqABlZokYg$__0, $main$__0__$qKNLTTV9SPy8sqABlZokYg$__1; - $main$__0__$qKNLTTV9SPy8sqABlZokYg$__1: - assume (!(R0_in[32:0] == 0bv32)); - R0_5, Gamma_R0_5 := 1bv64, true; - goto $main$__0__$qKNLTTV9SPy8sqABlZokYg$__2; $main$__0__$qKNLTTV9SPy8sqABlZokYg$__0: - assume (R0_in[32:0] == 0bv32); - R0_5, Gamma_R0_5 := 0bv64, true; + assume {:captureState "$main$__0__$qKNLTTV9SPy8sqABlZokYg$__0"} true; + assume (ZF == 1bv1); + R0, Gamma_R0 := 0bv64, true; + goto $main$__0__$qKNLTTV9SPy8sqABlZokYg$__2; + $main$__0__$qKNLTTV9SPy8sqABlZokYg$__1: + assume {:captureState "$main$__0__$qKNLTTV9SPy8sqABlZokYg$__1"} true; + assume (!(ZF == 1bv1)); + R0, Gamma_R0 := 1bv64, true; goto $main$__0__$qKNLTTV9SPy8sqABlZokYg$__2; $main$__0__$qKNLTTV9SPy8sqABlZokYg$__2: - R0_6, Gamma_R0_6 := zero_extend32_32(bvadd32(R0_5[32:0], 2bv32)), Gamma_R0_5; + assume {:captureState "$main$__0__$qKNLTTV9SPy8sqABlZokYg$__2"} true; + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 2bv32)), Gamma_R0; goto main_basil_return; main_basil_return: - R0_out := R0_6; - Gamma_R0_out := Gamma_R0_6; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifglobal/clang/ifglobal.expected b/src/test/correct/ifglobal/clang/ifglobal.expected index 471b450e4..a049e2d90 100644 --- a/src/test/correct/ifglobal/clang/ifglobal.expected +++ b/src/test/correct/ifglobal/clang/ifglobal.expected @@ -1,33 +1,42 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,23 +47,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -62,8 +66,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -76,77 +80,90 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, R9, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1892bv64) == 1bv8); - free requires (memory_load8_le(mem, 1893bv64) == 0bv8); - free requires (memory_load8_le(mem, 1894bv64) == 2bv8); - free requires (memory_load8_le(mem, 1895bv64) == 0bv8); + free requires (memory_load32_le(mem, 1892bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_2: bool; - var Gamma_R8_7: bool; - var Gamma_R9: bool; - var Gamma_R9_3: bool; - var R0_1: bv64; - var R8_10: bv64; - var R8_2: bv32; - var R8_7: bv64; - var R9: bv64; - var R9_3: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f1"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l0000031e, lmain_goto_l00000321; - lmain_goto_l00000321: - assume (!(R8_2 == 0bv32)); - R8_7, Gamma_R8_7 := 1bv64, true; + l00000321: + assume {:captureState "l00000321"} true; + R8, Gamma_R8 := 1bv64, true; goto l00000324; - lmain_goto_l0000031e: - assume (R8_2 == 0bv32); - R8_7, Gamma_R8_7 := 0bv64, true; + l0000031e: + assume {:captureState "l0000031e"} true; + R8, Gamma_R8 := 0bv64, true; goto l00000324; l00000324: - assert Gamma_R8_7; + assume {:captureState "l00000324"} true; + assert Gamma_R8; goto l00000324_goto_l0000032c, l00000324_goto_l00000343; - l00000324_goto_l00000343: - assume (!(R8_7[1:0] == 1bv1)); + l00000343: + assume {:captureState "l00000343"} true; + goto l00000344; + l00000344: + assume {:captureState "l00000344"} true; + R8, Gamma_R8 := 1bv64, true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); - R9_3, Gamma_R9_3 := 69632bv64, true; - R8_10, Gamma_R8_10 := 1bv64, true; - goto l0000032c; - l00000324_goto_l0000032c: - assume (R8_7[1:0] == 1bv1); - R9_3, Gamma_R9_3 := R9, Gamma_R9; - R8_10, Gamma_R8_10 := R8_7, Gamma_R8_7; + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "%00000357"} true; goto l0000032c; l0000032c: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l0000032c"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l0000031e: + assume {:captureState "lmain_goto_l0000031e"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l0000031e; + lmain_goto_l00000321: + assume {:captureState "lmain_goto_l00000321"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l00000321; + l00000324_goto_l0000032c: + assume {:captureState "l00000324_goto_l0000032c"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l0000032c; + l00000324_goto_l00000343: + assume {:captureState "l00000324_goto_l00000343"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000343; main_basil_return: - R0_out, R31_out, R8_out, R9_out := R0_1, R31_in, R8_10, R9_3; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_10, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifglobal/clang/ifglobal_gtirb.expected b/src/test/correct/ifglobal/clang/ifglobal_gtirb.expected index 6e5e6dd56..2e6edff1d 100644 --- a/src/test/correct/ifglobal/clang/ifglobal_gtirb.expected +++ b/src/test/correct/ifglobal/clang/ifglobal_gtirb.expected @@ -1,33 +1,41 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,23 +46,17 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -62,8 +64,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -76,90 +78,82 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, R9, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1892bv64) == 1bv8); - free requires (memory_load8_le(mem, 1893bv64) == 0bv8); - free requires (memory_load8_le(mem, 1894bv64) == 2bv8); - free requires (memory_load8_le(mem, 1895bv64) == 0bv8); + free requires (memory_load32_le(mem, 1892bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_12: bool; - var Gamma_R8_2: bool; - var Gamma_R8_8: bool; - var Gamma_R9: bool; - var Gamma_R9_3: bool; - var R0_1: bv64; - var R8_11: bv64; - var R8_12: bv64; - var R8_2: bv32; - var R8_8: bv64; - var R9: bv64; - var R9_3: bv64; + var Cse0__5$3$4: bv32; + var Gamma_Cse0__5$3$4: bool; $main$__0__$9GnbAUc4SVKU3B~gw6CarA: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$9GnbAUc4SVKU3B~gw6CarA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1816$0"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + Cse0__5$3$4, Gamma_Cse0__5$3$4 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$3$4, Cse0__5$3$4)), Gamma_Cse0__5$3$4; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$4), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$3$4); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$4, 0bv32), Gamma_Cse0__5$3$4; + NF, Gamma_NF := Cse0__5$3$4[32:31], Gamma_Cse0__5$3$4; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$3$4), Gamma_Cse0__5$3$4; + assert Gamma_ZF; goto $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__0, $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__1; - $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__1: - assume (!(R8_2 == 0bv32)); - goto $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__1_phi_$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__3__$mmRv3GP5SPy6AaIRmLInPw_phi_back_$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__3__$mmRv3GP5SPy6AaIRmLInPw, $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__1_phi_$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__1__$7rAM9J5nQI6xBaKIEerTtg_phi_back_$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__1__$7rAM9J5nQI6xBaKIEerTtg; - $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__1_phi_$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__1__$7rAM9J5nQI6xBaKIEerTtg_phi_back_$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__1__$7rAM9J5nQI6xBaKIEerTtg: - R8_8, Gamma_R8_8 := 1bv64, true; - assert Gamma_R8_8; - goto $main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__1__$7rAM9J5nQI6xBaKIEerTtg; - $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__1_phi_$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__3__$mmRv3GP5SPy6AaIRmLInPw_phi_back_$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__3__$mmRv3GP5SPy6AaIRmLInPw: - R8_11, Gamma_R8_11 := 1bv64, true; - assert Gamma_R8_11; - goto $main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__3__$mmRv3GP5SPy6AaIRmLInPw; - $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__0: - assume (R8_2 == 0bv32); - goto $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__0_phi_back_$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__1__$7rAM9J5nQI6xBaKIEerTtg, $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__0_phi_back_$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__3__$mmRv3GP5SPy6AaIRmLInPw; - $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__0_phi_back_$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__3__$mmRv3GP5SPy6AaIRmLInPw: - R8_11, Gamma_R8_11 := 0bv64, true; - assert Gamma_R8_11; - goto $main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__3__$mmRv3GP5SPy6AaIRmLInPw; - $main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__3__$mmRv3GP5SPy6AaIRmLInPw: - assume (R8_11[1:0] == 1bv1); - R9_3, Gamma_R9_3 := R9, Gamma_R9; - R8_12, Gamma_R8_12 := R8_11, Gamma_R8_11; - goto $main$__3__$mmRv3GP5SPy6AaIRmLInPw; - $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__0_phi_back_$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__1__$7rAM9J5nQI6xBaKIEerTtg: - R8_8, Gamma_R8_8 := 0bv64, true; - assert Gamma_R8_8; - goto $main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__1__$7rAM9J5nQI6xBaKIEerTtg; - $main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__1__$7rAM9J5nQI6xBaKIEerTtg: - assume (!(R8_8[1:0] == 1bv1)); + $main$__1__$7rAM9J5nQI6xBaKIEerTtg: + assume {:captureState "$main$__1__$7rAM9J5nQI6xBaKIEerTtg"} true; + goto $main$__2__$mbLAJH9oTJ~vni0HqhGvhg; + $main$__2__$mbLAJH9oTJ~vni0HqhGvhg: + assume {:captureState "$main$__2__$mbLAJH9oTJ~vni0HqhGvhg"} true; + R8, Gamma_R8 := 1bv64, true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); - R9_3, Gamma_R9_3 := 69632bv64, true; - R8_12, Gamma_R8_12 := 1bv64, true; + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "1852$0"} true; goto $main$__3__$mmRv3GP5SPy6AaIRmLInPw; $main$__3__$mmRv3GP5SPy6AaIRmLInPw: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__3__$mmRv3GP5SPy6AaIRmLInPw"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__3__$mmRv3GP5SPy6AaIRmLInPw: + assume {:captureState "$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__3__$mmRv3GP5SPy6AaIRmLInPw"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$mmRv3GP5SPy6AaIRmLInPw; + $main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__1__$7rAM9J5nQI6xBaKIEerTtg: + assume {:captureState "$main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__1__$7rAM9J5nQI6xBaKIEerTtg"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$7rAM9J5nQI6xBaKIEerTtg; + $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__0: + assume {:captureState "$main$__0__$9GnbAUc4SVKU3B~gw6CarA$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__3__$mmRv3GP5SPy6AaIRmLInPw, $main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__1__$7rAM9J5nQI6xBaKIEerTtg; + $main$__0__$9GnbAUc4SVKU3B~gw6CarA$__1: + assume {:captureState "$main$__0__$9GnbAUc4SVKU3B~gw6CarA$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__3__$mmRv3GP5SPy6AaIRmLInPw, $main$__0__$9GnbAUc4SVKU3B~gw6CarA_goto_$main$__1__$7rAM9J5nQI6xBaKIEerTtg; main_basil_return: - R0_out, R31_out, R8_out, R9_out := R0_1, R31_in, R8_12, R9_3; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_12, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifglobal/clang_O2/ifglobal.expected b/src/test/correct/ifglobal/clang_O2/ifglobal.expected index 12d03b47b..9c75c68c6 100644 --- a/src/test/correct/ifglobal/clang_O2/ifglobal.expected +++ b/src/test/correct/ifglobal/clang_O2/ifglobal.expected @@ -1,31 +1,25 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,23 +30,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -60,8 +47,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -74,52 +61,53 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R9_2: bool; - var Gamma_R9_5: bool; - var R9_2: bv64; - var R9_5: bv64; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R9_2, Gamma_R9_2 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R9_2; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + assert Gamma_R9; goto lmain_goto_l000002dc, lmain_goto_l000002f8; - lmain_goto_l000002f8: - assume (!(R9_2[32:0] == 0bv32)); - R9_5, Gamma_R9_5 := R9_2, Gamma_R9_2; - goto main_basil_return; - lmain_goto_l000002dc: - assume (R9_2[32:0] == 0bv32); + l000002dc: + assume {:captureState "l000002dc"} true; + R9, Gamma_R9 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); - R9_5, Gamma_R9_5 := 1bv64, true; + assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assume {:captureState "%000002ec"} true; + R0, Gamma_R0 := 0bv64, true; + goto main_basil_return; + l000002f8: + assume {:captureState "l000002f8"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + lmain_goto_l000002dc: + assume {:captureState "lmain_goto_l000002dc"} true; + assume (bvcomp32(R9[32:0], 0bv32) != 0bv1); + goto l000002dc; + lmain_goto_l000002f8: + assume {:captureState "lmain_goto_l000002f8"} true; + assume (bvcomp32(R9[32:0], 0bv32) == 0bv1); + goto l000002f8; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 69632bv64, R9_5; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R9_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifglobal/clang_O2/ifglobal_gtirb.expected b/src/test/correct/ifglobal/clang_O2/ifglobal_gtirb.expected index 055af380d..4d0aa9470 100644 --- a/src/test/correct/ifglobal/clang_O2/ifglobal_gtirb.expected +++ b/src/test/correct/ifglobal/clang_O2/ifglobal_gtirb.expected @@ -1,31 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,23 +29,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -60,8 +46,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -74,52 +60,53 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R9_2: bool; - var Gamma_R9_5: bool; - var R9_2: bv64; - var R9_5: bv64; $main$__0__$8o8s0gkLQHmltXj4DgySqA: + assume {:captureState "$main$__0__$8o8s0gkLQHmltXj4DgySqA"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R9_2, Gamma_R9_2 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R9_2; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + assert Gamma_R9; goto $main$__0__$8o8s0gkLQHmltXj4DgySqA_goto_$main$__2__$J_ed8O5fQyujpIXPBE06ZA, $main$__0__$8o8s0gkLQHmltXj4DgySqA_goto_$main$__1__$PgxZhKszSIyzQiwC3MZUTg; - $main$__0__$8o8s0gkLQHmltXj4DgySqA_goto_$main$__1__$PgxZhKszSIyzQiwC3MZUTg: - assume (!(R9_2[32:0] == 0bv32)); - R9_5, Gamma_R9_5 := R9_2, Gamma_R9_2; + $main$__1__$PgxZhKszSIyzQiwC3MZUTg: + assume {:captureState "$main$__1__$PgxZhKszSIyzQiwC3MZUTg"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; - $main$__0__$8o8s0gkLQHmltXj4DgySqA_goto_$main$__2__$J_ed8O5fQyujpIXPBE06ZA: - assume (R9_2[32:0] == 0bv32); + $main$__2__$J_ed8O5fQyujpIXPBE06ZA: + assume {:captureState "$main$__2__$J_ed8O5fQyujpIXPBE06ZA"} true; + R9, Gamma_R9 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); - R9_5, Gamma_R9_5 := 1bv64, true; + assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assume {:captureState "1836$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + $main$__0__$8o8s0gkLQHmltXj4DgySqA_goto_$main$__2__$J_ed8O5fQyujpIXPBE06ZA: + assume {:captureState "$main$__0__$8o8s0gkLQHmltXj4DgySqA_goto_$main$__2__$J_ed8O5fQyujpIXPBE06ZA"} true; + assume (R9[32:0] == 0bv32); + goto $main$__2__$J_ed8O5fQyujpIXPBE06ZA; + $main$__0__$8o8s0gkLQHmltXj4DgySqA_goto_$main$__1__$PgxZhKszSIyzQiwC3MZUTg: + assume {:captureState "$main$__0__$8o8s0gkLQHmltXj4DgySqA_goto_$main$__1__$PgxZhKszSIyzQiwC3MZUTg"} true; + assume (!(R9[32:0] == 0bv32)); + goto $main$__1__$PgxZhKszSIyzQiwC3MZUTg; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 69632bv64, R9_5; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R9_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifglobal/clang_pic/ifglobal.expected b/src/test/correct/ifglobal/clang_pic/ifglobal.expected index bce6114ff..2c79a79e3 100644 --- a/src/test/correct/ifglobal/clang_pic/ifglobal.expected +++ b/src/test/correct/ifglobal/clang_pic/ifglobal.expected @@ -1,23 +1,36 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +40,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,33 +51,28 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -81,87 +85,96 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, R9, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_8: bool; - var Gamma_R9: bool; - var Gamma_R9_2: bool; - var Gamma_R9_4: bool; - var R0_1: bv64; - var R8_11: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_8: bv64; - var R9: bv64; - var R9_2: bv64; - var R9_4: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f9"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l0000032d, lmain_goto_l00000330; - lmain_goto_l00000330: - assume (!(R8_3 == 0bv32)); - R8_8, Gamma_R8_8 := 1bv64, true; + l00000330: + assume {:captureState "l00000330"} true; + R8, Gamma_R8 := 1bv64, true; goto l00000333; - lmain_goto_l0000032d: - assume (R8_3 == 0bv32); - R8_8, Gamma_R8_8 := 0bv64, true; + l0000032d: + assume {:captureState "l0000032d"} true; + R8, Gamma_R8 := 0bv64, true; goto l00000333; l00000333: - assert Gamma_R8_8; + assume {:captureState "l00000333"} true; + assert Gamma_R8; goto l00000333_goto_l0000033b, l00000333_goto_l00000352; - l00000333_goto_l00000352: - assume (!(R8_8[1:0] == 1bv1)); + l00000352: + assume {:captureState "l00000352"} true; + goto l00000353; + l00000353: + assume {:captureState "l00000353"} true; + R8, Gamma_R8 := 1bv64, true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); call rely(); - assert (L(mem, R9_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 1bv32), gamma_store32(Gamma_mem, R9_2, true); - R9_4, Gamma_R9_4 := R9_2, Gamma_R9_2; - R8_11, Gamma_R8_11 := 1bv64, true; - goto l0000033b; - l00000333_goto_l0000033b: - assume (R8_8[1:0] == 1bv1); - R9_4, Gamma_R9_4 := R9, Gamma_R9; - R8_11, Gamma_R8_11 := R8_8, Gamma_R8_8; + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%0000036d"} true; goto l0000033b; l0000033b: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l0000033b"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l0000032d: + assume {:captureState "lmain_goto_l0000032d"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l0000032d; + lmain_goto_l00000330: + assume {:captureState "lmain_goto_l00000330"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l00000330; + l00000333_goto_l0000033b: + assume {:captureState "l00000333_goto_l0000033b"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l0000033b; + l00000333_goto_l00000352: + assume {:captureState "l00000333_goto_l00000352"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000352; main_basil_return: - R0_out, R31_out, R8_out, R9_out := R0_1, R31_in, R8_11, R9_4; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_11, Gamma_R9_4; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifglobal/clang_pic/ifglobal_gtirb.expected b/src/test/correct/ifglobal/clang_pic/ifglobal_gtirb.expected index 2bdb73bc1..3491452f3 100644 --- a/src/test/correct/ifglobal/clang_pic/ifglobal_gtirb.expected +++ b/src/test/correct/ifglobal/clang_pic/ifglobal_gtirb.expected @@ -1,23 +1,35 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +39,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,33 +50,27 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -81,100 +83,88 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, R9, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_12: bool; - var Gamma_R8_13: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_9: bool; - var Gamma_R9: bool; - var Gamma_R9_2: bool; - var Gamma_R9_4: bool; - var R0_1: bv64; - var R8_12: bv64; - var R8_13: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_9: bv64; - var R9: bv64; - var R9_2: bv64; - var R9_4: bv64; + var Cse0__5$3$5: bv32; + var Gamma_Cse0__5$3$5: bool; $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1880$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + Cse0__5$3$5, Gamma_Cse0__5$3$5 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$3$5, Cse0__5$3$5)), Gamma_Cse0__5$3$5; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$5), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$3$5); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$5, 0bv32), Gamma_Cse0__5$3$5; + NF, Gamma_NF := Cse0__5$3$5[32:31], Gamma_Cse0__5$3$5; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$3$5), Gamma_Cse0__5$3$5; + assert Gamma_ZF; goto $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__0, $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__1; - $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__1: - assume (!(R8_3 == 0bv32)); - goto $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__1_phi_$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__3__$MDEkbquZQ0KXk1JWhP4elQ_phi_back_$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__3__$MDEkbquZQ0KXk1JWhP4elQ, $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__1_phi_$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__1__$baEU1iczT1WhDbVoju64Lg_phi_back_$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__1__$baEU1iczT1WhDbVoju64Lg; - $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__1_phi_$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__1__$baEU1iczT1WhDbVoju64Lg_phi_back_$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__1__$baEU1iczT1WhDbVoju64Lg: - R8_9, Gamma_R8_9 := 1bv64, true; - assert Gamma_R8_9; - goto $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__1__$baEU1iczT1WhDbVoju64Lg; - $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__1_phi_$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__3__$MDEkbquZQ0KXk1JWhP4elQ_phi_back_$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__3__$MDEkbquZQ0KXk1JWhP4elQ: - R8_12, Gamma_R8_12 := 1bv64, true; - assert Gamma_R8_12; - goto $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__3__$MDEkbquZQ0KXk1JWhP4elQ; - $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__0: - assume (R8_3 == 0bv32); - goto $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__0_phi_back_$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__1__$baEU1iczT1WhDbVoju64Lg, $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__0_phi_back_$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__3__$MDEkbquZQ0KXk1JWhP4elQ; - $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__0_phi_back_$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__3__$MDEkbquZQ0KXk1JWhP4elQ: - R8_12, Gamma_R8_12 := 0bv64, true; - assert Gamma_R8_12; - goto $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__3__$MDEkbquZQ0KXk1JWhP4elQ; - $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__3__$MDEkbquZQ0KXk1JWhP4elQ: - assume (R8_12[1:0] == 1bv1); - R9_4, Gamma_R9_4 := R9, Gamma_R9; - R8_13, Gamma_R8_13 := R8_12, Gamma_R8_12; - goto $main$__3__$MDEkbquZQ0KXk1JWhP4elQ; - $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__0_phi_back_$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__1__$baEU1iczT1WhDbVoju64Lg: - R8_9, Gamma_R8_9 := 0bv64, true; - assert Gamma_R8_9; - goto $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__1__$baEU1iczT1WhDbVoju64Lg; - $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__1__$baEU1iczT1WhDbVoju64Lg: - assume (!(R8_9[1:0] == 1bv1)); + $main$__1__$baEU1iczT1WhDbVoju64Lg: + assume {:captureState "$main$__1__$baEU1iczT1WhDbVoju64Lg"} true; + goto $main$__2__$pEVh12TOROuFnk2eh834jw; + $main$__2__$pEVh12TOROuFnk2eh834jw: + assume {:captureState "$main$__2__$pEVh12TOROuFnk2eh834jw"} true; + R8, Gamma_R8 := 1bv64, true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); call rely(); - assert (L(mem, R9_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 1bv32), gamma_store32(Gamma_mem, R9_2, true); - R9_4, Gamma_R9_4 := R9_2, Gamma_R9_2; - R8_13, Gamma_R8_13 := 1bv64, true; + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1924$0"} true; goto $main$__3__$MDEkbquZQ0KXk1JWhP4elQ; $main$__3__$MDEkbquZQ0KXk1JWhP4elQ: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__3__$MDEkbquZQ0KXk1JWhP4elQ"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__3__$MDEkbquZQ0KXk1JWhP4elQ: + assume {:captureState "$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__3__$MDEkbquZQ0KXk1JWhP4elQ"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$MDEkbquZQ0KXk1JWhP4elQ; + $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__1__$baEU1iczT1WhDbVoju64Lg: + assume {:captureState "$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__1__$baEU1iczT1WhDbVoju64Lg"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$baEU1iczT1WhDbVoju64Lg; + $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__0: + assume {:captureState "$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__3__$MDEkbquZQ0KXk1JWhP4elQ, $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__1__$baEU1iczT1WhDbVoju64Lg; + $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__1: + assume {:captureState "$main$__0__$rjOo3YInS9ep6ZpsZcGhEQ$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__3__$MDEkbquZQ0KXk1JWhP4elQ, $main$__0__$rjOo3YInS9ep6ZpsZcGhEQ_goto_$main$__1__$baEU1iczT1WhDbVoju64Lg; main_basil_return: - R0_out, R31_out, R8_out, R9_out := R0_1, R31_in, R8_13, R9_4; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_13, Gamma_R9_4; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifglobal/gcc/ifglobal.expected b/src/test/correct/ifglobal/gcc/ifglobal.expected index 561ffa3d3..ef4f35400 100644 --- a/src/test/correct/ifglobal/gcc/ifglobal.expected +++ b/src/test/correct/ifglobal/gcc/ifglobal.expected @@ -1,31 +1,36 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,22 +41,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1876bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1877bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1878bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1879bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1876bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -59,8 +60,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -73,54 +74,62 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R1, VF, ZF, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1876bv64) == 1bv8); - free requires (memory_load8_le(mem, 1877bv64) == 0bv8); - free requires (memory_load8_le(mem, 1878bv64) == 2bv8); - free requires (memory_load8_le(mem, 1879bv64) == 0bv8); + free requires (memory_load32_le(mem, 1876bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1876bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1877bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1878bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1879bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1876bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_4: bool; - var Gamma_R1_4: bool; - var R0_4: bv32; - var R1_4: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000302, lmain_goto_l00000311; - lmain_goto_l00000311: - assume (R0_4 == 0bv32); + l00000311: + assume {:captureState "l00000311"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); - R1_4, Gamma_R1_4 := 1bv64, true; - goto l00000302; - lmain_goto_l00000302: - assume (!(R0_4 == 0bv32)); - R1_4, Gamma_R1_4 := R1_in, Gamma_R1_in; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000327"} true; goto l00000302; l00000302: + assume {:captureState "l00000302"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + lmain_goto_l00000302: + assume {:captureState "lmain_goto_l00000302"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000302; + lmain_goto_l00000311: + assume {:captureState "lmain_goto_l00000311"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000311; main_basil_return: - R0_out, R1_out := 0bv64, R1_4; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_4; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifglobal/gcc/ifglobal_gtirb.expected b/src/test/correct/ifglobal/gcc/ifglobal_gtirb.expected index 3ed7a16fb..0b7d7767d 100644 --- a/src/test/correct/ifglobal/gcc/ifglobal_gtirb.expected +++ b/src/test/correct/ifglobal/gcc/ifglobal_gtirb.expected @@ -1,31 +1,35 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,22 +40,17 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1876bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1877bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1878bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1879bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1876bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -59,8 +58,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -73,54 +72,62 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R1, VF, ZF, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1876bv64) == 1bv8); - free requires (memory_load8_le(mem, 1877bv64) == 0bv8); - free requires (memory_load8_le(mem, 1878bv64) == 2bv8); - free requires (memory_load8_le(mem, 1879bv64) == 0bv8); + free requires (memory_load32_le(mem, 1876bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1876bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1877bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1878bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1879bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1876bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_4: bool; - var Gamma_R1_4: bool; - var R0_4: bv32; - var R1_4: bv64; + var Cse0__5$0$3: bv32; + var Gamma_Cse0__5$0$3: bool; $main$__0__$BdIXwXrPTNePMukmPFVqTg: + assume {:captureState "$main$__0__$BdIXwXrPTNePMukmPFVqTg"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$0$3, Gamma_Cse0__5$0$3 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$3, Cse0__5$0$3)), Gamma_Cse0__5$0$3; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$3), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$0$3); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$3, 0bv32), Gamma_Cse0__5$0$3; + NF, Gamma_NF := Cse0__5$0$3[32:31], Gamma_Cse0__5$0$3; + assert Gamma_ZF; goto $main$__0__$BdIXwXrPTNePMukmPFVqTg_goto_$main$__2__$tIV0kBzOR1qEmAHuGr1c7Q, $main$__0__$BdIXwXrPTNePMukmPFVqTg_goto_$main$__1__$8wzGZjEOTmOYnhkjdJ4aCQ; - $main$__0__$BdIXwXrPTNePMukmPFVqTg_goto_$main$__1__$8wzGZjEOTmOYnhkjdJ4aCQ: - assume (R0_4 == 0bv32); + $main$__1__$8wzGZjEOTmOYnhkjdJ4aCQ: + assume {:captureState "$main$__1__$8wzGZjEOTmOYnhkjdJ4aCQ"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); - R1_4, Gamma_R1_4 := 1bv64, true; - goto $main$__2__$tIV0kBzOR1qEmAHuGr1c7Q; - $main$__0__$BdIXwXrPTNePMukmPFVqTg_goto_$main$__2__$tIV0kBzOR1qEmAHuGr1c7Q: - assume (!(R0_4 == 0bv32)); - R1_4, Gamma_R1_4 := R1_in, Gamma_R1_in; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1844$0"} true; goto $main$__2__$tIV0kBzOR1qEmAHuGr1c7Q; $main$__2__$tIV0kBzOR1qEmAHuGr1c7Q: + assume {:captureState "$main$__2__$tIV0kBzOR1qEmAHuGr1c7Q"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + $main$__0__$BdIXwXrPTNePMukmPFVqTg_goto_$main$__2__$tIV0kBzOR1qEmAHuGr1c7Q: + assume {:captureState "$main$__0__$BdIXwXrPTNePMukmPFVqTg_goto_$main$__2__$tIV0kBzOR1qEmAHuGr1c7Q"} true; + assume (!(ZF == 1bv1)); + goto $main$__2__$tIV0kBzOR1qEmAHuGr1c7Q; + $main$__0__$BdIXwXrPTNePMukmPFVqTg_goto_$main$__1__$8wzGZjEOTmOYnhkjdJ4aCQ: + assume {:captureState "$main$__0__$BdIXwXrPTNePMukmPFVqTg_goto_$main$__1__$8wzGZjEOTmOYnhkjdJ4aCQ"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__1__$8wzGZjEOTmOYnhkjdJ4aCQ; main_basil_return: - R0_out, R1_out := 0bv64, R1_4; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_4; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifglobal/gcc_O2/ifglobal.expected b/src/test/correct/ifglobal/gcc_O2/ifglobal.expected index 3fff81fb3..1e0ea5e01 100644 --- a/src/test/correct/ifglobal/gcc_O2/ifglobal.expected +++ b/src/test/correct/ifglobal/gcc_O2/ifglobal.expected @@ -1,31 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,23 +29,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -60,8 +46,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -74,54 +60,52 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R1_2: bool; - var Gamma_R1_5: bool; - var R1_2: bv64; - var R1_5: bv64; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; call rely(); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(mem, 69652bv64)), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R1_2; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, bvadd64(R0, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R0, 20bv64)) || L(mem, bvadd64(R0, 20bv64))); + assert Gamma_R1; goto lmain_goto_l000001b7, lmain_goto_l00000396; - lmain_goto_l00000396: - assume (R1_2[32:0] == 0bv32); + l00000396: + assume {:captureState "l00000396"} true; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); - R1_5, Gamma_R1_5 := 1bv64, true; - goto l000001b7; - lmain_goto_l000001b7: - assume (!(R1_2[32:0] == 0bv32)); - R1_5, Gamma_R1_5 := R1_2, Gamma_R1_2; + assert (L(mem, bvadd64(R0, 20bv64)) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 20bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 20bv64), Gamma_R1); + assume {:captureState "%000003a1"} true; goto l000001b7; l000001b7: + assume {:captureState "l000001b7"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + lmain_goto_l000001b7: + assume {:captureState "lmain_goto_l000001b7"} true; + assume (bvnot1(bvcomp32(R1[32:0], 0bv32)) != 0bv1); + goto l000001b7; + lmain_goto_l00000396: + assume {:captureState "lmain_goto_l00000396"} true; + assume (bvnot1(bvcomp32(R1[32:0], 0bv32)) == 0bv1); + goto l00000396; main_basil_return: - R0_out, R1_out := 0bv64, R1_5; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifglobal/gcc_O2/ifglobal_gtirb.expected b/src/test/correct/ifglobal/gcc_O2/ifglobal_gtirb.expected index 9ca4f3ece..0b576dc6c 100644 --- a/src/test/correct/ifglobal/gcc_O2/ifglobal_gtirb.expected +++ b/src/test/correct/ifglobal/gcc_O2/ifglobal_gtirb.expected @@ -1,31 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,23 +27,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -60,8 +44,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -74,54 +58,52 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R1_2: bool; - var Gamma_R1_5: bool; - var R1_2: bv64; - var R1_5: bv64; $main$__0__$ggTiniswTki0OuJx7AXB6A: + assume {:captureState "$main$__0__$ggTiniswTki0OuJx7AXB6A"} true; + R0, Gamma_R0 := 69632bv64, true; call rely(); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(mem, 69652bv64)), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R1_2; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, bvadd64(R0, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R0, 20bv64)) || L(mem, bvadd64(R0, 20bv64))); + assert Gamma_R1; goto $main$__0__$ggTiniswTki0OuJx7AXB6A_goto_$main$__2__$bRJzoNVcSf~geSM2_j94rg, $main$__0__$ggTiniswTki0OuJx7AXB6A_goto_$main$__1__$TcEobJ5CQB~dL48wnkCobA; - $main$__0__$ggTiniswTki0OuJx7AXB6A_goto_$main$__1__$TcEobJ5CQB~dL48wnkCobA: - assume (R1_2[32:0] == 0bv32); + $main$__1__$TcEobJ5CQB~dL48wnkCobA: + assume {:captureState "$main$__1__$TcEobJ5CQB~dL48wnkCobA"} true; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); - R1_5, Gamma_R1_5 := 1bv64, true; - goto $main$__2__$bRJzoNVcSf~geSM2_j94rg; - $main$__0__$ggTiniswTki0OuJx7AXB6A_goto_$main$__2__$bRJzoNVcSf~geSM2_j94rg: - assume (!(R1_2[32:0] == 0bv32)); - R1_5, Gamma_R1_5 := R1_2, Gamma_R1_2; + assert (L(mem, bvadd64(R0, 20bv64)) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 20bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 20bv64), Gamma_R1); + assume {:captureState "1552$0"} true; goto $main$__2__$bRJzoNVcSf~geSM2_j94rg; $main$__2__$bRJzoNVcSf~geSM2_j94rg: + assume {:captureState "$main$__2__$bRJzoNVcSf~geSM2_j94rg"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + $main$__0__$ggTiniswTki0OuJx7AXB6A_goto_$main$__2__$bRJzoNVcSf~geSM2_j94rg: + assume {:captureState "$main$__0__$ggTiniswTki0OuJx7AXB6A_goto_$main$__2__$bRJzoNVcSf~geSM2_j94rg"} true; + assume ((R1[32:0] == 0bv32) == false); + goto $main$__2__$bRJzoNVcSf~geSM2_j94rg; + $main$__0__$ggTiniswTki0OuJx7AXB6A_goto_$main$__1__$TcEobJ5CQB~dL48wnkCobA: + assume {:captureState "$main$__0__$ggTiniswTki0OuJx7AXB6A_goto_$main$__1__$TcEobJ5CQB~dL48wnkCobA"} true; + assume (!((R1[32:0] == 0bv32) == false)); + goto $main$__1__$TcEobJ5CQB~dL48wnkCobA; main_basil_return: - R0_out, R1_out := 0bv64, R1_5; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifglobal/gcc_pic/ifglobal.expected b/src/test/correct/ifglobal/gcc_pic/ifglobal.expected index d2e02a379..99d76739e 100644 --- a/src/test/correct/ifglobal/gcc_pic/ifglobal.expected +++ b/src/test/correct/ifglobal/gcc_pic/ifglobal.expected @@ -1,21 +1,30 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -25,11 +34,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,32 +45,28 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1940bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1941bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1942bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1943bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1940bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -78,64 +79,66 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R1, VF, ZF, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1940bv64) == 1bv8); - free requires (memory_load8_le(mem, 1941bv64) == 0bv8); - free requires (memory_load8_le(mem, 1942bv64) == 2bv8); - free requires (memory_load8_le(mem, 1943bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1940bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1940bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1941bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1942bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1943bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1940bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_6: bool; - var Gamma_R1_4: bool; - var R0_3: bv64; - var R0_4: bv32; - var R0_6: bv64; - var R1_4: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, R0_3), (gamma_load32(Gamma_mem, R0_3) || L(mem, R0_3)); - assert Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000303, lmain_goto_l00000312; - lmain_goto_l00000312: - assume (R0_4 == 0bv32); + l00000312: + assume {:captureState "l00000312"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_6, Gamma_R0_6 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_6) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_6, 1bv32), gamma_store32(Gamma_mem, R0_6, true); - R1_4, Gamma_R1_4 := 1bv64, true; - goto l00000303; - lmain_goto_l00000303: - assume (!(R0_4 == 0bv32)); - R1_4, Gamma_R1_4 := R1_in, Gamma_R1_in; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000329"} true; goto l00000303; l00000303: + assume {:captureState "l00000303"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + lmain_goto_l00000303: + assume {:captureState "lmain_goto_l00000303"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000303; + lmain_goto_l00000312: + assume {:captureState "lmain_goto_l00000312"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000312; main_basil_return: - R0_out, R1_out := 0bv64, R1_4; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_4; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/ifglobal/gcc_pic/ifglobal_gtirb.expected b/src/test/correct/ifglobal/gcc_pic/ifglobal_gtirb.expected index 29bf975af..599a59bca 100644 --- a/src/test/correct/ifglobal/gcc_pic/ifglobal_gtirb.expected +++ b/src/test/correct/ifglobal/gcc_pic/ifglobal_gtirb.expected @@ -1,21 +1,29 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -25,11 +33,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,32 +44,27 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1940bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1941bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1942bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1943bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1940bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -78,64 +77,66 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R1, VF, ZF, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1940bv64) == 1bv8); - free requires (memory_load8_le(mem, 1941bv64) == 0bv8); - free requires (memory_load8_le(mem, 1942bv64) == 2bv8); - free requires (memory_load8_le(mem, 1943bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1940bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1940bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1941bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1942bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1943bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1940bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_6: bool; - var Gamma_R1_4: bool; - var R0_3: bv64; - var R0_4: bv32; - var R0_6: bv64; - var R1_4: bv64; + var Cse0__5$0$3: bv32; + var Gamma_Cse0__5$0$3: bool; $main$__0__$Loy76gLhRcC4mniw9_LJhw: + assume {:captureState "$main$__0__$Loy76gLhRcC4mniw9_LJhw"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, R0_3), (gamma_load32(Gamma_mem, R0_3) || L(mem, R0_3)); - assert Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$0$3, Gamma_Cse0__5$0$3 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$3, Cse0__5$0$3)), Gamma_Cse0__5$0$3; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$3), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$0$3); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$3, 0bv32), Gamma_Cse0__5$0$3; + NF, Gamma_NF := Cse0__5$0$3[32:31], Gamma_Cse0__5$0$3; + assert Gamma_ZF; goto $main$__0__$Loy76gLhRcC4mniw9_LJhw_goto_$main$__2__$3D20OWy7Q32oBwBQc0XvUQ, $main$__0__$Loy76gLhRcC4mniw9_LJhw_goto_$main$__1__$k_rnnhlXQEmc~8A~_rBrZg; - $main$__0__$Loy76gLhRcC4mniw9_LJhw_goto_$main$__1__$k_rnnhlXQEmc~8A~_rBrZg: - assume (R0_4 == 0bv32); + $main$__1__$k_rnnhlXQEmc~8A~_rBrZg: + assume {:captureState "$main$__1__$k_rnnhlXQEmc~8A~_rBrZg"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_6, Gamma_R0_6 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_6) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_6, 1bv32), gamma_store32(Gamma_mem, R0_6, true); - R1_4, Gamma_R1_4 := 1bv64, true; - goto $main$__2__$3D20OWy7Q32oBwBQc0XvUQ; - $main$__0__$Loy76gLhRcC4mniw9_LJhw_goto_$main$__2__$3D20OWy7Q32oBwBQc0XvUQ: - assume (!(R0_4 == 0bv32)); - R1_4, Gamma_R1_4 := R1_in, Gamma_R1_in; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1908$0"} true; goto $main$__2__$3D20OWy7Q32oBwBQc0XvUQ; $main$__2__$3D20OWy7Q32oBwBQc0XvUQ: + assume {:captureState "$main$__2__$3D20OWy7Q32oBwBQc0XvUQ"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; + $main$__0__$Loy76gLhRcC4mniw9_LJhw_goto_$main$__2__$3D20OWy7Q32oBwBQc0XvUQ: + assume {:captureState "$main$__0__$Loy76gLhRcC4mniw9_LJhw_goto_$main$__2__$3D20OWy7Q32oBwBQc0XvUQ"} true; + assume (!(ZF == 1bv1)); + goto $main$__2__$3D20OWy7Q32oBwBQc0XvUQ; + $main$__0__$Loy76gLhRcC4mniw9_LJhw_goto_$main$__1__$k_rnnhlXQEmc~8A~_rBrZg: + assume {:captureState "$main$__0__$Loy76gLhRcC4mniw9_LJhw_goto_$main$__1__$k_rnnhlXQEmc~8A~_rBrZg"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__1__$k_rnnhlXQEmc~8A~_rBrZg; main_basil_return: - R0_out, R1_out := 0bv64, R1_4; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_4; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/indirect_call/clang/indirect_call_gtirb.expected b/src/test/correct/indirect_call/clang/indirect_call_gtirb.expected index c2d9a43d1..2afb32f54 100644 --- a/src/test/correct/indirect_call/clang/indirect_call_gtirb.expected +++ b/src/test/correct/indirect_call/clang/indirect_call_gtirb.expected @@ -1,28 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1996bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -32,15 +32,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -56,18 +52,18 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load8_le(mem, 1996bv64) == 1bv8); free ensures (memory_load8_le(mem, 1997bv64) == 0bv8); free ensures (memory_load8_le(mem, 1998bv64) == 2bv8); @@ -88,8 +84,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -102,8 +98,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_630(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load8_le(mem, 1996bv64) == 1bv8); free requires (memory_load8_le(mem, 1997bv64) == 0bv8); free requires (memory_load8_le(mem, 1998bv64) == 2bv8); @@ -139,143 +135,20 @@ procedure FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 1904bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_630() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_630$__0__$49PTrR3fTD2lKP8wnhJ57g: + assume {:captureState "$FUN_630$__0__$49PTrR3fTD2lKP8wnhJ57g"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69664bv64), (gamma_load64(Gamma_mem, 69664bv64) || L(mem, 69664bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69664bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 32bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 32bv64)) || L(mem, bvadd64(R16, 32bv64))); + R16, Gamma_R16 := bvadd64(R16, 32bv64), Gamma_R16; + call printf(); assume false; } -procedure greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure greet(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load8_le(mem, 1996bv64) == 1bv8); free requires (memory_load8_le(mem, 1997bv64) == 0bv8); free requires (memory_load8_le(mem, 1998bv64) == 2bv8); @@ -293,6 +166,10 @@ procedure greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bo free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1904bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load8_le(mem, 1996bv64) == 1bv8); free ensures (memory_load8_le(mem, 1997bv64) == 0bv8); free ensures (memory_load8_le(mem, 1998bv64) == 2bv8); @@ -311,27 +188,37 @@ procedure greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bo free ensures (memory_load64_le(mem, 69592bv64) == 1904bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool) +implementation greet() { - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; + var Cse0__5$0$0: bv64; + var Gamma_Cse0__5$0$0: bool; $greet$__0__$Nd2KKa~UT46Es~75P1pNcg: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_630(R16, Gamma_R16); + assume {:captureState "$greet$__0__$Nd2KKa~UT46Es~75P1pNcg"} true; + Cse0__5$0$0, Gamma_Cse0__5$0$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$0, R29), gamma_store64(Gamma_stack, Cse0__5$0$0, Gamma_R29); + assume {:captureState "1876$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$0, 8bv64), Gamma_R30); + assume {:captureState "1876$2"} true; + R31, Gamma_R31 := Cse0__5$0$0, Gamma_Cse0__5$0$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2000bv64), Gamma_R0; + R30, Gamma_R30 := 1896bv64, true; + call FUN_630(); + goto $greet$__1__$wP8zXF~mT7CtEXlgRwnnfA; + $greet$__1__$wP8zXF~mT7CtEXlgRwnnfA: + assume {:captureState "$greet$__1__$wP8zXF~mT7CtEXlgRwnnfA"} true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto greet_basil_return; greet_basil_return: - R31_out := R31_in; - Gamma_R31_out := Gamma_R31_in; + assume {:captureState "greet_basil_return"} true; return; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_mem, Gamma_stack, R0, R16, R17, R29, R30, R31, R8, mem, stack; free requires (memory_load64_le(mem, 69672bv64) == 0bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free requires (memory_load8_le(mem, 1996bv64) == 1bv8); @@ -351,6 +238,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1904bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load8_le(mem, 1996bv64) == 1bv8); free ensures (memory_load8_le(mem, 1997bv64) == 0bv8); free ensures (memory_load8_le(mem, 1998bv64) == 2bv8); @@ -369,48 +260,55 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 1904bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_4: bool; - var Gamma_R31_3: bool; - var Gamma_R8_4: bool; - var R0_3: bv64; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; - var R29_3: bv64; - var R30_4: bv64; - var R31_3: bv64; - var R8_4: bv64; + var Cse0__5$0$1: bv64; + var Cse0__5$1$1: bv64; + var Gamma_Cse0__5$0$1: bool; + var Gamma_Cse0__5$1$1: bool; $main$__0__$YfoEKj0KQgmJWDAtkqhLtQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551580bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), 1876bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), true); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_630(R16, Gamma_R16); + assume {:captureState "$main$__0__$YfoEKj0KQgmJWDAtkqhLtQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + Cse0__5$0$1, Gamma_Cse0__5$0$1 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$1, R29), gamma_store64(Gamma_stack, Cse0__5$0$1, Gamma_R29); + assume {:captureState "1908$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$1, 8bv64), Gamma_R30); + assume {:captureState "1908$2"} true; + R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; + R8, Gamma_R8 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1920$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "1924$0"} true; + R8, Gamma_R8 := 0bv64, true; + R8, Gamma_R8 := bvadd64(R8, 1876bv64), Gamma_R8; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R8); + assume {:captureState "1936$0"} true; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2015bv64), Gamma_R0; + R30, Gamma_R30 := 1952bv64, true; + call FUN_630(); goto $main$__1__$2meKsDplTtaQ3v5DgFlGYQ; $main$__1__$2meKsDplTtaQ3v5DgFlGYQ: - R8_4, Gamma_R8_4 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - call R31_3, Gamma_R31_3 := greet(bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, 1960bv64, true, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R31_in); + assume {:captureState "$main$__1__$2meKsDplTtaQ3v5DgFlGYQ"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R30, Gamma_R30 := 1960bv64, true; + call greet(); goto $main$__2__$ZjG4NofsQHGQIBdy45MZMg; $main$__2__$ZjG4NofsQHGQIBdy45MZMg: - R0_3, Gamma_R0_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_3, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31_3, 12bv64)); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_3, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 32bv64)); - R30_4, Gamma_R30_4 := memory_load64_le(stack, bvadd64(R31_3, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 40bv64)); + assume {:captureState "$main$__2__$ZjG4NofsQHGQIBdy45MZMg"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + Cse0__5$1$1, Gamma_Cse0__5$1$1 := bvadd64(R31, 32bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$1$1), gamma_load64(Gamma_stack, Cse0__5$1$1); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$1$1, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$1$1, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R29_out, R30_out, R31_out, R8_out := R0_3, R16_1, R17_1, R29_3, R30_4, bvadd64(R31_3, 48bv64), R8_4; - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_3, Gamma_R16_1, Gamma_R17_1, Gamma_R29_3, Gamma_R30_4, Gamma_R31_3, Gamma_R8_4; + assume {:captureState "main_basil_return"} true; return; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load8_le(mem, 1996bv64) == 1bv8); free requires (memory_load8_le(mem, 1997bv64) == 0bv8); free requires (memory_load8_le(mem, 1998bv64) == 2bv8); diff --git a/src/test/correct/indirect_call/clang_pic/indirect_call_gtirb.expected b/src/test/correct/indirect_call/clang_pic/indirect_call_gtirb.expected index de3813cc9..85aa00a9a 100644 --- a/src/test/correct/indirect_call/clang_pic/indirect_call_gtirb.expected +++ b/src/test/correct/indirect_call/clang_pic/indirect_call_gtirb.expected @@ -1,28 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2060bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -32,15 +32,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -56,18 +52,18 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load8_le(mem, 2060bv64) == 1bv8); free ensures (memory_load8_le(mem, 2061bv64) == 0bv8); free ensures (memory_load8_le(mem, 2062bv64) == 2bv8); @@ -81,16 +77,16 @@ procedure {:extern} rely(); free ensures (memory_load8_le(mem, 2105bv64) == 58bv8); free ensures (memory_load8_le(mem, 2106bv64) == 10bv8); free ensures (memory_load8_le(mem, 2107bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69056bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1968bv64); + free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -103,8 +99,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_mem, Gamma_stack, R0, R16, R17, R29, R30, R31, R8, mem, stack; free requires (memory_load64_le(mem, 69672bv64) == 0bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free requires (memory_load8_le(mem, 2060bv64) == 1bv8); @@ -120,11 +116,15 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load8_le(mem, 2105bv64) == 58bv8); free requires (memory_load8_le(mem, 2106bv64) == 10bv8); free requires (memory_load8_le(mem, 2107bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 1940bv64); - free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free requires (memory_load64_le(mem, 69056bv64) == 1936bv64); free requires (memory_load64_le(mem, 69064bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69576bv64) == 1940bv64); free requires (memory_load64_le(mem, 69592bv64) == 1968bv64); + free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load8_le(mem, 2060bv64) == 1bv8); free ensures (memory_load8_le(mem, 2061bv64) == 0bv8); free ensures (memory_load8_le(mem, 2062bv64) == 2bv8); @@ -138,59 +138,63 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load8_le(mem, 2105bv64) == 58bv8); free ensures (memory_load8_le(mem, 2106bv64) == 10bv8); free ensures (memory_load8_le(mem, 2107bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69056bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1968bv64); + free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_4: bool; - var Gamma_R31_3: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var R0_3: bv64; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; - var R29_3: bv64; - var R30_4: bv64; - var R31_3: bv64; - var R8_3: bv64; - var R8_4: bv64; + var Cse0__5$0$1: bv64; + var Cse0__5$2$1: bv64; + var Gamma_Cse0__5$0$1: bool; + var Gamma_Cse0__5$2$1: bool; $main$__0__$sMTViGMvRc6UQwwHLkZ0lg: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551580bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); + assume {:captureState "$main$__0__$sMTViGMvRc6UQwwHLkZ0lg"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + Cse0__5$0$1, Gamma_Cse0__5$0$1 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$1, R29), gamma_store64(Gamma_stack, Cse0__5$0$1, Gamma_R29); + assume {:captureState "1972$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$1, 8bv64), Gamma_R30); + assume {:captureState "1972$2"} true; + R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; + R8, Gamma_R8 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1984$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "1988$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R8_3), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R8_3); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_650(R16, Gamma_R16); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R8); + assume {:captureState "2000$0"} true; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2079bv64), Gamma_R0; + R30, Gamma_R30 := 2016bv64, true; + call FUN_650(); goto $main$__1__$3xrW3vxVQYegwMrQhPeDAA; $main$__1__$3xrW3vxVQYegwMrQhPeDAA: - R8_4, Gamma_R8_4 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - call R31_3, Gamma_R31_3 := greet(bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, 2024bv64, true, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R31_in); + assume {:captureState "$main$__1__$3xrW3vxVQYegwMrQhPeDAA"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R30, Gamma_R30 := 2024bv64, true; + call greet(); goto $main$__2__$~oSET3ZKQL2oiUDT8~pKHA; $main$__2__$~oSET3ZKQL2oiUDT8~pKHA: - R0_3, Gamma_R0_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_3, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31_3, 12bv64)); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_3, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 32bv64)); - R30_4, Gamma_R30_4 := memory_load64_le(stack, bvadd64(R31_3, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 40bv64)); + assume {:captureState "$main$__2__$~oSET3ZKQL2oiUDT8~pKHA"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + Cse0__5$2$1, Gamma_Cse0__5$2$1 := bvadd64(R31, 32bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$2$1), gamma_load64(Gamma_stack, Cse0__5$2$1); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$2$1, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$2$1, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out := R0_3, R29_3, R30_4, bvadd64(R31_3, 48bv64), R8_4; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_3, Gamma_R29_3, Gamma_R30_4, Gamma_R31_3, Gamma_R8_4; + assume {:captureState "main_basil_return"} true; return; } -procedure FUN_650(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_650(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load8_le(mem, 2060bv64) == 1bv8); free requires (memory_load8_le(mem, 2061bv64) == 0bv8); free requires (memory_load8_le(mem, 2062bv64) == 2bv8); @@ -204,11 +208,11 @@ procedure FUN_650(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free requires (memory_load8_le(mem, 2105bv64) == 58bv8); free requires (memory_load8_le(mem, 2106bv64) == 10bv8); free requires (memory_load8_le(mem, 2107bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 1940bv64); - free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free requires (memory_load64_le(mem, 69056bv64) == 1936bv64); free requires (memory_load64_le(mem, 69064bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69576bv64) == 1940bv64); free requires (memory_load64_le(mem, 69592bv64) == 1968bv64); + free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free ensures (memory_load8_le(mem, 2060bv64) == 1bv8); free ensures (memory_load8_le(mem, 2061bv64) == 0bv8); free ensures (memory_load8_le(mem, 2062bv64) == 2bv8); @@ -222,149 +226,26 @@ procedure FUN_650(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load8_le(mem, 2105bv64) == 58bv8); free ensures (memory_load8_le(mem, 2106bv64) == 10bv8); free ensures (memory_load8_le(mem, 2107bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69056bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1968bv64); + free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation FUN_650(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_650() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_650$__0__$Q8~f_ny6Tyei9F9VZVqpig: + assume {:captureState "$FUN_650$__0__$Q8~f_ny6Tyei9F9VZVqpig"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69664bv64), (gamma_load64(Gamma_mem, 69664bv64) || L(mem, 69664bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69664bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 32bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 32bv64)) || L(mem, bvadd64(R16, 32bv64))); + R16, Gamma_R16 := bvadd64(R16, 32bv64), Gamma_R16; + call printf(); assume false; } -procedure greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure greet(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load8_le(mem, 2060bv64) == 1bv8); free requires (memory_load8_le(mem, 2061bv64) == 0bv8); free requires (memory_load8_le(mem, 2062bv64) == 2bv8); @@ -378,11 +259,15 @@ procedure greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bo free requires (memory_load8_le(mem, 2105bv64) == 58bv8); free requires (memory_load8_le(mem, 2106bv64) == 10bv8); free requires (memory_load8_le(mem, 2107bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 1940bv64); - free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free requires (memory_load64_le(mem, 69056bv64) == 1936bv64); free requires (memory_load64_le(mem, 69064bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69576bv64) == 1940bv64); free requires (memory_load64_le(mem, 69592bv64) == 1968bv64); + free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load8_le(mem, 2060bv64) == 1bv8); free ensures (memory_load8_le(mem, 2061bv64) == 0bv8); free ensures (memory_load8_le(mem, 2062bv64) == 2bv8); @@ -396,32 +281,42 @@ procedure greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bo free ensures (memory_load8_le(mem, 2105bv64) == 58bv8); free ensures (memory_load8_le(mem, 2106bv64) == 10bv8); free ensures (memory_load8_le(mem, 2107bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69056bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1968bv64); + free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool) +implementation greet() { - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; + var Cse0__5$1$0: bv64; + var Gamma_Cse0__5$1$0: bool; $greet$__0__$2iOaL1UgSjeQS6XoIxVEwg: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_650(R16, Gamma_R16); + assume {:captureState "$greet$__0__$2iOaL1UgSjeQS6XoIxVEwg"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$0, R29), gamma_store64(Gamma_stack, Cse0__5$1$0, Gamma_R29); + assume {:captureState "1940$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$0, 8bv64), Gamma_R30); + assume {:captureState "1940$2"} true; + R31, Gamma_R31 := Cse0__5$1$0, Gamma_Cse0__5$1$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2064bv64), Gamma_R0; + R30, Gamma_R30 := 1960bv64, true; + call FUN_650(); + goto $greet$__1__$qE3JfQuGRqKhzooPEQBb4Q; + $greet$__1__$qE3JfQuGRqKhzooPEQBb4Q: + assume {:captureState "$greet$__1__$qE3JfQuGRqKhzooPEQBb4Q"} true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto greet_basil_return; greet_basil_return: - R31_out := R31_in; - Gamma_R31_out := Gamma_R31_in; + assume {:captureState "greet_basil_return"} true; return; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load8_le(mem, 2060bv64) == 1bv8); free requires (memory_load8_le(mem, 2061bv64) == 0bv8); free requires (memory_load8_le(mem, 2062bv64) == 2bv8); @@ -435,11 +330,11 @@ procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free requires (memory_load8_le(mem, 2105bv64) == 58bv8); free requires (memory_load8_le(mem, 2106bv64) == 10bv8); free requires (memory_load8_le(mem, 2107bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 1940bv64); - free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free requires (memory_load64_le(mem, 69056bv64) == 1936bv64); free requires (memory_load64_le(mem, 69064bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69576bv64) == 1940bv64); free requires (memory_load64_le(mem, 69592bv64) == 1968bv64); + free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free ensures (memory_load8_le(mem, 2060bv64) == 1bv8); free ensures (memory_load8_le(mem, 2061bv64) == 0bv8); free ensures (memory_load8_le(mem, 2062bv64) == 2bv8); @@ -453,9 +348,9 @@ procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load8_le(mem, 2105bv64) == 58bv8); free ensures (memory_load8_le(mem, 2106bv64) == 10bv8); free ensures (memory_load8_le(mem, 2107bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69056bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1968bv64); + free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); diff --git a/src/test/correct/indirect_call/gcc/indirect_call_gtirb.expected b/src/test/correct/indirect_call/gcc/indirect_call_gtirb.expected index f6209344d..1b2be3e60 100644 --- a/src/test/correct/indirect_call/gcc/indirect_call_gtirb.expected +++ b/src/test/correct/indirect_call/gcc/indirect_call_gtirb.expected @@ -1,33 +1,32 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1984bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { @@ -39,13 +38,13 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 1984bv64) == 131073bv64); free ensures (memory_load64_le(mem, 1992bv64) == 8583909746840200520bv64); free ensures (memory_load64_le(mem, 2000bv64) == 143418749551bv64); @@ -63,8 +62,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -77,8 +76,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_630(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 1984bv64) == 131073bv64); free requires (memory_load64_le(mem, 1992bv64) == 8583909746840200520bv64); free requires (memory_load64_le(mem, 2000bv64) == 143418749551bv64); @@ -108,143 +107,20 @@ procedure FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 1908bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_630() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_630$__0__$tuyfiXKhQwyDbRrxvmvI3A: + assume {:captureState "$FUN_630$__0__$tuyfiXKhQwyDbRrxvmvI3A"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := puts(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69576bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4040bv64)) || L(mem, bvadd64(R16, 4040bv64))); + R16, Gamma_R16 := bvadd64(R16, 4040bv64), Gamma_R16; + call puts(); assume false; } -procedure greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure greet(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 1984bv64) == 131073bv64); free requires (memory_load64_le(mem, 1992bv64) == 8583909746840200520bv64); free requires (memory_load64_le(mem, 2000bv64) == 143418749551bv64); @@ -259,6 +135,10 @@ procedure greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bo free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1908bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 1984bv64) == 131073bv64); free ensures (memory_load64_le(mem, 1992bv64) == 8583909746840200520bv64); free ensures (memory_load64_le(mem, 2000bv64) == 143418749551bv64); @@ -274,27 +154,37 @@ procedure greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bo free ensures (memory_load64_le(mem, 69616bv64) == 1908bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool) +implementation greet() { - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; + var Cse0__5$1$0: bv64; + var Gamma_Cse0__5$1$0: bool; $greet$__0__$81FUb_xuSnaFuKB7SDT2jQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_630(R16, Gamma_R16); + assume {:captureState "$greet$__0__$81FUb_xuSnaFuKB7SDT2jQ"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$0, R29), gamma_store64(Gamma_stack, Cse0__5$1$0, Gamma_R29); + assume {:captureState "1876$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$0, 8bv64), Gamma_R30); + assume {:captureState "1876$2"} true; + R31, Gamma_R31 := Cse0__5$1$0, Gamma_Cse0__5$1$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 1992bv64), Gamma_R0; + R30, Gamma_R30 := 1896bv64, true; + call FUN_630(); + goto $greet$__1__$kdZai1woRdCWjv9gZOc7IQ; + $greet$__1__$kdZai1woRdCWjv9gZOc7IQ: + assume {:captureState "$greet$__1__$kdZai1woRdCWjv9gZOc7IQ"} true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto greet_basil_return; greet_basil_return: - R31_out := R31_in; - Gamma_R31_out := Gamma_R31_in; + assume {:captureState "greet_basil_return"} true; return; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 1984bv64) == 131073bv64); @@ -311,6 +201,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1908bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 1984bv64) == 131073bv64); free ensures (memory_load64_le(mem, 1992bv64) == 8583909746840200520bv64); free ensures (memory_load64_le(mem, 2000bv64) == 143418749551bv64); @@ -326,40 +220,47 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 1908bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_4: bool; - var Gamma_R31_3: bool; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; - var R29_3: bv64; - var R30_4: bv64; - var R31_3: bv64; + var Cse0__5$2$0: bv64; + var Gamma_Cse0__5$2$0: bool; $main$__0__$w0OdBToKQa2Q58glCiVypg: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 1876bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_630(R16, Gamma_R16); + assume {:captureState "$main$__0__$w0OdBToKQa2Q58glCiVypg"} true; + Cse0__5$2$0, Gamma_Cse0__5$2$0 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$2$0, R29), gamma_store64(Gamma_stack, Cse0__5$2$0, Gamma_R29); + assume {:captureState "1908$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$2$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$2$0, 8bv64), Gamma_R30); + assume {:captureState "1908$2"} true; + R31, Gamma_R31 := Cse0__5$2$0, Gamma_Cse0__5$2$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 1876bv64), Gamma_R0; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "1924$0"} true; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2008bv64), Gamma_R0; + R30, Gamma_R30 := 1940bv64, true; + call FUN_630(); goto $main$__1__$XCDB1coVTJ2EOAyBt9pNGg; $main$__1__$XCDB1coVTJ2EOAyBt9pNGg: - call R31_3, Gamma_R31_3 := greet(bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in, 1948bv64, true, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in); + assume {:captureState "$main$__1__$XCDB1coVTJ2EOAyBt9pNGg"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + R30, Gamma_R30 := 1948bv64, true; + call greet(); goto $main$__2__$CUvNMZuRSsiLfPsNmfjI_Q; $main$__2__$CUvNMZuRSsiLfPsNmfjI_Q: - R29_3, Gamma_R29_3 := memory_load64_le(stack, R31_3), gamma_load64(Gamma_stack, R31_3); - R30_4, Gamma_R30_4 := memory_load64_le(stack, bvadd64(R31_3, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 8bv64)); + assume {:captureState "$main$__2__$CUvNMZuRSsiLfPsNmfjI_Q"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R29_out, R30_out, R31_out := 0bv64, R16_1, R17_1, R29_3, R30_4, bvadd64(R31_3, 32bv64); - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R16_1, Gamma_R17_1, Gamma_R29_3, Gamma_R30_4, Gamma_R31_3; + assume {:captureState "main_basil_return"} true; return; } -procedure puts(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure puts(); free requires (memory_load64_le(mem, 1984bv64) == 131073bv64); free requires (memory_load64_le(mem, 1992bv64) == 8583909746840200520bv64); free requires (memory_load64_le(mem, 2000bv64) == 143418749551bv64); diff --git a/src/test/correct/indirect_call/gcc_pic/indirect_call_gtirb.expected b/src/test/correct/indirect_call/gcc_pic/indirect_call_gtirb.expected index fe03ab27d..01dd235a3 100644 --- a/src/test/correct/indirect_call/gcc_pic/indirect_call_gtirb.expected +++ b/src/test/correct/indirect_call/gcc_pic/indirect_call_gtirb.expected @@ -1,33 +1,32 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2048bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { @@ -39,13 +38,13 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2056bv64) == 8583909746840200520bv64); free ensures (memory_load64_le(mem, 2064bv64) == 143418749551bv64); @@ -56,16 +55,16 @@ procedure {:extern} rely(); free ensures (memory_load8_le(mem, 2097bv64) == 121bv8); free ensures (memory_load8_le(mem, 2098bv64) == 58bv8); free ensures (memory_load8_le(mem, 2099bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1972bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1972bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -78,8 +77,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure greet(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); free requires (memory_load64_le(mem, 2056bv64) == 8583909746840200520bv64); free requires (memory_load64_le(mem, 2064bv64) == 143418749551bv64); @@ -90,11 +89,15 @@ procedure greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bo free requires (memory_load8_le(mem, 2097bv64) == 121bv8); free requires (memory_load8_le(mem, 2098bv64) == 58bv8); free requires (memory_load8_le(mem, 2099bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1972bv64); - free requires (memory_load64_le(mem, 69600bv64) == 1940bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); free requires (memory_load64_le(mem, 69000bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69600bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1972bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2056bv64) == 8583909746840200520bv64); free ensures (memory_load64_le(mem, 2064bv64) == 143418749551bv64); @@ -105,33 +108,43 @@ procedure greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bo free ensures (memory_load8_le(mem, 2097bv64) == 121bv8); free ensures (memory_load8_le(mem, 2098bv64) == 58bv8); free ensures (memory_load8_le(mem, 2099bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1972bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1972bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation greet(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool) +implementation greet() { - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; + var Cse0__5$1$0: bv64; + var Gamma_Cse0__5$1$0: bool; $greet$__0__$ya12BsraQDyb0PY~D2lGYQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_650(R16, Gamma_R16); + assume {:captureState "$greet$__0__$ya12BsraQDyb0PY~D2lGYQ"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$0, R29), gamma_store64(Gamma_stack, Cse0__5$1$0, Gamma_R29); + assume {:captureState "1940$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$0, 8bv64), Gamma_R30); + assume {:captureState "1940$2"} true; + R31, Gamma_R31 := Cse0__5$1$0, Gamma_Cse0__5$1$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2056bv64), Gamma_R0; + R30, Gamma_R30 := 1960bv64, true; + call FUN_650(); + goto $greet$__1__$BAJa2ZW0ROGpI~IG4G4dnQ; + $greet$__1__$BAJa2ZW0ROGpI~IG4G4dnQ: + assume {:captureState "$greet$__1__$BAJa2ZW0ROGpI~IG4G4dnQ"} true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto greet_basil_return; greet_basil_return: - R31_out := R31_in; - Gamma_R31_out := Gamma_R31_in; + assume {:captureState "greet_basil_return"} true; return; } -procedure FUN_650(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_650(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); free requires (memory_load64_le(mem, 2056bv64) == 8583909746840200520bv64); free requires (memory_load64_le(mem, 2064bv64) == 143418749551bv64); @@ -142,11 +155,11 @@ procedure FUN_650(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free requires (memory_load8_le(mem, 2097bv64) == 121bv8); free requires (memory_load8_le(mem, 2098bv64) == 58bv8); free requires (memory_load8_le(mem, 2099bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1972bv64); - free requires (memory_load64_le(mem, 69600bv64) == 1940bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); free requires (memory_load64_le(mem, 69000bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69600bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1972bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2056bv64) == 8583909746840200520bv64); free ensures (memory_load64_le(mem, 2064bv64) == 143418749551bv64); @@ -157,149 +170,26 @@ procedure FUN_650(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load8_le(mem, 2097bv64) == 121bv8); free ensures (memory_load8_le(mem, 2098bv64) == 58bv8); free ensures (memory_load8_le(mem, 2099bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1972bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1972bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_650(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_650() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_650$__0__$blyA87erSRO9dBs3C_GROw: + assume {:captureState "$FUN_650$__0__$blyA87erSRO9dBs3C_GROw"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := puts(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69568bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4032bv64)) || L(mem, bvadd64(R16, 4032bv64))); + R16, Gamma_R16 := bvadd64(R16, 4032bv64), Gamma_R16; + call puts(); assume false; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); @@ -312,11 +202,15 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load8_le(mem, 2097bv64) == 121bv8); free requires (memory_load8_le(mem, 2098bv64) == 58bv8); free requires (memory_load8_le(mem, 2099bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1972bv64); - free requires (memory_load64_le(mem, 69600bv64) == 1940bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); free requires (memory_load64_le(mem, 69000bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69600bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1972bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2056bv64) == 8583909746840200520bv64); free ensures (memory_load64_le(mem, 2064bv64) == 143418749551bv64); @@ -327,50 +221,54 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load8_le(mem, 2097bv64) == 121bv8); free ensures (memory_load8_le(mem, 2098bv64) == 58bv8); free ensures (memory_load8_le(mem, 2099bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1972bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1972bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_4: bool; - var Gamma_R31_3: bool; - var R0_2: bv64; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; - var R29_3: bv64; - var R30_4: bv64; - var R31_3: bv64; + var Cse0__5$0$0: bv64; + var Gamma_Cse0__5$0$0: bool; $main$__0__$BoFgJ28hRESLWeRUGTZ6AQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); + assume {:captureState "$main$__0__$BoFgJ28hRESLWeRUGTZ6AQ"} true; + Cse0__5$0$0, Gamma_Cse0__5$0$0 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$0, R29), gamma_store64(Gamma_stack, Cse0__5$0$0, Gamma_R29); + assume {:captureState "1972$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$0, 8bv64), Gamma_R30); + assume {:captureState "1972$2"} true; + R31, Gamma_R31 := Cse0__5$0$0, Gamma_Cse0__5$0$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_2), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_2); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_650(R16, Gamma_R16); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "1988$0"} true; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2072bv64), Gamma_R0; + R30, Gamma_R30 := 2004bv64, true; + call FUN_650(); goto $main$__1__$gEm6HfTiSIW8xoT2LZrDVw; $main$__1__$gEm6HfTiSIW8xoT2LZrDVw: - call R31_3, Gamma_R31_3 := greet(bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in, 2012bv64, true, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in); + assume {:captureState "$main$__1__$gEm6HfTiSIW8xoT2LZrDVw"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + R30, Gamma_R30 := 2012bv64, true; + call greet(); goto $main$__2__$sk~gIF9_TnupcjAVM_n30w; $main$__2__$sk~gIF9_TnupcjAVM_n30w: - R29_3, Gamma_R29_3 := memory_load64_le(stack, R31_3), gamma_load64(Gamma_stack, R31_3); - R30_4, Gamma_R30_4 := memory_load64_le(stack, bvadd64(R31_3, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 8bv64)); + assume {:captureState "$main$__2__$sk~gIF9_TnupcjAVM_n30w"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R29_out, R30_out, R31_out := 0bv64, R16_1, R17_1, R29_3, R30_4, bvadd64(R31_3, 32bv64); - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R16_1, Gamma_R17_1, Gamma_R29_3, Gamma_R30_4, Gamma_R31_3; + assume {:captureState "main_basil_return"} true; return; } -procedure puts(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure puts(); free requires (memory_load64_le(mem, 2048bv64) == 131073bv64); free requires (memory_load64_le(mem, 2056bv64) == 8583909746840200520bv64); free requires (memory_load64_le(mem, 2064bv64) == 143418749551bv64); @@ -381,11 +279,11 @@ procedure puts(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, free requires (memory_load8_le(mem, 2097bv64) == 121bv8); free requires (memory_load8_le(mem, 2098bv64) == 58bv8); free requires (memory_load8_le(mem, 2099bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1972bv64); - free requires (memory_load64_le(mem, 69600bv64) == 1940bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); free requires (memory_load64_le(mem, 69000bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69600bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1972bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 2048bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2056bv64) == 8583909746840200520bv64); free ensures (memory_load64_le(mem, 2064bv64) == 143418749551bv64); @@ -396,9 +294,9 @@ procedure puts(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, free ensures (memory_load8_le(mem, 2097bv64) == 121bv8); free ensures (memory_load8_le(mem, 2098bv64) == 58bv8); free ensures (memory_load8_le(mem, 2099bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1972bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1972bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); diff --git a/src/test/correct/initialisation/clang/initialisation.expected b/src/test/correct/initialisation/clang/initialisation.expected index ef3fbd0b1..b6d670468 100644 --- a/src/test/correct/initialisation/clang/initialisation.expected +++ b/src/test/correct/initialisation/clang/initialisation.expected @@ -1,4 +1,22 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $a_addr: bv64; axiom ($a_addr == 69696bv64); @@ -8,26 +26,16 @@ const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvadd"} bvadd65(bv65, bv65) returns (bv65); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp64(bv64, bv64) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp65(bv65, bv65) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +49,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,27 +73,26 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_64(bv64) returns (bv65); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_64(bv64) returns (bv65); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -97,8 +100,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -111,17 +114,14 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R10, Gamma_R11, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R10, R11, R8, R9, VF, ZF, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); free requires (memory_load64_le(mem, 69680bv64) == 416611827717bv64); free requires (memory_load64_le(mem, 69688bv64) == 68719476735bv64); free requires (memory_load64_le(mem, 69696bv64) == 8589934593bv64); - free requires (memory_load8_le(mem, 1912bv64) == 1bv8); - free requires (memory_load8_le(mem, 1913bv64) == 0bv8); - free requires (memory_load8_le(mem, 1914bv64) == 2bv8); - free requires (memory_load8_le(mem, 1915bv64) == 0bv8); + free requires (memory_load32_le(mem, 1912bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -129,59 +129,61 @@ procedure main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: boo ensures (memory_load32_le(mem, $x_addr) == 6bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 4bv64)) == 4bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 0bv64)) == 1bv32); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_2: bool; - var Gamma_R10_3: bool; - var Gamma_R10_4: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R8_5: bool; - var Gamma_R8_6: bool; - var R10_2: bv32; - var R10_3: bv32; - var R10_4: bv64; - var R8_3: bv32; - var R8_4: bv32; - var R8_5: bv64; - var R8_6: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R9, Gamma_R9 := bvadd64(R9, 64bv64), Gamma_R9; + R11, Gamma_R11 := 69632bv64, true; call rely(); - R10_2, Gamma_R10_2 := memory_load32_le(mem, 69680bv64), (gamma_load32(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); - R10_3, Gamma_R10_3 := bvadd32(R10_2, 1bv32), Gamma_R10_2; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, bvadd64(R11, 48bv64))), (gamma_load32(Gamma_mem, bvadd64(R11, 48bv64)) || L(mem, bvadd64(R11, 48bv64))); + R10, Gamma_R10 := zero_extend32_32(bvadd32(R10[32:0], 1bv32)), Gamma_R10; call rely(); - assert (L(mem, 69680bv64) ==> Gamma_R10_3); - mem, Gamma_mem := memory_store32_le(mem, 69680bv64, R10_3), gamma_store32(Gamma_mem, 69680bv64, Gamma_R10_3); + assert (L(mem, bvadd64(R11, 48bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R11, 48bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R11, 48bv64), Gamma_R10); + assume {:captureState "%00000322"} true; + R11, Gamma_R11 := 69632bv64, true; call rely(); - R10_4, Gamma_R10_4 := memory_load64_le(mem, 69688bv64), (gamma_load64(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R10, Gamma_R10 := memory_load64_le(mem, bvadd64(R11, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R11, 56bv64)) || L(mem, bvadd64(R11, 56bv64))); + #4, Gamma_#4 := bvadd64(R10, 18446744073709551614bv64), Gamma_R10; + VF, Gamma_VF := bvnot1(bvcomp65(sign_extend1_64(bvadd64(#4, 1bv64)), bvadd65(sign_extend1_64(R10), 36893488147419103231bv65))), (Gamma_R10 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp65(zero_extend1_64(bvadd64(#4, 1bv64)), bvadd65(zero_extend1_64(R10), 18446744073709551615bv65))), (Gamma_R10 && Gamma_#4); + ZF, Gamma_ZF := bvcomp64(bvadd64(#4, 1bv64), 0bv64), Gamma_#4; + NF, Gamma_NF := bvadd64(#4, 1bv64)[64:63], Gamma_#4; + R10, Gamma_R10 := bvadd64(#4, 1bv64), Gamma_#4; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R10_4); - mem, Gamma_mem := memory_store64_le(mem, 69688bv64, bvadd64(R10_4, 18446744073709551615bv64)), gamma_store64(Gamma_mem, 69688bv64, Gamma_R10_4); + assert (L(mem, bvadd64(R11, 56bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R11, 56bv64), R10), gamma_store64(Gamma_mem, bvadd64(R11, 56bv64), Gamma_R10); + assume {:captureState "%00000352"} true; call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, 69696bv64), (gamma_load32(Gamma_mem, 69696bv64) || L(mem, 69696bv64)); - R8_4, Gamma_R8_4 := bvadd32(R8_3, 3bv32), Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 64bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 64bv64)) || L(mem, bvadd64(R8, 64bv64))); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 3bv32)), Gamma_R8; call rely(); - assert (L(mem, 69700bv64) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store32_le(mem, 69700bv64, R8_4), gamma_store32(Gamma_mem, 69700bv64, Gamma_R8_4); + assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); + assume {:captureState "%00000367"} true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - R8_5, Gamma_R8_5 := zero_extend56_8(memory_load8_le(mem, 69684bv64)), (gamma_load8(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - R8_6, Gamma_R8_6 := zero_extend32_32(bvadd32(R8_5[32:0], 1bv32)), Gamma_R8_5; + R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, bvadd64(R9, 52bv64))), (gamma_load8(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R8_6); - mem, Gamma_mem := memory_store8_le(mem, 69684bv64, R8_6[8:0]), gamma_store8(Gamma_mem, 69684bv64, Gamma_R8_6); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 52bv64), R8[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "%00000381"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R8_out, R9_out := 0bv64, bvadd64(R10_4, 18446744073709551615bv64), 69632bv64, R8_6, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_4, true, Gamma_R8_6, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/initialisation/clang/initialisation_gtirb.expected b/src/test/correct/initialisation/clang/initialisation_gtirb.expected index 26fc60505..d27251515 100644 --- a/src/test/correct/initialisation/clang/initialisation_gtirb.expected +++ b/src/test/correct/initialisation/clang/initialisation_gtirb.expected @@ -1,4 +1,22 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $a_addr: bv64; axiom ($a_addr == 69696bv64); @@ -8,26 +26,16 @@ const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvadd"} bvadd65(bv65, bv65) returns (bv65); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp64(bv64, bv64) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp65(bv65, bv65) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +49,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,27 +73,26 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_64(bv64) returns (bv65); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_64(bv64) returns (bv65); +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -97,8 +100,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -111,17 +114,14 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R10, Gamma_R11, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R10, R11, R8, R9, VF, ZF, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); free requires (memory_load64_le(mem, 69680bv64) == 416611827717bv64); free requires (memory_load64_le(mem, 69688bv64) == 68719476735bv64); free requires (memory_load64_le(mem, 69696bv64) == 8589934593bv64); - free requires (memory_load8_le(mem, 1912bv64) == 1bv8); - free requires (memory_load8_le(mem, 1913bv64) == 0bv8); - free requires (memory_load8_le(mem, 1914bv64) == 2bv8); - free requires (memory_load8_le(mem, 1915bv64) == 0bv8); + free requires (memory_load32_le(mem, 1912bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -129,59 +129,61 @@ procedure main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: boo ensures (memory_load32_le(mem, $x_addr) == 6bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 4bv64)) == 4bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 0bv64)) == 1bv32); - free ensures (memory_load8_le(mem, 1912bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1913bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1914bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1915bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1912bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_2: bool; - var Gamma_R10_3: bool; - var Gamma_R10_4: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R8_5: bool; - var Gamma_R8_6: bool; - var R10_2: bv32; - var R10_3: bv32; - var R10_4: bv64; - var R8_3: bv32; - var R8_4: bv32; - var R8_5: bv64; - var R8_6: bv64; + var Cse0__5$0$9: bv64; + var Gamma_Cse0__5$0$9: bool; $main$__0__$bXjOvzBIQmSVnOWXdNnWZA: + assume {:captureState "$main$__0__$bXjOvzBIQmSVnOWXdNnWZA"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R9, Gamma_R9 := bvadd64(R9, 64bv64), Gamma_R9; + R11, Gamma_R11 := 69632bv64, true; call rely(); - R10_2, Gamma_R10_2 := memory_load32_le(mem, 69680bv64), (gamma_load32(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); - R10_3, Gamma_R10_3 := bvadd32(R10_2, 1bv32), Gamma_R10_2; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, bvadd64(R11, 48bv64))), (gamma_load32(Gamma_mem, bvadd64(R11, 48bv64)) || L(mem, bvadd64(R11, 48bv64))); + R10, Gamma_R10 := zero_extend32_32(bvadd32(R10[32:0], 1bv32)), Gamma_R10; call rely(); - assert (L(mem, 69680bv64) ==> Gamma_R10_3); - mem, Gamma_mem := memory_store32_le(mem, 69680bv64, R10_3), gamma_store32(Gamma_mem, 69680bv64, Gamma_R10_3); + assert (L(mem, bvadd64(R11, 48bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R11, 48bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R11, 48bv64), Gamma_R10); + assume {:captureState "1836$0"} true; + R11, Gamma_R11 := 69632bv64, true; call rely(); - R10_4, Gamma_R10_4 := memory_load64_le(mem, 69688bv64), (gamma_load64(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R10, Gamma_R10 := memory_load64_le(mem, bvadd64(R11, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R11, 56bv64)) || L(mem, bvadd64(R11, 56bv64))); + Cse0__5$0$9, Gamma_Cse0__5$0$9 := bvadd64(R10, 18446744073709551615bv64), Gamma_R10; + VF, Gamma_VF := bvnot1(bvcomp65(sign_extend1_64(Cse0__5$0$9), bvadd65(sign_extend1_64(R10), 36893488147419103231bv65))), (Gamma_R10 && Gamma_Cse0__5$0$9); + CF, Gamma_CF := bvnot1(bvcomp65(zero_extend1_64(Cse0__5$0$9), bvadd65(zero_extend1_64(R10), 18446744073709551615bv65))), (Gamma_R10 && Gamma_Cse0__5$0$9); + ZF, Gamma_ZF := bvcomp64(Cse0__5$0$9, 0bv64), Gamma_Cse0__5$0$9; + NF, Gamma_NF := Cse0__5$0$9[64:63], Gamma_Cse0__5$0$9; + R10, Gamma_R10 := Cse0__5$0$9, Gamma_Cse0__5$0$9; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R10_4); - mem, Gamma_mem := memory_store64_le(mem, 69688bv64, bvadd64(R10_4, 18446744073709551615bv64)), gamma_store64(Gamma_mem, 69688bv64, Gamma_R10_4); + assert (L(mem, bvadd64(R11, 56bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R11, 56bv64), R10), gamma_store64(Gamma_mem, bvadd64(R11, 56bv64), Gamma_R10); + assume {:captureState "1852$0"} true; call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, 69696bv64), (gamma_load32(Gamma_mem, 69696bv64) || L(mem, 69696bv64)); - R8_4, Gamma_R8_4 := bvadd32(R8_3, 3bv32), Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 64bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 64bv64)) || L(mem, bvadd64(R8, 64bv64))); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 3bv32)), Gamma_R8; call rely(); - assert (L(mem, 69700bv64) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store32_le(mem, 69700bv64, R8_4), gamma_store32(Gamma_mem, 69700bv64, Gamma_R8_4); + assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); + assume {:captureState "1864$0"} true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - R8_5, Gamma_R8_5 := zero_extend56_8(memory_load8_le(mem, 69684bv64)), (gamma_load8(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - R8_6, Gamma_R8_6 := zero_extend32_32(bvadd32(R8_5[32:0], 1bv32)), Gamma_R8_5; + R8, Gamma_R8 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, bvadd64(R9, 52bv64)))), (gamma_load8(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R8_6); - mem, Gamma_mem := memory_store8_le(mem, 69684bv64, R8_6[8:0]), gamma_store8(Gamma_mem, 69684bv64, Gamma_R8_6); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 52bv64), R8[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "1880$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R8_out, R9_out := 0bv64, bvadd64(R10_4, 18446744073709551615bv64), 69632bv64, R8_6, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_4, true, Gamma_R8_6, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/initialisation/clang_O2/initialisation.expected b/src/test/correct/initialisation/clang_O2/initialisation.expected index aea68aa6e..3562cf315 100644 --- a/src/test/correct/initialisation/clang_O2/initialisation.expected +++ b/src/test/correct/initialisation/clang_O2/initialisation.expected @@ -1,4 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R12: bool; +var {:extern} Gamma_R13: bool; +var {:extern} Gamma_R14: bool; +var {:extern} Gamma_R15: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R12: bv64; +var {:extern} R13: bv64; +var {:extern} R14: bv64; +var {:extern} R15: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $a_addr: bv64; axiom ($a_addr == 69696bv64); @@ -8,26 +26,12 @@ const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +45,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,27 +69,24 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1908bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1909bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1910bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1911bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1908bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -97,8 +94,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -111,17 +108,14 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R11, Gamma_R12, Gamma_R13, Gamma_R14, Gamma_R15, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R11, R12, R13, R14, R15, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); free requires (memory_load64_le(mem, 69680bv64) == 416611827717bv64); free requires (memory_load64_le(mem, 69688bv64) == 68719476735bv64); free requires (memory_load64_le(mem, 69696bv64) == 8589934593bv64); - free requires (memory_load8_le(mem, 1908bv64) == 1bv8); - free requires (memory_load8_le(mem, 1909bv64) == 0bv8); - free requires (memory_load8_le(mem, 1910bv64) == 2bv8); - free requires (memory_load8_le(mem, 1911bv64) == 0bv8); + free requires (memory_load32_le(mem, 1908bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -129,59 +123,53 @@ procedure main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: boo ensures (memory_load32_le(mem, $x_addr) == 6bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 4bv64)) == 4bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 0bv64)) == 1bv32); - free ensures (memory_load8_le(mem, 1908bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1909bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1910bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1911bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1908bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_4: bool; - var Gamma_R11_2: bool; - var Gamma_R11_3: bool; - var Gamma_R13_2: bool; - var Gamma_R13_3: bool; - var Gamma_R14_2: bool; - var Gamma_R15_2: bool; - var R10_4: bv64; - var R11_2: bv32; - var R11_3: bv64; - var R13_2: bv32; - var R13_3: bv64; - var R14_2: bv64; - var R15_2: bv64; lmain: + assume {:captureState "lmain"} true; + R10, Gamma_R10 := 69632bv64, true; + R10, Gamma_R10 := bvadd64(R10, 64bv64), Gamma_R10; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R12, Gamma_R12 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - R11_2, Gamma_R11_2 := memory_load32_le(mem, 69696bv64), (gamma_load32(Gamma_mem, 69696bv64) || L(mem, 69696bv64)); + R11, Gamma_R11 := zero_extend32_32(memory_load32_le(mem, R10)), (gamma_load32(Gamma_mem, R10) || L(mem, R10)); call rely(); - R13_2, Gamma_R13_2 := memory_load32_le(mem, 69680bv64), (gamma_load32(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); + R13, Gamma_R13 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 48bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 48bv64)) || L(mem, bvadd64(R8, 48bv64))); call rely(); - R14_2, Gamma_R14_2 := memory_load64_le(mem, 69688bv64), (gamma_load64(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - R11_3, Gamma_R11_3 := zero_extend32_32(bvadd32(R11_2, 3bv32)), Gamma_R11_2; + R14, Gamma_R14 := memory_load64_le(mem, bvadd64(R9, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 56bv64)) || L(mem, bvadd64(R9, 56bv64))); + R11, Gamma_R11 := zero_extend32_32(bvadd32(R11[32:0], 3bv32)), Gamma_R11; call rely(); - R15_2, Gamma_R15_2 := zero_extend56_8(memory_load8_le(mem, 69684bv64)), (gamma_load8(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - R13_3, Gamma_R13_3 := zero_extend32_32(bvadd32(R13_2, 1bv32)), Gamma_R13_2; + R15, Gamma_R15 := zero_extend56_8(memory_load8_le(mem, bvadd64(R12, 52bv64))), (gamma_load8(Gamma_mem, bvadd64(R12, 52bv64)) || L(mem, bvadd64(R12, 52bv64))); + R13, Gamma_R13 := zero_extend32_32(bvadd32(R13[32:0], 1bv32)), Gamma_R13; + R14, Gamma_R14 := bvadd64(R14, 18446744073709551615bv64), Gamma_R14; call rely(); - assert (L(mem, 69700bv64) ==> Gamma_R11_3); - mem, Gamma_mem := memory_store32_le(mem, 69700bv64, R11_3[32:0]), gamma_store32(Gamma_mem, 69700bv64, Gamma_R11_3); - R10_4, Gamma_R10_4 := zero_extend32_32(bvadd32(R15_2[32:0], 1bv32)), Gamma_R15_2; + assert (L(mem, bvadd64(R10, 4bv64)) ==> Gamma_R11); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 4bv64), R11[32:0]), gamma_store32(Gamma_mem, bvadd64(R10, 4bv64), Gamma_R11); + assume {:captureState "%00000349"} true; + R10, Gamma_R10 := zero_extend32_32(bvadd32(R15[32:0], 1bv32)), Gamma_R15; call rely(); - assert (L(mem, 69680bv64) ==> Gamma_R13_3); - mem, Gamma_mem := memory_store32_le(mem, 69680bv64, R13_3[32:0]), gamma_store32(Gamma_mem, 69680bv64, Gamma_R13_3); + assert (L(mem, bvadd64(R8, 48bv64)) ==> Gamma_R13); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 48bv64), R13[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 48bv64), Gamma_R13); + assume {:captureState "%00000357"} true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R14_2); - mem, Gamma_mem := memory_store64_le(mem, 69688bv64, bvadd64(R14_2, 18446744073709551615bv64)), gamma_store64(Gamma_mem, 69688bv64, Gamma_R14_2); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R14); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 56bv64), R14), gamma_store64(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R14); + assume {:captureState "%0000035f"} true; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R10_4); - mem, Gamma_mem := memory_store8_le(mem, 69684bv64, R10_4[8:0]), gamma_store8(Gamma_mem, 69684bv64, Gamma_R10_4); + assert (L(mem, bvadd64(R12, 52bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R12, 52bv64), R10[8:0]), gamma_store8(Gamma_mem, bvadd64(R12, 52bv64), Gamma_R10); + assume {:captureState "%00000367"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R12_out, R13_out, R14_out, R15_out, R8_out, R9_out := 0bv64, R10_4, R11_3, 69632bv64, R13_3, bvadd64(R14_2, 18446744073709551615bv64), R15_2, 69632bv64, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R12_out, Gamma_R13_out, Gamma_R14_out, Gamma_R15_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_4, Gamma_R11_3, true, Gamma_R13_3, Gamma_R14_2, Gamma_R15_2, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/initialisation/clang_O2/initialisation_gtirb.expected b/src/test/correct/initialisation/clang_O2/initialisation_gtirb.expected index ab9f21f0c..3297b068d 100644 --- a/src/test/correct/initialisation/clang_O2/initialisation_gtirb.expected +++ b/src/test/correct/initialisation/clang_O2/initialisation_gtirb.expected @@ -1,4 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R12: bool; +var {:extern} Gamma_R13: bool; +var {:extern} Gamma_R14: bool; +var {:extern} Gamma_R15: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R12: bv64; +var {:extern} R13: bv64; +var {:extern} R14: bv64; +var {:extern} R15: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $a_addr: bv64; axiom ($a_addr == 69696bv64); @@ -8,26 +26,12 @@ const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +45,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,27 +69,24 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1908bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1909bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1910bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1911bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1908bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -97,8 +94,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -111,17 +108,14 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R11, Gamma_R12, Gamma_R13, Gamma_R14, Gamma_R15, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R11, R12, R13, R14, R15, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); free requires (memory_load64_le(mem, 69680bv64) == 416611827717bv64); free requires (memory_load64_le(mem, 69688bv64) == 68719476735bv64); free requires (memory_load64_le(mem, 69696bv64) == 8589934593bv64); - free requires (memory_load8_le(mem, 1908bv64) == 1bv8); - free requires (memory_load8_le(mem, 1909bv64) == 0bv8); - free requires (memory_load8_le(mem, 1910bv64) == 2bv8); - free requires (memory_load8_le(mem, 1911bv64) == 0bv8); + free requires (memory_load32_le(mem, 1908bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -129,59 +123,53 @@ procedure main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: boo ensures (memory_load32_le(mem, $x_addr) == 6bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 4bv64)) == 4bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 0bv64)) == 1bv32); - free ensures (memory_load8_le(mem, 1908bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1909bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1910bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1911bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1908bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_4: bool; - var Gamma_R11_2: bool; - var Gamma_R11_3: bool; - var Gamma_R13_2: bool; - var Gamma_R13_3: bool; - var Gamma_R14_2: bool; - var Gamma_R15_2: bool; - var R10_4: bv64; - var R11_2: bv32; - var R11_3: bv64; - var R13_2: bv32; - var R13_3: bv64; - var R14_2: bv64; - var R15_2: bv64; $main$__0__$f6fSZwrZSIKfQqhZ9R_A_Q: + assume {:captureState "$main$__0__$f6fSZwrZSIKfQqhZ9R_A_Q"} true; + R10, Gamma_R10 := 69632bv64, true; + R10, Gamma_R10 := bvadd64(R10, 64bv64), Gamma_R10; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R12, Gamma_R12 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - R11_2, Gamma_R11_2 := memory_load32_le(mem, 69696bv64), (gamma_load32(Gamma_mem, 69696bv64) || L(mem, 69696bv64)); + R11, Gamma_R11 := zero_extend32_32(memory_load32_le(mem, R10)), (gamma_load32(Gamma_mem, R10) || L(mem, R10)); call rely(); - R13_2, Gamma_R13_2 := memory_load32_le(mem, 69680bv64), (gamma_load32(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); + R13, Gamma_R13 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 48bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 48bv64)) || L(mem, bvadd64(R8, 48bv64))); call rely(); - R14_2, Gamma_R14_2 := memory_load64_le(mem, 69688bv64), (gamma_load64(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - R11_3, Gamma_R11_3 := zero_extend32_32(bvadd32(R11_2, 3bv32)), Gamma_R11_2; + R14, Gamma_R14 := memory_load64_le(mem, bvadd64(R9, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 56bv64)) || L(mem, bvadd64(R9, 56bv64))); + R11, Gamma_R11 := zero_extend32_32(bvadd32(R11[32:0], 3bv32)), Gamma_R11; call rely(); - R15_2, Gamma_R15_2 := zero_extend56_8(memory_load8_le(mem, 69684bv64)), (gamma_load8(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - R13_3, Gamma_R13_3 := zero_extend32_32(bvadd32(R13_2, 1bv32)), Gamma_R13_2; + R15, Gamma_R15 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, bvadd64(R12, 52bv64)))), (gamma_load8(Gamma_mem, bvadd64(R12, 52bv64)) || L(mem, bvadd64(R12, 52bv64))); + R13, Gamma_R13 := zero_extend32_32(bvadd32(R13[32:0], 1bv32)), Gamma_R13; + R14, Gamma_R14 := bvadd64(R14, 18446744073709551615bv64), Gamma_R14; call rely(); - assert (L(mem, 69700bv64) ==> Gamma_R11_3); - mem, Gamma_mem := memory_store32_le(mem, 69700bv64, R11_3[32:0]), gamma_store32(Gamma_mem, 69700bv64, Gamma_R11_3); - R10_4, Gamma_R10_4 := zero_extend32_32(bvadd32(R15_2[32:0], 1bv32)), Gamma_R15_2; + assert (L(mem, bvadd64(R10, 4bv64)) ==> Gamma_R11); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 4bv64), R11[32:0]), gamma_store32(Gamma_mem, bvadd64(R10, 4bv64), Gamma_R11); + assume {:captureState "1864$0"} true; + R10, Gamma_R10 := zero_extend32_32(bvadd32(R15[32:0], 1bv32)), Gamma_R15; call rely(); - assert (L(mem, 69680bv64) ==> Gamma_R13_3); - mem, Gamma_mem := memory_store32_le(mem, 69680bv64, R13_3[32:0]), gamma_store32(Gamma_mem, 69680bv64, Gamma_R13_3); + assert (L(mem, bvadd64(R8, 48bv64)) ==> Gamma_R13); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 48bv64), R13[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 48bv64), Gamma_R13); + assume {:captureState "1872$0"} true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R14_2); - mem, Gamma_mem := memory_store64_le(mem, 69688bv64, bvadd64(R14_2, 18446744073709551615bv64)), gamma_store64(Gamma_mem, 69688bv64, Gamma_R14_2); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R14); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 56bv64), R14), gamma_store64(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R14); + assume {:captureState "1876$0"} true; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R10_4); - mem, Gamma_mem := memory_store8_le(mem, 69684bv64, R10_4[8:0]), gamma_store8(Gamma_mem, 69684bv64, Gamma_R10_4); + assert (L(mem, bvadd64(R12, 52bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R12, 52bv64), R10[8:0]), gamma_store8(Gamma_mem, bvadd64(R12, 52bv64), Gamma_R10); + assume {:captureState "1880$0"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R12_out, R13_out, R14_out, R15_out, R8_out, R9_out := 0bv64, R10_4, R11_3, 69632bv64, R13_3, bvadd64(R14_2, 18446744073709551615bv64), R15_2, 69632bv64, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R12_out, Gamma_R13_out, Gamma_R14_out, Gamma_R15_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_4, Gamma_R11_3, true, Gamma_R13_3, Gamma_R14_2, Gamma_R15_2, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/initialisation/clang_pic/initialisation.expected b/src/test/correct/initialisation/clang_pic/initialisation.expected index 7f30bafff..d38e9a7ca 100644 --- a/src/test/correct/initialisation/clang_pic/initialisation.expected +++ b/src/test/correct/initialisation/clang_pic/initialisation.expected @@ -1,4 +1,20 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $a_addr: bv64; axiom ($a_addr == 69696bv64); @@ -8,26 +24,16 @@ const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvadd"} bvadd65(bv65, bv65) returns (bv65); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp64(bv64, bv64) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp65(bv65, bv65) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +47,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,40 +71,39 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_64(bv64) returns (bv65); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_64(bv64) returns (bv65); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2048bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2049bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2050bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2051bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2048bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69040bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69552bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69560bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69576bv64) == 69696bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69552bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69040bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); - free ensures (memory_load64_le(mem, 69560bv64) == 69680bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -115,101 +116,90 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R10, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R10, R8, R9, VF, ZF, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); free requires (memory_load64_le(mem, 69680bv64) == 416611827717bv64); free requires (memory_load64_le(mem, 69688bv64) == 68719476735bv64); free requires (memory_load64_le(mem, 69696bv64) == 8589934593bv64); - free requires (memory_load8_le(mem, 2048bv64) == 1bv8); - free requires (memory_load8_le(mem, 2049bv64) == 0bv8); - free requires (memory_load8_le(mem, 2050bv64) == 2bv8); - free requires (memory_load8_le(mem, 2051bv64) == 0bv8); + free requires (memory_load32_le(mem, 2048bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69032bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69040bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69552bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69560bv64) == 69680bv64); free requires (memory_load64_le(mem, 69576bv64) == 69696bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69552bv64) == 69688bv64); - free requires (memory_load64_le(mem, 69040bv64) == 1856bv64); free requires (memory_load64_le(mem, 69592bv64) == 1940bv64); - free requires (memory_load64_le(mem, 69032bv64) == 1936bv64); - free requires (memory_load64_le(mem, 69560bv64) == 69680bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (memory_load32_le(mem, $x_addr) == 6bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 4bv64)) == 4bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 0bv64)) == 1bv32); - free ensures (memory_load8_le(mem, 2048bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2049bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2050bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2051bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2048bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69040bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69552bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69560bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69576bv64) == 69696bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69552bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69040bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); - free ensures (memory_load64_le(mem, 69560bv64) == 69680bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_3: bool; - var Gamma_R10_5: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R8_6: bool; - var Gamma_R8_7: bool; - var Gamma_R8_8: bool; - var Gamma_R8_9: bool; - var Gamma_R9_3: bool; - var Gamma_R9_5: bool; - var R10_3: bv64; - var R10_5: bv64; - var R8_2: bv32; - var R8_3: bv32; - var R8_4: bv64; - var R8_6: bv32; - var R8_7: bv32; - var R8_8: bv64; - var R8_9: bv64; - var R9_3: bv64; - var R9_5: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); + R10, Gamma_R10 := 65536bv64, true; call rely(); - R10_3, Gamma_R10_3 := memory_load64_le(mem, 69560bv64), (gamma_load64(Gamma_mem, 69560bv64) || L(mem, 69560bv64)); + R10, Gamma_R10 := memory_load64_le(mem, bvadd64(R10, 4024bv64)), (gamma_load64(Gamma_mem, bvadd64(R10, 4024bv64)) || L(mem, bvadd64(R10, 4024bv64))); call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, R10_3), (gamma_load32(Gamma_mem, R10_3) || L(mem, R10_3)); - R8_3, Gamma_R8_3 := bvadd32(R8_2, 1bv32), Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R10)), (gamma_load32(Gamma_mem, R10) || L(mem, R10)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, R10_3) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, R10_3, R8_3), gamma_store32(Gamma_mem, R10_3, Gamma_R8_3); + assert (L(mem, R10) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R10, R8[32:0]), gamma_store32(Gamma_mem, R10, Gamma_R8); + assume {:captureState "%0000032d"} true; + R10, Gamma_R10 := 65536bv64, true; call rely(); - R10_5, Gamma_R10_5 := memory_load64_le(mem, 69552bv64), (gamma_load64(Gamma_mem, 69552bv64) || L(mem, 69552bv64)); + R10, Gamma_R10 := memory_load64_le(mem, bvadd64(R10, 4016bv64)), (gamma_load64(Gamma_mem, bvadd64(R10, 4016bv64)) || L(mem, bvadd64(R10, 4016bv64))); call rely(); - R8_4, Gamma_R8_4 := memory_load64_le(mem, R10_5), (gamma_load64(Gamma_mem, R10_5) || L(mem, R10_5)); + R8, Gamma_R8 := memory_load64_le(mem, R10), (gamma_load64(Gamma_mem, R10) || L(mem, R10)); + #4, Gamma_#4 := bvadd64(R8, 18446744073709551614bv64), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp65(sign_extend1_64(bvadd64(#4, 1bv64)), bvadd65(sign_extend1_64(R8), 36893488147419103231bv65))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp65(zero_extend1_64(bvadd64(#4, 1bv64)), bvadd65(zero_extend1_64(R8), 18446744073709551615bv65))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp64(bvadd64(#4, 1bv64), 0bv64), Gamma_#4; + NF, Gamma_NF := bvadd64(#4, 1bv64)[64:63], Gamma_#4; + R8, Gamma_R8 := bvadd64(#4, 1bv64), Gamma_#4; call rely(); - assert (L(mem, R10_5) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store64_le(mem, R10_5, bvadd64(R8_4, 18446744073709551615bv64)), gamma_store64(Gamma_mem, R10_5, Gamma_R8_4); + assert (L(mem, R10) ==> Gamma_R8); + mem, Gamma_mem := memory_store64_le(mem, R10, R8), gamma_store64(Gamma_mem, R10, Gamma_R8); + assume {:captureState "%00000364"} true; call rely(); - R8_6, Gamma_R8_6 := memory_load32_le(mem, R9_3), (gamma_load32(Gamma_mem, R9_3) || L(mem, R9_3)); - R8_7, Gamma_R8_7 := bvadd32(R8_6, 3bv32), Gamma_R8_6; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 3bv32)), Gamma_R8; call rely(); - assert (L(mem, bvadd64(R9_3, 4bv64)) ==> Gamma_R8_7); - mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9_3, 4bv64), R8_7), gamma_store32(Gamma_mem, bvadd64(R9_3, 4bv64), Gamma_R8_7); + assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); + assume {:captureState "%00000379"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_5, Gamma_R9_5 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4048bv64)) || L(mem, bvadd64(R9, 4048bv64))); call rely(); - R8_8, Gamma_R8_8 := zero_extend56_8(memory_load8_le(mem, R9_5)), (gamma_load8(Gamma_mem, R9_5) || L(mem, R9_5)); - R8_9, Gamma_R8_9 := zero_extend32_32(bvadd32(R8_8[32:0], 1bv32)), Gamma_R8_8; + R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, R9)), (gamma_load8(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, R9_5) ==> Gamma_R8_9); - mem, Gamma_mem := memory_store8_le(mem, R9_5, R8_9[8:0]), gamma_store8(Gamma_mem, R9_5, Gamma_R8_9); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%0000039a"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R8_out, R9_out := 0bv64, R10_5, R8_9, R9_5; - Gamma_R0_out, Gamma_R10_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_5, Gamma_R8_9, Gamma_R9_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/initialisation/clang_pic/initialisation_gtirb.expected b/src/test/correct/initialisation/clang_pic/initialisation_gtirb.expected index b78f48973..874733c01 100644 --- a/src/test/correct/initialisation/clang_pic/initialisation_gtirb.expected +++ b/src/test/correct/initialisation/clang_pic/initialisation_gtirb.expected @@ -1,4 +1,20 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $a_addr: bv64; axiom ($a_addr == 69696bv64); @@ -8,26 +24,16 @@ const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvadd"} bvadd65(bv65, bv65) returns (bv65); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp64(bv64, bv64) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp65(bv65, bv65) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +47,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,40 +71,39 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_64(bv64) returns (bv65); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_64(bv64) returns (bv65); +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2048bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2049bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2050bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2051bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2048bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69040bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69552bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69560bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69576bv64) == 69696bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69552bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69040bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); - free ensures (memory_load64_le(mem, 69560bv64) == 69680bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -115,101 +116,90 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R10, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R10, R8, R9, VF, ZF, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); free requires (memory_load64_le(mem, 69680bv64) == 416611827717bv64); free requires (memory_load64_le(mem, 69688bv64) == 68719476735bv64); free requires (memory_load64_le(mem, 69696bv64) == 8589934593bv64); - free requires (memory_load8_le(mem, 2048bv64) == 1bv8); - free requires (memory_load8_le(mem, 2049bv64) == 0bv8); - free requires (memory_load8_le(mem, 2050bv64) == 2bv8); - free requires (memory_load8_le(mem, 2051bv64) == 0bv8); + free requires (memory_load32_le(mem, 2048bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69032bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69040bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69552bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69560bv64) == 69680bv64); free requires (memory_load64_le(mem, 69576bv64) == 69696bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69552bv64) == 69688bv64); - free requires (memory_load64_le(mem, 69040bv64) == 1856bv64); free requires (memory_load64_le(mem, 69592bv64) == 1940bv64); - free requires (memory_load64_le(mem, 69032bv64) == 1936bv64); - free requires (memory_load64_le(mem, 69560bv64) == 69680bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (memory_load32_le(mem, $x_addr) == 6bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 4bv64)) == 4bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 0bv64)) == 1bv32); - free ensures (memory_load8_le(mem, 2048bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2049bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2050bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2051bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2048bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69040bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69552bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69560bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69576bv64) == 69696bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69552bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69040bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1940bv64); - free ensures (memory_load64_le(mem, 69032bv64) == 1936bv64); - free ensures (memory_load64_le(mem, 69560bv64) == 69680bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_3: bool; - var Gamma_R10_5: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R8_6: bool; - var Gamma_R8_7: bool; - var Gamma_R8_8: bool; - var Gamma_R8_9: bool; - var Gamma_R9_3: bool; - var Gamma_R9_5: bool; - var R10_3: bv64; - var R10_5: bv64; - var R8_2: bv32; - var R8_3: bv32; - var R8_4: bv64; - var R8_6: bv32; - var R8_7: bv32; - var R8_8: bv64; - var R8_9: bv64; - var R9_3: bv64; - var R9_5: bv64; + var Cse0__5$0$10: bv64; + var Gamma_Cse0__5$0$10: bool; $main$__0__$qUctHEkFTbC0bXMW251ihQ: + assume {:captureState "$main$__0__$qUctHEkFTbC0bXMW251ihQ"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); + R10, Gamma_R10 := 65536bv64, true; call rely(); - R10_3, Gamma_R10_3 := memory_load64_le(mem, 69560bv64), (gamma_load64(Gamma_mem, 69560bv64) || L(mem, 69560bv64)); + R10, Gamma_R10 := memory_load64_le(mem, bvadd64(R10, 4024bv64)), (gamma_load64(Gamma_mem, bvadd64(R10, 4024bv64)) || L(mem, bvadd64(R10, 4024bv64))); call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, R10_3), (gamma_load32(Gamma_mem, R10_3) || L(mem, R10_3)); - R8_3, Gamma_R8_3 := bvadd32(R8_2, 1bv32), Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R10)), (gamma_load32(Gamma_mem, R10) || L(mem, R10)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, R10_3) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, R10_3, R8_3), gamma_store32(Gamma_mem, R10_3, Gamma_R8_3); + assert (L(mem, R10) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R10, R8[32:0]), gamma_store32(Gamma_mem, R10, Gamma_R8); + assume {:captureState "1964$0"} true; + R10, Gamma_R10 := 65536bv64, true; call rely(); - R10_5, Gamma_R10_5 := memory_load64_le(mem, 69552bv64), (gamma_load64(Gamma_mem, 69552bv64) || L(mem, 69552bv64)); + R10, Gamma_R10 := memory_load64_le(mem, bvadd64(R10, 4016bv64)), (gamma_load64(Gamma_mem, bvadd64(R10, 4016bv64)) || L(mem, bvadd64(R10, 4016bv64))); call rely(); - R8_4, Gamma_R8_4 := memory_load64_le(mem, R10_5), (gamma_load64(Gamma_mem, R10_5) || L(mem, R10_5)); + R8, Gamma_R8 := memory_load64_le(mem, R10), (gamma_load64(Gamma_mem, R10) || L(mem, R10)); + Cse0__5$0$10, Gamma_Cse0__5$0$10 := bvadd64(R8, 18446744073709551615bv64), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp65(sign_extend1_64(Cse0__5$0$10), bvadd65(sign_extend1_64(R8), 36893488147419103231bv65))), (Gamma_R8 && Gamma_Cse0__5$0$10); + CF, Gamma_CF := bvnot1(bvcomp65(zero_extend1_64(Cse0__5$0$10), bvadd65(zero_extend1_64(R8), 18446744073709551615bv65))), (Gamma_R8 && Gamma_Cse0__5$0$10); + ZF, Gamma_ZF := bvcomp64(Cse0__5$0$10, 0bv64), Gamma_Cse0__5$0$10; + NF, Gamma_NF := Cse0__5$0$10[64:63], Gamma_Cse0__5$0$10; + R8, Gamma_R8 := Cse0__5$0$10, Gamma_Cse0__5$0$10; call rely(); - assert (L(mem, R10_5) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store64_le(mem, R10_5, bvadd64(R8_4, 18446744073709551615bv64)), gamma_store64(Gamma_mem, R10_5, Gamma_R8_4); + assert (L(mem, R10) ==> Gamma_R8); + mem, Gamma_mem := memory_store64_le(mem, R10, R8), gamma_store64(Gamma_mem, R10, Gamma_R8); + assume {:captureState "1984$0"} true; call rely(); - R8_6, Gamma_R8_6 := memory_load32_le(mem, R9_3), (gamma_load32(Gamma_mem, R9_3) || L(mem, R9_3)); - R8_7, Gamma_R8_7 := bvadd32(R8_6, 3bv32), Gamma_R8_6; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 3bv32)), Gamma_R8; call rely(); - assert (L(mem, bvadd64(R9_3, 4bv64)) ==> Gamma_R8_7); - mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9_3, 4bv64), R8_7), gamma_store32(Gamma_mem, bvadd64(R9_3, 4bv64), Gamma_R8_7); + assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); + assume {:captureState "1996$0"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_5, Gamma_R9_5 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4048bv64)) || L(mem, bvadd64(R9, 4048bv64))); call rely(); - R8_8, Gamma_R8_8 := zero_extend56_8(memory_load8_le(mem, R9_5)), (gamma_load8(Gamma_mem, R9_5) || L(mem, R9_5)); - R8_9, Gamma_R8_9 := zero_extend32_32(bvadd32(R8_8[32:0], 1bv32)), Gamma_R8_8; + R8, Gamma_R8 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R9))), (gamma_load8(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, R9_5) ==> Gamma_R8_9); - mem, Gamma_mem := memory_store8_le(mem, R9_5, R8_9[8:0]), gamma_store8(Gamma_mem, R9_5, Gamma_R8_9); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "2016$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R8_out, R9_out := 0bv64, R10_5, R8_9, R9_5; - Gamma_R0_out, Gamma_R10_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_5, Gamma_R8_9, Gamma_R9_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/initialisation/gcc/initialisation.expected b/src/test/correct/initialisation/gcc/initialisation.expected index efdaca08d..c1e20ad01 100644 --- a/src/test/correct/initialisation/gcc/initialisation.expected +++ b/src/test/correct/initialisation/gcc/initialisation.expected @@ -1,4 +1,8 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $a_addr: bv64; axiom ($a_addr == 69664bv64); @@ -8,26 +12,12 @@ const {:extern} $y_addr: bv64; axiom ($y_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +31,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,27 +55,24 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -97,8 +80,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -111,17 +94,14 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69648bv64) == 416611827717bv64); free requires (memory_load64_le(mem, 69656bv64) == 68719476735bv64); free requires (memory_load64_le(mem, 69664bv64) == 8589934593bv64); - free requires (memory_load8_le(mem, 1956bv64) == 1bv8); - free requires (memory_load8_le(mem, 1957bv64) == 0bv8); - free requires (memory_load8_le(mem, 1958bv64) == 2bv8); - free requires (memory_load8_le(mem, 1959bv64) == 0bv8); + free requires (memory_load32_le(mem, 1956bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -129,62 +109,65 @@ procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) r ensures (memory_load32_le(mem, $x_addr) == 6bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 4bv64)) == 4bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 0bv64)) == 1bv32); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_14: bool; - var Gamma_R0_19: bool; - var Gamma_R0_20: bool; - var Gamma_R0_4: bool; - var Gamma_R0_9: bool; - var Gamma_R1_2: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var R0_14: bv32; - var R0_19: bv64; - var R0_20: bv64; - var R0_4: bv32; - var R0_9: bv64; - var R1_2: bv32; - var R1_4: bv32; - var R1_5: bv64; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, 69648bv64), (gamma_load32(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - R1_2, Gamma_R1_2 := bvadd32(R0_4, 1bv32), Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); - assert (L(mem, 69648bv64) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, 69648bv64, R1_2), gamma_store32(Gamma_mem, 69648bv64, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000034f"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_9, Gamma_R0_9 := memory_load64_le(mem, 69656bv64), (gamma_load64(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := bvadd64(R0, 18446744073709551615bv64), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R0_9); - mem, Gamma_mem := memory_store64_le(mem, 69656bv64, bvadd64(R0_9, 18446744073709551615bv64)), gamma_store64(Gamma_mem, 69656bv64, Gamma_R0_9); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000037a"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); - R0_14, Gamma_R0_14 := memory_load32_le(mem, 69664bv64), (gamma_load32(Gamma_mem, 69664bv64) || L(mem, 69664bv64)); - R1_4, Gamma_R1_4 := bvadd32(R0_14, 3bv32), Gamma_R0_14; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 3bv32)), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); - assert (L(mem, 69668bv64) ==> Gamma_R1_4); - mem, Gamma_mem := memory_store32_le(mem, 69668bv64, R1_4), gamma_store32(Gamma_mem, 69668bv64, Gamma_R1_4); + assert (L(mem, bvadd64(R0, 4bv64)) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); + assume {:captureState "%000003a5"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_19, Gamma_R0_19 := zero_extend56_8(memory_load8_le(mem, 69652bv64)), (gamma_load8(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - R0_20, Gamma_R0_20 := zero_extend32_32(bvadd32(R0_19[32:0], 1bv32)), Gamma_R0_19; - R1_5, Gamma_R1_5 := zero_extend56_8(R0_20[8:0]), Gamma_R0_20; + R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32((0bv24 ++ R0[8:0])), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_5); - mem, Gamma_mem := memory_store8_le(mem, 69652bv64, R1_5[8:0]), gamma_store8(Gamma_mem, 69652bv64, Gamma_R1_5); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003d6"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_5; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/initialisation/gcc/initialisation_gtirb.expected b/src/test/correct/initialisation/gcc/initialisation_gtirb.expected index 24db0eb0d..d23427f1b 100644 --- a/src/test/correct/initialisation/gcc/initialisation_gtirb.expected +++ b/src/test/correct/initialisation/gcc/initialisation_gtirb.expected @@ -1,4 +1,8 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $a_addr: bv64; axiom ($a_addr == 69664bv64); @@ -8,26 +12,12 @@ const {:extern} $y_addr: bv64; axiom ($y_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +31,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,27 +55,24 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -97,8 +80,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -111,17 +94,14 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69648bv64) == 416611827717bv64); free requires (memory_load64_le(mem, 69656bv64) == 68719476735bv64); free requires (memory_load64_le(mem, 69664bv64) == 8589934593bv64); - free requires (memory_load8_le(mem, 1956bv64) == 1bv8); - free requires (memory_load8_le(mem, 1957bv64) == 0bv8); - free requires (memory_load8_le(mem, 1958bv64) == 2bv8); - free requires (memory_load8_le(mem, 1959bv64) == 0bv8); + free requires (memory_load32_le(mem, 1956bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -129,62 +109,65 @@ procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) r ensures (memory_load32_le(mem, $x_addr) == 6bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 4bv64)) == 4bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 0bv64)) == 1bv32); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_14: bool; - var Gamma_R0_19: bool; - var Gamma_R0_20: bool; - var Gamma_R0_4: bool; - var Gamma_R0_9: bool; - var Gamma_R1_2: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var R0_14: bv32; - var R0_19: bv64; - var R0_20: bv64; - var R0_4: bv32; - var R0_9: bv64; - var R1_2: bv32; - var R1_4: bv32; - var R1_5: bv64; $main$__0__$ulEp46faSbyYIP08N0ny3w: + assume {:captureState "$main$__0__$ulEp46faSbyYIP08N0ny3w"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, 69648bv64), (gamma_load32(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - R1_2, Gamma_R1_2 := bvadd32(R0_4, 1bv32), Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); - assert (L(mem, 69648bv64) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, 69648bv64, R1_2), gamma_store32(Gamma_mem, 69648bv64, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1836$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_9, Gamma_R0_9 := memory_load64_le(mem, 69656bv64), (gamma_load64(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := bvadd64(R0, 18446744073709551615bv64), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R0_9); - mem, Gamma_mem := memory_store64_le(mem, 69656bv64, bvadd64(R0_9, 18446744073709551615bv64)), gamma_store64(Gamma_mem, 69656bv64, Gamma_R0_9); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1864$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); - R0_14, Gamma_R0_14 := memory_load32_le(mem, 69664bv64), (gamma_load32(Gamma_mem, 69664bv64) || L(mem, 69664bv64)); - R1_4, Gamma_R1_4 := bvadd32(R0_14, 3bv32), Gamma_R0_14; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 3bv32)), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); - assert (L(mem, 69668bv64) ==> Gamma_R1_4); - mem, Gamma_mem := memory_store32_le(mem, 69668bv64, R1_4), gamma_store32(Gamma_mem, 69668bv64, Gamma_R1_4); + assert (L(mem, bvadd64(R0, 4bv64)) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); + assume {:captureState "1892$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_19, Gamma_R0_19 := zero_extend56_8(memory_load8_le(mem, 69652bv64)), (gamma_load8(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - R0_20, Gamma_R0_20 := zero_extend32_32(bvadd32(R0_19[32:0], 1bv32)), Gamma_R0_19; - R1_5, Gamma_R1_5 := zero_extend56_8(R0_20[8:0]), Gamma_R0_20; + R0, Gamma_R0 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R0))), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32((0bv24 ++ R0[8:0])), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_5); - mem, Gamma_mem := memory_store8_le(mem, 69652bv64, R1_5[8:0]), gamma_store8(Gamma_mem, 69652bv64, Gamma_R1_5); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1924$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_5; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/initialisation/gcc_O2/initialisation.expected b/src/test/correct/initialisation/gcc_O2/initialisation.expected index ae8ed1e52..c9f0e32be 100644 --- a/src/test/correct/initialisation/gcc_O2/initialisation.expected +++ b/src/test/correct/initialisation/gcc_O2/initialisation.expected @@ -1,4 +1,18 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_R4: bool; +var {:extern} Gamma_R5: bool; +var {:extern} Gamma_R6: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; +var {:extern} R4: bv64; +var {:extern} R5: bv64; +var {:extern} R6: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $a_addr: bv64; axiom ($a_addr == 69664bv64); @@ -8,26 +22,12 @@ const {:extern} $y_addr: bv64; axiom ($y_addr == 69672bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +41,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,27 +65,24 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -97,8 +90,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -111,18 +104,15 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_R3, Gamma_R4, Gamma_R5, Gamma_R6, Gamma_mem, R0, R1, R2, R3, R4, R5, R6, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69648bv64) == 5bv64); free requires (memory_load64_le(mem, 69656bv64) == 68719476735bv64); free requires (memory_load64_le(mem, 69664bv64) == 8589934593bv64); free requires (memory_load8_le(mem, 69672bv64) == 97bv8); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -130,59 +120,50 @@ procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R ensures (memory_load32_le(mem, $x_addr) == 6bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 4bv64)) == 4bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 0bv64)) == 1bv32); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool) +implementation main() { - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var Gamma_R3_2: bool; - var Gamma_R3_3: bool; - var Gamma_R4_2: bool; - var Gamma_R6_2: bool; - var Gamma_R6_3: bool; - var R2_2: bv64; - var R2_3: bv64; - var R3_2: bv32; - var R3_3: bv64; - var R4_2: bv64; - var R6_2: bv32; - var R6_3: bv64; lmain: + assume {:captureState "lmain"} true; + R5, Gamma_R5 := 69632bv64, true; + R1, Gamma_R1 := bvadd64(R5, 16bv64), Gamma_R5; + R0, Gamma_R0 := 0bv64, true; call rely(); - R6_2, Gamma_R6_2 := memory_load32_le(mem, 69648bv64), (gamma_load32(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); + R6, Gamma_R6 := zero_extend32_32(memory_load32_le(mem, bvadd64(R5, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R5, 16bv64)) || L(mem, bvadd64(R5, 16bv64))); call rely(); - R4_2, Gamma_R4_2 := memory_load64_le(mem, 69656bv64), (gamma_load64(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - R6_3, Gamma_R6_3 := zero_extend32_32(bvadd32(R6_2, 1bv32)), Gamma_R6_2; + R4, Gamma_R4 := memory_load64_le(mem, bvadd64(R1, 8bv64)), (gamma_load64(Gamma_mem, bvadd64(R1, 8bv64)) || L(mem, bvadd64(R1, 8bv64))); + R6, Gamma_R6 := zero_extend32_32(bvadd32(R6[32:0], 1bv32)), Gamma_R6; call rely(); - R2_2, Gamma_R2_2 := zero_extend56_8(memory_load8_le(mem, 69672bv64)), (gamma_load8(Gamma_mem, 69672bv64) || L(mem, 69672bv64)); + R2, Gamma_R2 := zero_extend56_8(memory_load8_le(mem, bvadd64(R1, 24bv64))), (gamma_load8(Gamma_mem, bvadd64(R1, 24bv64)) || L(mem, bvadd64(R1, 24bv64))); call rely(); - R3_2, Gamma_R3_2 := memory_load32_le(mem, 69664bv64), (gamma_load32(Gamma_mem, 69664bv64) || L(mem, 69664bv64)); - R2_3, Gamma_R2_3 := zero_extend32_32(bvadd32(R2_2[32:0], 1bv32)), Gamma_R2_2; + R3, Gamma_R3 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); + R4, Gamma_R4 := bvadd64(R4, 18446744073709551615bv64), Gamma_R4; + R2, Gamma_R2 := zero_extend32_32(bvadd32(R2[32:0], 1bv32)), Gamma_R2; call rely(); - assert (L(mem, 69648bv64) ==> Gamma_R6_3); - mem, Gamma_mem := memory_store32_le(mem, 69648bv64, R6_3[32:0]), gamma_store32(Gamma_mem, 69648bv64, Gamma_R6_3); - R3_3, Gamma_R3_3 := zero_extend32_32(bvadd32(R3_2, 3bv32)), Gamma_R3_2; + assert (L(mem, bvadd64(R5, 16bv64)) ==> Gamma_R6); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R5, 16bv64), R6[32:0]), gamma_store32(Gamma_mem, bvadd64(R5, 16bv64), Gamma_R6); + assume {:captureState "%000001ec"} true; + R3, Gamma_R3 := zero_extend32_32(bvadd32(R3[32:0], 3bv32)), Gamma_R3; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R4_2); - mem, Gamma_mem := memory_store64_le(mem, 69656bv64, bvadd64(R4_2, 18446744073709551615bv64)), gamma_store64(Gamma_mem, 69656bv64, Gamma_R4_2); + assert (L(mem, bvadd64(R1, 8bv64)) ==> Gamma_R4); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R1, 8bv64), R4), gamma_store64(Gamma_mem, bvadd64(R1, 8bv64), Gamma_R4); + assume {:captureState "%000001fa"} true; call rely(); - assert (L(mem, 69668bv64) ==> Gamma_R3_3); - mem, Gamma_mem := memory_store32_le(mem, 69668bv64, R3_3[32:0]), gamma_store32(Gamma_mem, 69668bv64, Gamma_R3_3); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R3); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R3); + assume {:captureState "%00000202"} true; call rely(); - assert (L(mem, 69672bv64) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store8_le(mem, 69672bv64, R2_3[8:0]), gamma_store8(Gamma_mem, 69672bv64, Gamma_R2_3); + assert (L(mem, bvadd64(R1, 24bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R1, 24bv64), R2[8:0]), gamma_store8(Gamma_mem, bvadd64(R1, 24bv64), Gamma_R2); + assume {:captureState "%0000020a"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out, R3_out, R4_out, R5_out, R6_out := 0bv64, 69648bv64, R2_3, R3_3, bvadd64(R4_2, 18446744073709551615bv64), 69632bv64, R6_3; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out, Gamma_R3_out, Gamma_R4_out, Gamma_R5_out, Gamma_R6_out := true, true, Gamma_R2_3, Gamma_R3_3, Gamma_R4_2, true, Gamma_R6_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/initialisation/gcc_O2/initialisation_gtirb.expected b/src/test/correct/initialisation/gcc_O2/initialisation_gtirb.expected index cabf0da86..aed04a776 100644 --- a/src/test/correct/initialisation/gcc_O2/initialisation_gtirb.expected +++ b/src/test/correct/initialisation/gcc_O2/initialisation_gtirb.expected @@ -1,4 +1,18 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_R4: bool; +var {:extern} Gamma_R5: bool; +var {:extern} Gamma_R6: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; +var {:extern} R4: bv64; +var {:extern} R5: bv64; +var {:extern} R6: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $a_addr: bv64; axiom ($a_addr == 69664bv64); @@ -8,26 +22,12 @@ const {:extern} $y_addr: bv64; axiom ($y_addr == 69672bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +41,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,27 +65,24 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -97,8 +90,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -111,18 +104,15 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_R3, Gamma_R4, Gamma_R5, Gamma_R6, Gamma_mem, R0, R1, R2, R3, R4, R5, R6, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69648bv64) == 5bv64); free requires (memory_load64_le(mem, 69656bv64) == 68719476735bv64); free requires (memory_load64_le(mem, 69664bv64) == 8589934593bv64); free requires (memory_load8_le(mem, 69672bv64) == 97bv8); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -130,59 +120,50 @@ procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R ensures (memory_load32_le(mem, $x_addr) == 6bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 4bv64)) == 4bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 0bv64)) == 1bv32); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool) +implementation main() { - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var Gamma_R3_2: bool; - var Gamma_R3_3: bool; - var Gamma_R4_2: bool; - var Gamma_R6_2: bool; - var Gamma_R6_3: bool; - var R2_2: bv64; - var R2_3: bv64; - var R3_2: bv32; - var R3_3: bv64; - var R4_2: bv64; - var R6_2: bv32; - var R6_3: bv64; $main$__0__$VgTx1GD5RKmGejJw1DpySQ: + assume {:captureState "$main$__0__$VgTx1GD5RKmGejJw1DpySQ"} true; + R5, Gamma_R5 := 69632bv64, true; + R1, Gamma_R1 := bvadd64(R5, 16bv64), Gamma_R5; + R0, Gamma_R0 := 0bv64, true; call rely(); - R6_2, Gamma_R6_2 := memory_load32_le(mem, 69648bv64), (gamma_load32(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); + R6, Gamma_R6 := zero_extend32_32(memory_load32_le(mem, bvadd64(R5, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R5, 16bv64)) || L(mem, bvadd64(R5, 16bv64))); call rely(); - R4_2, Gamma_R4_2 := memory_load64_le(mem, 69656bv64), (gamma_load64(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - R6_3, Gamma_R6_3 := zero_extend32_32(bvadd32(R6_2, 1bv32)), Gamma_R6_2; + R4, Gamma_R4 := memory_load64_le(mem, bvadd64(R1, 8bv64)), (gamma_load64(Gamma_mem, bvadd64(R1, 8bv64)) || L(mem, bvadd64(R1, 8bv64))); + R6, Gamma_R6 := zero_extend32_32(bvadd32(R6[32:0], 1bv32)), Gamma_R6; call rely(); - R2_2, Gamma_R2_2 := zero_extend56_8(memory_load8_le(mem, 69672bv64)), (gamma_load8(Gamma_mem, 69672bv64) || L(mem, 69672bv64)); + R2, Gamma_R2 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, bvadd64(R1, 24bv64)))), (gamma_load8(Gamma_mem, bvadd64(R1, 24bv64)) || L(mem, bvadd64(R1, 24bv64))); call rely(); - R3_2, Gamma_R3_2 := memory_load32_le(mem, 69664bv64), (gamma_load32(Gamma_mem, 69664bv64) || L(mem, 69664bv64)); - R2_3, Gamma_R2_3 := zero_extend32_32(bvadd32(R2_2[32:0], 1bv32)), Gamma_R2_2; + R3, Gamma_R3 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); + R4, Gamma_R4 := bvadd64(R4, 18446744073709551615bv64), Gamma_R4; + R2, Gamma_R2 := zero_extend32_32(bvadd32(R2[32:0], 1bv32)), Gamma_R2; call rely(); - assert (L(mem, 69648bv64) ==> Gamma_R6_3); - mem, Gamma_mem := memory_store32_le(mem, 69648bv64, R6_3[32:0]), gamma_store32(Gamma_mem, 69648bv64, Gamma_R6_3); - R3_3, Gamma_R3_3 := zero_extend32_32(bvadd32(R3_2, 3bv32)), Gamma_R3_2; + assert (L(mem, bvadd64(R5, 16bv64)) ==> Gamma_R6); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R5, 16bv64), R6[32:0]), gamma_store32(Gamma_mem, bvadd64(R5, 16bv64), Gamma_R6); + assume {:captureState "1576$0"} true; + R3, Gamma_R3 := zero_extend32_32(bvadd32(R3[32:0], 3bv32)), Gamma_R3; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R4_2); - mem, Gamma_mem := memory_store64_le(mem, 69656bv64, bvadd64(R4_2, 18446744073709551615bv64)), gamma_store64(Gamma_mem, 69656bv64, Gamma_R4_2); + assert (L(mem, bvadd64(R1, 8bv64)) ==> Gamma_R4); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R1, 8bv64), R4), gamma_store64(Gamma_mem, bvadd64(R1, 8bv64), Gamma_R4); + assume {:captureState "1584$0"} true; call rely(); - assert (L(mem, 69668bv64) ==> Gamma_R3_3); - mem, Gamma_mem := memory_store32_le(mem, 69668bv64, R3_3[32:0]), gamma_store32(Gamma_mem, 69668bv64, Gamma_R3_3); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R3); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R3); + assume {:captureState "1588$0"} true; call rely(); - assert (L(mem, 69672bv64) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store8_le(mem, 69672bv64, R2_3[8:0]), gamma_store8(Gamma_mem, 69672bv64, Gamma_R2_3); + assert (L(mem, bvadd64(R1, 24bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R1, 24bv64), R2[8:0]), gamma_store8(Gamma_mem, bvadd64(R1, 24bv64), Gamma_R2); + assume {:captureState "1592$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out, R3_out, R4_out, R5_out, R6_out := 0bv64, 69648bv64, R2_3, R3_3, bvadd64(R4_2, 18446744073709551615bv64), 69632bv64, R6_3; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out, Gamma_R3_out, Gamma_R4_out, Gamma_R5_out, Gamma_R6_out := true, true, Gamma_R2_3, Gamma_R3_3, Gamma_R4_2, true, Gamma_R6_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/initialisation/gcc_pic/initialisation.expected b/src/test/correct/initialisation/gcc_pic/initialisation.expected index b06b98436..5a5a277e7 100644 --- a/src/test/correct/initialisation/gcc_pic/initialisation.expected +++ b/src/test/correct/initialisation/gcc_pic/initialisation.expected @@ -1,4 +1,8 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $a_addr: bv64; axiom ($a_addr == 69664bv64); @@ -8,26 +12,12 @@ const {:extern} $y_addr: bv64; axiom ($y_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +31,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,40 +55,37 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2084bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2085bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2086bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2087bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69652bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2084bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 68984bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69576bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69648bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69664bv64); - free ensures (memory_load64_le(mem, 68984bv64) == 1936bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -115,120 +98,96 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69648bv64) == 416611827717bv64); free requires (memory_load64_le(mem, 69656bv64) == 68719476735bv64); free requires (memory_load64_le(mem, 69664bv64) == 8589934593bv64); - free requires (memory_load8_le(mem, 2084bv64) == 1bv8); - free requires (memory_load8_le(mem, 2085bv64) == 0bv8); - free requires (memory_load8_le(mem, 2086bv64) == 2bv8); - free requires (memory_load8_le(mem, 2087bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69652bv64); + free requires (memory_load32_le(mem, 2084bv64) == 131073bv32); + free requires (memory_load64_le(mem, 68984bv64) == 1936bv64); + free requires (memory_load64_le(mem, 68992bv64) == 1856bv64); free requires (memory_load64_le(mem, 69576bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1940bv64); free requires (memory_load64_le(mem, 69584bv64) == 69648bv64); free requires (memory_load64_le(mem, 69600bv64) == 69664bv64); - free requires (memory_load64_le(mem, 68984bv64) == 1936bv64); - free requires (memory_load64_le(mem, 68992bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $x_addr) == 6bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 4bv64)) == 4bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 0bv64)) == 1bv32); - free ensures (memory_load8_le(mem, 2084bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2085bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2086bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2087bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 2084bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 68984bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69576bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69648bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69664bv64); - free ensures (memory_load64_le(mem, 68984bv64) == 1936bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_11: bool; - var Gamma_R0_13: bool; - var Gamma_R0_14: bool; - var Gamma_R0_16: bool; - var Gamma_R0_18: bool; - var Gamma_R0_19: bool; - var Gamma_R0_20: bool; - var Gamma_R0_22: bool; - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_6: bool; - var Gamma_R0_8: bool; - var Gamma_R0_9: bool; - var Gamma_R1_2: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var R0_11: bv64; - var R0_13: bv64; - var R0_14: bv32; - var R0_16: bv64; - var R0_18: bv64; - var R0_19: bv64; - var R0_20: bv64; - var R0_22: bv64; - var R0_3: bv64; - var R0_4: bv32; - var R0_6: bv64; - var R0_8: bv64; - var R0_9: bv64; - var R1_2: bv32; - var R1_4: bv32; - var R1_5: bv64; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, R0_3), (gamma_load32(Gamma_mem, R0_3) || L(mem, R0_3)); - R1_2, Gamma_R1_2 := bvadd32(R0_4, 1bv32), Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_6, Gamma_R0_6 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - assert (L(mem, R0_6) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, R0_6, R1_2), gamma_store32(Gamma_mem, R0_6, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000351"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_8, Gamma_R0_8 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4040bv64)) || L(mem, bvadd64(R0, 4040bv64))); call rely(); - R0_9, Gamma_R0_9 := memory_load64_le(mem, R0_8), (gamma_load64(Gamma_mem, R0_8) || L(mem, R0_8)); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := bvadd64(R0, 18446744073709551615bv64), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_11, Gamma_R0_11 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4040bv64)) || L(mem, bvadd64(R0, 4040bv64))); call rely(); - assert (L(mem, R0_11) ==> Gamma_R0_9); - mem, Gamma_mem := memory_store64_le(mem, R0_11, bvadd64(R0_9, 18446744073709551615bv64)), gamma_store64(Gamma_mem, R0_11, Gamma_R0_9); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000037e"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_13, Gamma_R0_13 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_14, Gamma_R0_14 := memory_load32_le(mem, R0_13), (gamma_load32(Gamma_mem, R0_13) || L(mem, R0_13)); - R1_4, Gamma_R1_4 := bvadd32(R0_14, 3bv32), Gamma_R0_14; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 3bv32)), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_16, Gamma_R0_16 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - assert (L(mem, bvadd64(R0_16, 4bv64)) ==> Gamma_R1_4); - mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0_16, 4bv64), R1_4), gamma_store32(Gamma_mem, bvadd64(R0_16, 4bv64), Gamma_R1_4); + assert (L(mem, bvadd64(R0, 4bv64)) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); + assume {:captureState "%000003ab"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_18, Gamma_R0_18 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_19, Gamma_R0_19 := zero_extend56_8(memory_load8_le(mem, R0_18)), (gamma_load8(Gamma_mem, R0_18) || L(mem, R0_18)); - R0_20, Gamma_R0_20 := zero_extend32_32(bvadd32(R0_19[32:0], 1bv32)), Gamma_R0_19; - R1_5, Gamma_R1_5 := zero_extend56_8(R0_20[8:0]), Gamma_R0_20; + R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32((0bv24 ++ R0[8:0])), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_22, Gamma_R0_22 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - assert (L(mem, R0_22) ==> Gamma_R1_5); - mem, Gamma_mem := memory_store8_le(mem, R0_22, R1_5[8:0]), gamma_store8(Gamma_mem, R0_22, Gamma_R1_5); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003de"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_5; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/initialisation/gcc_pic/initialisation_gtirb.expected b/src/test/correct/initialisation/gcc_pic/initialisation_gtirb.expected index 47799b514..bc4fb819f 100644 --- a/src/test/correct/initialisation/gcc_pic/initialisation_gtirb.expected +++ b/src/test/correct/initialisation/gcc_pic/initialisation_gtirb.expected @@ -1,4 +1,8 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $a_addr: bv64; axiom ($a_addr == 69664bv64); @@ -8,26 +12,12 @@ const {:extern} $y_addr: bv64; axiom ($y_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +31,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,40 +55,37 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2084bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2085bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2086bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2087bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69652bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2084bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 68984bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69576bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69648bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69664bv64); - free ensures (memory_load64_le(mem, 68984bv64) == 1936bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -115,120 +98,96 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69648bv64) == 416611827717bv64); free requires (memory_load64_le(mem, 69656bv64) == 68719476735bv64); free requires (memory_load64_le(mem, 69664bv64) == 8589934593bv64); - free requires (memory_load8_le(mem, 2084bv64) == 1bv8); - free requires (memory_load8_le(mem, 2085bv64) == 0bv8); - free requires (memory_load8_le(mem, 2086bv64) == 2bv8); - free requires (memory_load8_le(mem, 2087bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69652bv64); + free requires (memory_load32_le(mem, 2084bv64) == 131073bv32); + free requires (memory_load64_le(mem, 68984bv64) == 1936bv64); + free requires (memory_load64_le(mem, 68992bv64) == 1856bv64); free requires (memory_load64_le(mem, 69576bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1940bv64); free requires (memory_load64_le(mem, 69584bv64) == 69648bv64); free requires (memory_load64_le(mem, 69600bv64) == 69664bv64); - free requires (memory_load64_le(mem, 68984bv64) == 1936bv64); - free requires (memory_load64_le(mem, 68992bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $x_addr) == 6bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 4bv64)) == 4bv32); ensures (memory_load32_le(mem, bvadd64($a_addr, 0bv64)) == 1bv32); - free ensures (memory_load8_le(mem, 2084bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2085bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2086bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2087bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69652bv64); + free ensures (memory_load32_le(mem, 2084bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 68984bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69576bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69648bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69664bv64); - free ensures (memory_load64_le(mem, 68984bv64) == 1936bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1940bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_11: bool; - var Gamma_R0_13: bool; - var Gamma_R0_14: bool; - var Gamma_R0_16: bool; - var Gamma_R0_18: bool; - var Gamma_R0_19: bool; - var Gamma_R0_20: bool; - var Gamma_R0_22: bool; - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_6: bool; - var Gamma_R0_8: bool; - var Gamma_R0_9: bool; - var Gamma_R1_2: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var R0_11: bv64; - var R0_13: bv64; - var R0_14: bv32; - var R0_16: bv64; - var R0_18: bv64; - var R0_19: bv64; - var R0_20: bv64; - var R0_22: bv64; - var R0_3: bv64; - var R0_4: bv32; - var R0_6: bv64; - var R0_8: bv64; - var R0_9: bv64; - var R1_2: bv32; - var R1_4: bv32; - var R1_5: bv64; $main$__0__$RdBKbEpiQ_~E2xl9E6bZQw: + assume {:captureState "$main$__0__$RdBKbEpiQ_~E2xl9E6bZQw"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, R0_3), (gamma_load32(Gamma_mem, R0_3) || L(mem, R0_3)); - R1_2, Gamma_R1_2 := bvadd32(R0_4, 1bv32), Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_6, Gamma_R0_6 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - assert (L(mem, R0_6) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, R0_6, R1_2), gamma_store32(Gamma_mem, R0_6, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1964$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_8, Gamma_R0_8 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4040bv64)) || L(mem, bvadd64(R0, 4040bv64))); call rely(); - R0_9, Gamma_R0_9 := memory_load64_le(mem, R0_8), (gamma_load64(Gamma_mem, R0_8) || L(mem, R0_8)); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := bvadd64(R0, 18446744073709551615bv64), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_11, Gamma_R0_11 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4040bv64)) || L(mem, bvadd64(R0, 4040bv64))); call rely(); - assert (L(mem, R0_11) ==> Gamma_R0_9); - mem, Gamma_mem := memory_store64_le(mem, R0_11, bvadd64(R0_9, 18446744073709551615bv64)), gamma_store64(Gamma_mem, R0_11, Gamma_R0_9); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1992$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_13, Gamma_R0_13 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_14, Gamma_R0_14 := memory_load32_le(mem, R0_13), (gamma_load32(Gamma_mem, R0_13) || L(mem, R0_13)); - R1_4, Gamma_R1_4 := bvadd32(R0_14, 3bv32), Gamma_R0_14; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 3bv32)), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_16, Gamma_R0_16 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - assert (L(mem, bvadd64(R0_16, 4bv64)) ==> Gamma_R1_4); - mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0_16, 4bv64), R1_4), gamma_store32(Gamma_mem, bvadd64(R0_16, 4bv64), Gamma_R1_4); + assert (L(mem, bvadd64(R0, 4bv64)) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); + assume {:captureState "2020$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_18, Gamma_R0_18 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_19, Gamma_R0_19 := zero_extend56_8(memory_load8_le(mem, R0_18)), (gamma_load8(Gamma_mem, R0_18) || L(mem, R0_18)); - R0_20, Gamma_R0_20 := zero_extend32_32(bvadd32(R0_19[32:0], 1bv32)), Gamma_R0_19; - R1_5, Gamma_R1_5 := zero_extend56_8(R0_20[8:0]), Gamma_R0_20; + R0, Gamma_R0 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R0))), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32((0bv24 ++ R0[8:0])), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_22, Gamma_R0_22 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - assert (L(mem, R0_22) ==> Gamma_R1_5); - mem, Gamma_mem := memory_store8_le(mem, R0_22, R1_5[8:0]), gamma_store8(Gamma_mem, R0_22, Gamma_R1_5); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2052$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_5; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/jumptable2/clang/jumptable2_gtirb.expected b/src/test/correct/jumptable2/clang/jumptable2_gtirb.expected index 05cd7ad8a..aedfd59b2 100644 --- a/src/test/correct/jumptable2/clang/jumptable2_gtirb.expected +++ b/src/test/correct/jumptable2/clang/jumptable2_gtirb.expected @@ -1,5 +1,27 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -8,26 +30,16 @@ const {:extern} $jump_table_addr: bv64; axiom ($jump_table_addr == 69688bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69680bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -37,15 +49,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -56,39 +64,34 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); - free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); - free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -102,204 +105,212 @@ procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure add_two(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2052bv64) == 1bv8); - free requires (memory_load8_le(mem, 2053bv64) == 0bv8); - free requires (memory_load8_le(mem, 2054bv64) == 2bv8); - free requires (memory_load8_le(mem, 2055bv64) == 0bv8); - free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); - free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); - free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); + modifies Gamma_R8, Gamma_R9, Gamma_mem, R8, R9, mem; + free requires (memory_load32_le(mem, 2052bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1936bv64); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); - free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); - free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); + free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); implementation add_two() { - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var R8_1: bv32; - var R8_2: bv32; $add_two$__0__$q7ZKy1R2QUKWr5v_JFG4ug: + assume {:captureState "$add_two$__0__$q7ZKy1R2QUKWr5v_JFG4ug"} true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - R8_1, Gamma_R8_1 := memory_load32_le(mem, 69680bv64), (gamma_load32(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); - R8_2, Gamma_R8_2 := bvadd32(R8_1, 2bv32), Gamma_R8_1; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 48bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 48bv64)) || L(mem, bvadd64(R9, 48bv64))); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 2bv32)), Gamma_R8; call rely(); - assert (L(mem, 69680bv64) ==> Gamma_R8_2); - mem, Gamma_mem := memory_store32_le(mem, 69680bv64, R8_2), gamma_store32(Gamma_mem, 69680bv64, Gamma_R8_2); + assert (L(mem, bvadd64(R9, 48bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 48bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 48bv64), Gamma_R8); + assume {:captureState "1888$0"} true; goto add_two_basil_return; add_two_basil_return: + assume {:captureState "add_two_basil_return"} true; return; } procedure sub_seven(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2052bv64) == 1bv8); - free requires (memory_load8_le(mem, 2053bv64) == 0bv8); - free requires (memory_load8_le(mem, 2054bv64) == 2bv8); - free requires (memory_load8_le(mem, 2055bv64) == 0bv8); - free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); - free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); - free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R8, R9, VF, ZF, mem; + free requires (memory_load32_le(mem, 2052bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1936bv64); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); - free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); - free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); + free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); implementation sub_seven() { - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var R8_1: bv32; - var R8_2: bv32; + var Cse0__5$0$2: bv32; + var Gamma_Cse0__5$0$2: bool; $sub_seven$__0__$NsH3NjTvSbaIhN4GlaFRLw: + assume {:captureState "$sub_seven$__0__$NsH3NjTvSbaIhN4GlaFRLw"} true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - R8_1, Gamma_R8_1 := memory_load32_le(mem, 69680bv64), (gamma_load32(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); - R8_2, Gamma_R8_2 := bvadd32(R8_1, 4294967289bv32), Gamma_R8_1; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 48bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 48bv64)) || L(mem, bvadd64(R9, 48bv64))); + Cse0__5$0$2, Gamma_Cse0__5$0$2 := bvadd32(R8[32:0], 4294967289bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$0$2), bvadd33(sign_extend1_32(R8[32:0]), 8589934585bv33))), (Gamma_R8 && Gamma_Cse0__5$0$2); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$2), bvadd33(zero_extend1_32(R8[32:0]), 4294967289bv33))), (Gamma_R8 && Gamma_Cse0__5$0$2); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$2, 0bv32), Gamma_Cse0__5$0$2; + NF, Gamma_NF := Cse0__5$0$2[32:31], Gamma_Cse0__5$0$2; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$0$2), Gamma_Cse0__5$0$2; call rely(); - assert (L(mem, 69680bv64) ==> Gamma_R8_2); - mem, Gamma_mem := memory_store32_le(mem, 69680bv64, R8_2), gamma_store32(Gamma_mem, 69680bv64, Gamma_R8_2); + assert (L(mem, bvadd64(R9, 48bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 48bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 48bv64), Gamma_R8); + assume {:captureState "1928$0"} true; goto sub_seven_basil_return; sub_seven_basil_return: + assume {:captureState "sub_seven_basil_return"} true; return; } procedure add_six(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2052bv64) == 1bv8); - free requires (memory_load8_le(mem, 2053bv64) == 0bv8); - free requires (memory_load8_le(mem, 2054bv64) == 2bv8); - free requires (memory_load8_le(mem, 2055bv64) == 0bv8); - free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); - free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); - free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); + modifies Gamma_R8, Gamma_R9, Gamma_mem, R8, R9, mem; + free requires (memory_load32_le(mem, 2052bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1936bv64); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); - free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); - free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); + free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); implementation add_six() { - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var R8_1: bv32; - var R8_2: bv32; $add_six$__0__$R7rnILkkQt~m3atwYHgqZw: + assume {:captureState "$add_six$__0__$R7rnILkkQt~m3atwYHgqZw"} true; + R9, Gamma_R9 := 69632bv64, true; call rely(); - R8_1, Gamma_R8_1 := memory_load32_le(mem, 69680bv64), (gamma_load32(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); - R8_2, Gamma_R8_2 := bvadd32(R8_1, 6bv32), Gamma_R8_1; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 48bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 48bv64)) || L(mem, bvadd64(R9, 48bv64))); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 6bv32)), Gamma_R8; call rely(); - assert (L(mem, 69680bv64) ==> Gamma_R8_2); - mem, Gamma_mem := memory_store32_le(mem, 69680bv64, R8_2), gamma_store32(Gamma_mem, 69680bv64, Gamma_R8_2); + assert (L(mem, bvadd64(R9, 48bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 48bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 48bv64), Gamma_R8); + assume {:captureState "1908$0"} true; goto add_six_basil_return; add_six_basil_return: + assume {:captureState "add_six_basil_return"} true; return; } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R29, R30, R31, R8, R9, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); free requires (memory_load64_le(mem, 69680bv64) == 5bv64); free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); - free requires (memory_load8_le(mem, 2052bv64) == 1bv8); - free requires (memory_load8_le(mem, 2053bv64) == 0bv8); - free requires (memory_load8_le(mem, 2054bv64) == 2bv8); - free requires (memory_load8_le(mem, 2055bv64) == 0bv8); - free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); - free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); - free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); + free requires (memory_load32_le(mem, 2052bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1936bv64); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); - free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); - free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); + free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_5: bool; - var Gamma_R8_5: bool; - var Gamma_R8_6: bool; - var R0_2: bv64; - var R29_3: bv64; - var R30_5: bv64; - var R8_5: bv64; - var R8_6: bv64; + var Cse0__5$0$1: bv64; + var Cse0__5$1$1: bv64; + var Gamma_Cse0__5$0$1: bool; + var Gamma_Cse0__5$1$1: bool; $main$__0__$eU5HB3jMTHGqgfMDZYX1tA: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), 69688bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551580bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R1_in); + assume {:captureState "$main$__0__$eU5HB3jMTHGqgfMDZYX1tA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + Cse0__5$1$1, Gamma_Cse0__5$1$1 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$1, R29), gamma_store64(Gamma_stack, Cse0__5$1$1, Gamma_R29); + assume {:captureState "1940$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$1, 8bv64), Gamma_R30); + assume {:captureState "1940$2"} true; + R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R9, Gamma_R9 := bvadd64(R9, 56bv64), Gamma_R9; + stack, Gamma_stack := memory_store64_le(stack, R31, R9), gamma_store64(Gamma_stack, R31, Gamma_R9); + assume {:captureState "1960$0"} true; + R9, Gamma_R9 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R9[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R9); + assume {:captureState "1968$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "1972$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551608bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551608bv64), Gamma_R0); + assume {:captureState "1976$0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "1980$0"} true; + call rely(); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + R30, Gamma_R30 := 1992bv64, true; call add_two(); goto $main$__1__$p5YPh9uZSeeRZ2XwUYn~Tw; $main$__1__$p5YPh9uZSeeRZ2XwUYn~Tw: + assume {:captureState "$main$__1__$p5YPh9uZSeeRZ2XwUYn~Tw"} true; + R8, Gamma_R8 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + call rely(); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 8bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 8bv64)) || L(mem, bvadd64(R8, 8bv64))); + R30, Gamma_R30 := 1992bv64, true; call add_six(); goto $main$__2__$_hg9mn5wS7GgqSlZeoJfGQ; $main$__2__$_hg9mn5wS7GgqSlZeoJfGQ: - R8_5, Gamma_R8_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551568bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64)); + assume {:captureState "$main$__2__$_hg9mn5wS7GgqSlZeoJfGQ"} true; + R8, Gamma_R8 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); call rely(); - R8_6, Gamma_R8_6 := memory_load64_le(mem, bvadd64(R8_5, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R8_5, 16bv64)) || L(mem, bvadd64(R8_5, 16bv64))); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 16bv64)) || L(mem, bvadd64(R8, 16bv64))); + R30, Gamma_R30 := 1992bv64, true; call sub_seven(); goto $main$__3__$Wg9L39DXQImRFWkgvX2gEw; $main$__3__$Wg9L39DXQImRFWkgvX2gEw: - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551580bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64)); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_5, Gamma_R30_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__3__$Wg9L39DXQImRFWkgvX2gEw"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + Cse0__5$0$1, Gamma_Cse0__5$0$1 := bvadd64(R31, 32bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$0$1), gamma_load64(Gamma_stack, Cse0__5$0$1); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$0$1, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$0$1, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out, R9_out := R0_2, R29_3, R30_5, R31_in, R8_6, 0bv64; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_2, Gamma_R29_3, Gamma_R30_5, Gamma_R31_in, Gamma_R8_6, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/jumptable2/clang_O2/jumptable2_gtirb.expected b/src/test/correct/jumptable2/clang_O2/jumptable2_gtirb.expected index 3e7e7fa88..37536bc1f 100644 --- a/src/test/correct/jumptable2/clang_O2/jumptable2_gtirb.expected +++ b/src/test/correct/jumptable2/clang_O2/jumptable2_gtirb.expected @@ -1,5 +1,19 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R19: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R19: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -8,26 +22,12 @@ const {:extern} $jump_table_addr: bv64; axiom ($jump_table_addr == 69688bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69680bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -37,15 +37,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -56,38 +52,32 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2016bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2017bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2018bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2019bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); - free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); - free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2016bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -100,198 +90,194 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R19_in: bv64, Gamma_R19_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R19_out: bv64, Gamma_R19_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R19, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R19, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); free requires (memory_load64_le(mem, 69680bv64) == 5bv64); free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); - free requires (memory_load8_le(mem, 2016bv64) == 1bv8); - free requires (memory_load8_le(mem, 2017bv64) == 0bv8); - free requires (memory_load8_le(mem, 2018bv64) == 2bv8); - free requires (memory_load8_le(mem, 2019bv64) == 0bv8); - free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); - free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); - free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); + free requires (memory_load32_le(mem, 2016bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1936bv64); - free ensures (memory_load8_le(mem, 2016bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2017bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2018bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2019bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); - free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); - free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); + free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); + free ensures (Gamma_R19 == old(Gamma_R19)); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R19 == old(R19)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2016bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); -implementation main(R19_in: bv64, Gamma_R19_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R19_out: bv64, Gamma_R19_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R19_4: bool; - var Gamma_R29_3: bool; - var Gamma_R30_5: bool; - var Gamma_R8_3: bool; - var R19_4: bv64; - var R29_3: bv64; - var R30_5: bv64; - var R8_3: bv64; + var Cse0__5$2$0: bv64; + var Gamma_Cse0__5$2$0: bool; $main$__0__$wC7NIj00StStGxM0LI2VwQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R19_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R19_in); + assume {:captureState "$main$__0__$wC7NIj00StStGxM0LI2VwQ"} true; + Cse0__5$2$0, Gamma_Cse0__5$2$0 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$2$0, R29), gamma_store64(Gamma_stack, Cse0__5$2$0, Gamma_R29); + assume {:captureState "1936$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$2$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$2$0, 8bv64), Gamma_R30); + assume {:captureState "1936$2"} true; + R31, Gamma_R31 := Cse0__5$2$0, Gamma_Cse0__5$2$0; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R19), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R19); + assume {:captureState "1940$0"} true; + R29, Gamma_R29 := R31, Gamma_R31; + R19, Gamma_R19 := 69632bv64, true; + R19, Gamma_R19 := bvadd64(R19, 56bv64), Gamma_R19; + call rely(); + R8, Gamma_R8 := memory_load64_le(mem, R19), (gamma_load64(Gamma_mem, R19) || L(mem, R19)); + R30, Gamma_R30 := 1964bv64, true; call add_two(); goto $main$__1__$9JzDMe78T9KO0OnEp65uKg; $main$__1__$9JzDMe78T9KO0OnEp65uKg: + assume {:captureState "$main$__1__$9JzDMe78T9KO0OnEp65uKg"} true; + call rely(); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R19, 8bv64)), (gamma_load64(Gamma_mem, bvadd64(R19, 8bv64)) || L(mem, bvadd64(R19, 8bv64))); + R30, Gamma_R30 := 1964bv64, true; call add_six(); goto $main$__2__$F9IXiDuaS2S~EwbOz5HUEw; $main$__2__$F9IXiDuaS2S~EwbOz5HUEw: + assume {:captureState "$main$__2__$F9IXiDuaS2S~EwbOz5HUEw"} true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, 69704bv64), (gamma_load64(Gamma_mem, 69704bv64) || L(mem, 69704bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R19, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R19, 16bv64)) || L(mem, bvadd64(R19, 16bv64))); + R30, Gamma_R30 := 1964bv64, true; call sub_seven(); goto $main$__3__$OhO~c77aTJ6ndOxW9PxJzQ; $main$__3__$OhO~c77aTJ6ndOxW9PxJzQ: - R19_4, Gamma_R19_4 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - R30_5, Gamma_R30_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "$main$__3__$OhO~c77aTJ6ndOxW9PxJzQ"} true; + R0, Gamma_R0 := 0bv64, true; + R19, Gamma_R19 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R19_out, R29_out, R30_out, R31_out, R8_out := 0bv64, R19_4, R29_3, R30_5, R31_in, R8_3; - Gamma_R0_out, Gamma_R19_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out := true, Gamma_R19_4, Gamma_R29_3, Gamma_R30_5, Gamma_R31_in, Gamma_R8_3; + assume {:captureState "main_basil_return"} true; return; } procedure sub_seven(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2016bv64) == 1bv8); - free requires (memory_load8_le(mem, 2017bv64) == 0bv8); - free requires (memory_load8_le(mem, 2018bv64) == 2bv8); - free requires (memory_load8_le(mem, 2019bv64) == 0bv8); - free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); - free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); - free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); + modifies Gamma_R8, Gamma_R9, Gamma_mem, R8, R9, mem; + free requires (memory_load32_le(mem, 2016bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1936bv64); - free ensures (memory_load8_le(mem, 2016bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2017bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2018bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2019bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); - free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); - free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); + free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); + free ensures (memory_load32_le(mem, 2016bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); implementation sub_seven() { - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var R9_1: bv32; - var R9_2: bv32; $sub_seven$__0__$ocbHXXGATjqAp6GkHigdUA: + assume {:captureState "$sub_seven$__0__$ocbHXXGATjqAp6GkHigdUA"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R9_1, Gamma_R9_1 := memory_load32_le(mem, 69680bv64), (gamma_load32(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); - R9_2, Gamma_R9_2 := bvadd32(R9_1, 4294967289bv32), Gamma_R9_1; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 48bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 48bv64)) || L(mem, bvadd64(R8, 48bv64))); + R9, Gamma_R9 := zero_extend32_32(bvadd32(R9[32:0], 4294967289bv32)), Gamma_R9; call rely(); - assert (L(mem, 69680bv64) ==> Gamma_R9_2); - mem, Gamma_mem := memory_store32_le(mem, 69680bv64, R9_2), gamma_store32(Gamma_mem, 69680bv64, Gamma_R9_2); + assert (L(mem, bvadd64(R8, 48bv64)) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 48bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 48bv64), Gamma_R9); + assume {:captureState "1928$0"} true; goto sub_seven_basil_return; sub_seven_basil_return: + assume {:captureState "sub_seven_basil_return"} true; return; } procedure add_two(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2016bv64) == 1bv8); - free requires (memory_load8_le(mem, 2017bv64) == 0bv8); - free requires (memory_load8_le(mem, 2018bv64) == 2bv8); - free requires (memory_load8_le(mem, 2019bv64) == 0bv8); - free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); - free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); - free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); + modifies Gamma_R8, Gamma_R9, Gamma_mem, R8, R9, mem; + free requires (memory_load32_le(mem, 2016bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1936bv64); - free ensures (memory_load8_le(mem, 2016bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2017bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2018bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2019bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); - free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); - free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); + free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); + free ensures (memory_load32_le(mem, 2016bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); implementation add_two() { - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var R9_1: bv32; - var R9_2: bv32; $add_two$__0__$Y7f13oh7RqmVBWvxNXuniA: + assume {:captureState "$add_two$__0__$Y7f13oh7RqmVBWvxNXuniA"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R9_1, Gamma_R9_1 := memory_load32_le(mem, 69680bv64), (gamma_load32(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); - R9_2, Gamma_R9_2 := bvadd32(R9_1, 2bv32), Gamma_R9_1; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 48bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 48bv64)) || L(mem, bvadd64(R8, 48bv64))); + R9, Gamma_R9 := zero_extend32_32(bvadd32(R9[32:0], 2bv32)), Gamma_R9; call rely(); - assert (L(mem, 69680bv64) ==> Gamma_R9_2); - mem, Gamma_mem := memory_store32_le(mem, 69680bv64, R9_2), gamma_store32(Gamma_mem, 69680bv64, Gamma_R9_2); + assert (L(mem, bvadd64(R8, 48bv64)) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 48bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 48bv64), Gamma_R9); + assume {:captureState "1888$0"} true; goto add_two_basil_return; add_two_basil_return: + assume {:captureState "add_two_basil_return"} true; return; } procedure add_six(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2016bv64) == 1bv8); - free requires (memory_load8_le(mem, 2017bv64) == 0bv8); - free requires (memory_load8_le(mem, 2018bv64) == 2bv8); - free requires (memory_load8_le(mem, 2019bv64) == 0bv8); - free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); - free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); - free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); + modifies Gamma_R8, Gamma_R9, Gamma_mem, R8, R9, mem; + free requires (memory_load32_le(mem, 2016bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1936bv64); - free ensures (memory_load8_le(mem, 2016bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2017bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2018bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2019bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); - free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); - free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69688bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69696bv64) == 1896bv64); + free requires (memory_load64_le(mem, 69704bv64) == 1916bv64); + free ensures (memory_load32_le(mem, 2016bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69696bv64) == 1896bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1916bv64); implementation add_six() { - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var R9_1: bv32; - var R9_2: bv32; $add_six$__0__$xWsLZ13VTJuk_UvRVjK3kQ: + assume {:captureState "$add_six$__0__$xWsLZ13VTJuk_UvRVjK3kQ"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R9_1, Gamma_R9_1 := memory_load32_le(mem, 69680bv64), (gamma_load32(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); - R9_2, Gamma_R9_2 := bvadd32(R9_1, 6bv32), Gamma_R9_1; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 48bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 48bv64)) || L(mem, bvadd64(R8, 48bv64))); + R9, Gamma_R9 := zero_extend32_32(bvadd32(R9[32:0], 6bv32)), Gamma_R9; call rely(); - assert (L(mem, 69680bv64) ==> Gamma_R9_2); - mem, Gamma_mem := memory_store32_le(mem, 69680bv64, R9_2), gamma_store32(Gamma_mem, 69680bv64, Gamma_R9_2); + assert (L(mem, bvadd64(R8, 48bv64)) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 48bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 48bv64), Gamma_R9); + assume {:captureState "1908$0"} true; goto add_six_basil_return; add_six_basil_return: + assume {:captureState "add_six_basil_return"} true; return; } diff --git a/src/test/correct/jumptable2/clang_pic/jumptable2_gtirb.expected b/src/test/correct/jumptable2/clang_pic/jumptable2_gtirb.expected index f6936d2ec..829cdbe50 100644 --- a/src/test/correct/jumptable2/clang_pic/jumptable2_gtirb.expected +++ b/src/test/correct/jumptable2/clang_pic/jumptable2_gtirb.expected @@ -1,5 +1,27 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -8,26 +30,16 @@ const {:extern} $jump_table_addr: bv64; axiom ($jump_table_addr == 69688bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69680bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -37,15 +49,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -56,41 +64,36 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2124bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2125bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2126bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2127bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69584bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69688bv64) == 1940bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2124bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1936bv64); - free ensures (memory_load64_le(mem, 69568bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69056bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69568bv64) == 69680bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 2012bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1988bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69696bv64) == 1964bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1988bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -104,236 +107,234 @@ procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure add_two(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2124bv64) == 1bv8); - free requires (memory_load8_le(mem, 2125bv64) == 0bv8); - free requires (memory_load8_le(mem, 2126bv64) == 2bv8); - free requires (memory_load8_le(mem, 2127bv64) == 0bv8); - free requires (memory_load64_le(mem, 69584bv64) == 2012bv64); - free requires (memory_load64_le(mem, 69688bv64) == 1940bv64); + modifies Gamma_R8, Gamma_R9, Gamma_mem, R8, R9, mem; + free requires (memory_load32_le(mem, 2124bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1936bv64); - free requires (memory_load64_le(mem, 69568bv64) == 69680bv64); free requires (memory_load64_le(mem, 69056bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69568bv64) == 69680bv64); + free requires (memory_load64_le(mem, 69584bv64) == 2012bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69688bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69704bv64) == 1988bv64); + free requires (memory_load64_le(mem, 69688bv64) == 1940bv64); free requires (memory_load64_le(mem, 69696bv64) == 1964bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69688bv64); - free ensures (memory_load8_le(mem, 2124bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2125bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2126bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2127bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69584bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69688bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69704bv64) == 1988bv64); + free ensures (memory_load32_le(mem, 2124bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1936bv64); - free ensures (memory_load64_le(mem, 69568bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69056bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69568bv64) == 69680bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 2012bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1988bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69696bv64) == 1964bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1988bv64); implementation add_two() { - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R9_2: bool; - var R8_1: bv32; - var R8_2: bv32; - var R9_2: bv64; $add_two$__0__$r_TPM3RHSfm3u2v1UY0bLw: + assume {:captureState "$add_two$__0__$r_TPM3RHSfm3u2v1UY0bLw"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); call rely(); - R8_1, Gamma_R8_1 := memory_load32_le(mem, R9_2), (gamma_load32(Gamma_mem, R9_2) || L(mem, R9_2)); - R8_2, Gamma_R8_2 := bvadd32(R8_1, 2bv32), Gamma_R8_1; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 2bv32)), Gamma_R8; call rely(); - assert (L(mem, R9_2) ==> Gamma_R8_2); - mem, Gamma_mem := memory_store32_le(mem, R9_2, R8_2), gamma_store32(Gamma_mem, R9_2, Gamma_R8_2); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1956$0"} true; goto add_two_basil_return; add_two_basil_return: + assume {:captureState "add_two_basil_return"} true; return; } procedure add_six(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2124bv64) == 1bv8); - free requires (memory_load8_le(mem, 2125bv64) == 0bv8); - free requires (memory_load8_le(mem, 2126bv64) == 2bv8); - free requires (memory_load8_le(mem, 2127bv64) == 0bv8); - free requires (memory_load64_le(mem, 69584bv64) == 2012bv64); - free requires (memory_load64_le(mem, 69688bv64) == 1940bv64); + modifies Gamma_R8, Gamma_R9, Gamma_mem, R8, R9, mem; + free requires (memory_load32_le(mem, 2124bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1936bv64); - free requires (memory_load64_le(mem, 69568bv64) == 69680bv64); free requires (memory_load64_le(mem, 69056bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69568bv64) == 69680bv64); + free requires (memory_load64_le(mem, 69584bv64) == 2012bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69688bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69704bv64) == 1988bv64); + free requires (memory_load64_le(mem, 69688bv64) == 1940bv64); free requires (memory_load64_le(mem, 69696bv64) == 1964bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69688bv64); - free ensures (memory_load8_le(mem, 2124bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2125bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2126bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2127bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69584bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69688bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69704bv64) == 1988bv64); + free ensures (memory_load32_le(mem, 2124bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1936bv64); - free ensures (memory_load64_le(mem, 69568bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69056bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69568bv64) == 69680bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 2012bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1988bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69696bv64) == 1964bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1988bv64); implementation add_six() { - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R9_2: bool; - var R8_1: bv32; - var R8_2: bv32; - var R9_2: bv64; $add_six$__0__$WmWCAeM7QYqeVhx9woNn_g: + assume {:captureState "$add_six$__0__$WmWCAeM7QYqeVhx9woNn_g"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); call rely(); - R8_1, Gamma_R8_1 := memory_load32_le(mem, R9_2), (gamma_load32(Gamma_mem, R9_2) || L(mem, R9_2)); - R8_2, Gamma_R8_2 := bvadd32(R8_1, 6bv32), Gamma_R8_1; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 6bv32)), Gamma_R8; call rely(); - assert (L(mem, R9_2) ==> Gamma_R8_2); - mem, Gamma_mem := memory_store32_le(mem, R9_2, R8_2), gamma_store32(Gamma_mem, R9_2, Gamma_R8_2); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1980$0"} true; goto add_six_basil_return; add_six_basil_return: + assume {:captureState "add_six_basil_return"} true; return; } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R29, R30, R31, R8, R9, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); free requires (memory_load64_le(mem, 69680bv64) == 5bv64); free requires (memory_load64_le(mem, 69688bv64) == 1940bv64); free requires (memory_load64_le(mem, 69696bv64) == 1964bv64); free requires (memory_load64_le(mem, 69704bv64) == 1988bv64); - free requires (memory_load8_le(mem, 2124bv64) == 1bv8); - free requires (memory_load8_le(mem, 2125bv64) == 0bv8); - free requires (memory_load8_le(mem, 2126bv64) == 2bv8); - free requires (memory_load8_le(mem, 2127bv64) == 0bv8); - free requires (memory_load64_le(mem, 69584bv64) == 2012bv64); - free requires (memory_load64_le(mem, 69688bv64) == 1940bv64); + free requires (memory_load32_le(mem, 2124bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1936bv64); - free requires (memory_load64_le(mem, 69568bv64) == 69680bv64); free requires (memory_load64_le(mem, 69056bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69568bv64) == 69680bv64); + free requires (memory_load64_le(mem, 69584bv64) == 2012bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69688bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69704bv64) == 1988bv64); + free requires (memory_load64_le(mem, 69688bv64) == 1940bv64); free requires (memory_load64_le(mem, 69696bv64) == 1964bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69688bv64); - free ensures (memory_load8_le(mem, 2124bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2125bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2126bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2127bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69584bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69688bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69704bv64) == 1988bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2124bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1936bv64); - free ensures (memory_load64_le(mem, 69568bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69056bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69568bv64) == 69680bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 2012bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1988bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69696bv64) == 1964bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1988bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_5: bool; - var Gamma_R8_2: bool; - var Gamma_R8_6: bool; - var Gamma_R8_7: bool; - var R0_2: bv64; - var R29_3: bv64; - var R30_5: bv64; - var R8_2: bv64; - var R8_6: bv64; - var R8_7: bv64; + var Cse0__5$0$1: bv64; + var Cse0__5$2$1: bv64; + var Gamma_Cse0__5$0$1: bool; + var Gamma_Cse0__5$2$1: bool; $main$__0__$EvxJkgQzT1q~MAbs_DZI3w: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); + assume {:captureState "$main$__0__$EvxJkgQzT1q~MAbs_DZI3w"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + Cse0__5$0$1, Gamma_Cse0__5$0$1 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$1, R29), gamma_store64(Gamma_stack, Cse0__5$0$1, Gamma_R29); + assume {:captureState "2016$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$1, 8bv64), Gamma_R30); + assume {:captureState "2016$2"} true; + R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; + R8, Gamma_R8 := 65536bv64, true; + call rely(); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4064bv64)) || L(mem, bvadd64(R8, 4064bv64))); + stack, Gamma_stack := memory_store64_le(stack, R31, R8), gamma_store64(Gamma_stack, R31, Gamma_R8); + assume {:captureState "2032$0"} true; + R9, Gamma_R9 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R9[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R9); + assume {:captureState "2040$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "2044$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551608bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551608bv64), Gamma_R0); + assume {:captureState "2048$0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "2052$0"} true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), R8_2), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R8_2); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551580bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R1_in); + R8, Gamma_R8 := memory_load64_le(mem, R8), (gamma_load64(Gamma_mem, R8) || L(mem, R8)); + R30, Gamma_R30 := 2064bv64, true; call add_two(); goto $main$__1__$~R7GAmlPRJGIPLWxHDibcw; $main$__1__$~R7GAmlPRJGIPLWxHDibcw: + assume {:captureState "$main$__1__$~R7GAmlPRJGIPLWxHDibcw"} true; + R8, Gamma_R8 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + call rely(); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 8bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 8bv64)) || L(mem, bvadd64(R8, 8bv64))); + R30, Gamma_R30 := 2064bv64, true; call add_six(); goto $main$__2__$N2O4Vfx1QgWyqbECmi5prA; $main$__2__$N2O4Vfx1QgWyqbECmi5prA: - R8_6, Gamma_R8_6 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551568bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64)); + assume {:captureState "$main$__2__$N2O4Vfx1QgWyqbECmi5prA"} true; + R8, Gamma_R8 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); call rely(); - R8_7, Gamma_R8_7 := memory_load64_le(mem, bvadd64(R8_6, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R8_6, 16bv64)) || L(mem, bvadd64(R8_6, 16bv64))); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 16bv64)) || L(mem, bvadd64(R8, 16bv64))); + R30, Gamma_R30 := 2064bv64, true; call sub_seven(); goto $main$__3__$Ql81hl5HThuEPpygsxdjXA; $main$__3__$Ql81hl5HThuEPpygsxdjXA: - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551580bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64)); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_5, Gamma_R30_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__3__$Ql81hl5HThuEPpygsxdjXA"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + Cse0__5$2$1, Gamma_Cse0__5$2$1 := bvadd64(R31, 32bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$2$1), gamma_load64(Gamma_stack, Cse0__5$2$1); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$2$1, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$2$1, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out, R8_out, R9_out := R0_2, R29_3, R30_5, R31_in, R8_7, 0bv64; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_2, Gamma_R29_3, Gamma_R30_5, Gamma_R31_in, Gamma_R8_7, true; + assume {:captureState "main_basil_return"} true; return; } procedure sub_seven(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2124bv64) == 1bv8); - free requires (memory_load8_le(mem, 2125bv64) == 0bv8); - free requires (memory_load8_le(mem, 2126bv64) == 2bv8); - free requires (memory_load8_le(mem, 2127bv64) == 0bv8); - free requires (memory_load64_le(mem, 69584bv64) == 2012bv64); - free requires (memory_load64_le(mem, 69688bv64) == 1940bv64); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R8, R9, VF, ZF, mem; + free requires (memory_load32_le(mem, 2124bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1936bv64); - free requires (memory_load64_le(mem, 69568bv64) == 69680bv64); free requires (memory_load64_le(mem, 69056bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69568bv64) == 69680bv64); + free requires (memory_load64_le(mem, 69584bv64) == 2012bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69688bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69704bv64) == 1988bv64); + free requires (memory_load64_le(mem, 69688bv64) == 1940bv64); free requires (memory_load64_le(mem, 69696bv64) == 1964bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69688bv64); - free ensures (memory_load8_le(mem, 2124bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2125bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2126bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2127bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69584bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69688bv64) == 1940bv64); + free requires (memory_load64_le(mem, 69704bv64) == 1988bv64); + free ensures (memory_load32_le(mem, 2124bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1936bv64); - free ensures (memory_load64_le(mem, 69568bv64) == 69680bv64); free ensures (memory_load64_le(mem, 69056bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69568bv64) == 69680bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 2012bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69704bv64) == 1988bv64); + free ensures (memory_load64_le(mem, 69688bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69696bv64) == 1964bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69704bv64) == 1988bv64); implementation sub_seven() { - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R9_2: bool; - var R8_1: bv32; - var R8_2: bv32; - var R9_2: bv64; + var Cse0__5$0$3: bv32; + var Gamma_Cse0__5$0$3: bool; $sub_seven$__0__$PpMW6ScZQ3q32PrByBlXeA: + assume {:captureState "$sub_seven$__0__$PpMW6ScZQ3q32PrByBlXeA"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); call rely(); - R8_1, Gamma_R8_1 := memory_load32_le(mem, R9_2), (gamma_load32(Gamma_mem, R9_2) || L(mem, R9_2)); - R8_2, Gamma_R8_2 := bvadd32(R8_1, 4294967289bv32), Gamma_R8_1; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); + Cse0__5$0$3, Gamma_Cse0__5$0$3 := bvadd32(R8[32:0], 4294967289bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$0$3), bvadd33(sign_extend1_32(R8[32:0]), 8589934585bv33))), (Gamma_R8 && Gamma_Cse0__5$0$3); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$3), bvadd33(zero_extend1_32(R8[32:0]), 4294967289bv33))), (Gamma_R8 && Gamma_Cse0__5$0$3); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$3, 0bv32), Gamma_Cse0__5$0$3; + NF, Gamma_NF := Cse0__5$0$3[32:31], Gamma_Cse0__5$0$3; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$0$3), Gamma_Cse0__5$0$3; call rely(); - assert (L(mem, R9_2) ==> Gamma_R8_2); - mem, Gamma_mem := memory_store32_le(mem, R9_2, R8_2), gamma_store32(Gamma_mem, R9_2, Gamma_R8_2); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "2004$0"} true; goto sub_seven_basil_return; sub_seven_basil_return: + assume {:captureState "sub_seven_basil_return"} true; return; } diff --git a/src/test/correct/jumptable2/gcc/jumptable2_gtirb.expected b/src/test/correct/jumptable2/gcc/jumptable2_gtirb.expected index 677a4c67e..9c87ecd7c 100644 --- a/src/test/correct/jumptable2/gcc/jumptable2_gtirb.expected +++ b/src/test/correct/jumptable2/gcc/jumptable2_gtirb.expected @@ -1,5 +1,15 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -8,26 +18,12 @@ const {:extern} $jump_table_addr: bv64; axiom ($jump_table_addr == 69656bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69648bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -37,15 +33,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -56,38 +48,32 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1984bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1912bv64); - free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69672bv64) == 1948bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -101,191 +87,205 @@ procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure add_two(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2080bv64) == 1bv8); - free requires (memory_load8_le(mem, 2081bv64) == 0bv8); - free requires (memory_load8_le(mem, 2082bv64) == 2bv8); - free requires (memory_load8_le(mem, 2083bv64) == 0bv8); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2080bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1984bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69656bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69664bv64) == 1912bv64); - free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69672bv64) == 1948bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1984bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1912bv64); - free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69672bv64) == 1948bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); implementation add_two() { - var Gamma_R0_3: bool; - var Gamma_R1_1: bool; - var R0_3: bv32; - var R1_1: bv32; $add_two$__0__$Rbfn3kvcQq6N6xB9sTqQbg: + assume {:captureState "$add_two$__0__$Rbfn3kvcQq6N6xB9sTqQbg"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69648bv64), (gamma_load32(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - R1_1, Gamma_R1_1 := bvadd32(R0_3, 2bv32), Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 2bv32)), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); - assert (L(mem, 69648bv64) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, 69648bv64, R1_1), gamma_store32(Gamma_mem, 69648bv64, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1900$0"} true; goto add_two_basil_return; add_two_basil_return: + assume {:captureState "add_two_basil_return"} true; return; } procedure sub_seven(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2080bv64) == 1bv8); - free requires (memory_load8_le(mem, 2081bv64) == 0bv8); - free requires (memory_load8_le(mem, 2082bv64) == 2bv8); - free requires (memory_load8_le(mem, 2083bv64) == 0bv8); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2080bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1984bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69656bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69664bv64) == 1912bv64); - free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69672bv64) == 1948bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1984bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1912bv64); - free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69672bv64) == 1948bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); implementation sub_seven() { - var Gamma_R0_3: bool; - var Gamma_R1_1: bool; - var R0_3: bv32; - var R1_1: bv32; $sub_seven$__0__$MLKKmEoXSkSC_7jU3K5ZIA: + assume {:captureState "$sub_seven$__0__$MLKKmEoXSkSC_7jU3K5ZIA"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69648bv64), (gamma_load32(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - R1_1, Gamma_R1_1 := bvadd32(R0_3, 4294967289bv32), Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 4294967289bv32)), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); - assert (L(mem, 69648bv64) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, 69648bv64, R1_1), gamma_store32(Gamma_mem, 69648bv64, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1972$0"} true; goto sub_seven_basil_return; sub_seven_basil_return: + assume {:captureState "sub_seven_basil_return"} true; return; } procedure add_six(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2080bv64) == 1bv8); - free requires (memory_load8_le(mem, 2081bv64) == 0bv8); - free requires (memory_load8_le(mem, 2082bv64) == 2bv8); - free requires (memory_load8_le(mem, 2083bv64) == 0bv8); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2080bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1984bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69656bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69664bv64) == 1912bv64); - free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69672bv64) == 1948bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1984bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1912bv64); - free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69672bv64) == 1948bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); implementation add_six() { - var Gamma_R0_3: bool; - var Gamma_R1_1: bool; - var R0_3: bv32; - var R1_1: bv32; $add_six$__0__$tNh_uLjASU~LDGT1yt60fQ: + assume {:captureState "$add_six$__0__$tNh_uLjASU~LDGT1yt60fQ"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69648bv64), (gamma_load32(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - R1_1, Gamma_R1_1 := bvadd32(R0_3, 6bv32), Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 6bv32)), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); - assert (L(mem, 69648bv64) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, 69648bv64, R1_1), gamma_store32(Gamma_mem, 69648bv64, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1936$0"} true; goto add_six_basil_return; add_six_basil_return: + assume {:captureState "add_six_basil_return"} true; return; } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69648bv64) == 5bv64); free requires (memory_load64_le(mem, 69656bv64) == 1876bv64); free requires (memory_load64_le(mem, 69664bv64) == 1912bv64); free requires (memory_load64_le(mem, 69672bv64) == 1948bv64); - free requires (memory_load8_le(mem, 2080bv64) == 1bv8); - free requires (memory_load8_le(mem, 2081bv64) == 0bv8); - free requires (memory_load8_le(mem, 2082bv64) == 2bv8); - free requires (memory_load8_le(mem, 2083bv64) == 0bv8); + free requires (memory_load32_le(mem, 2080bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1984bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69656bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69664bv64) == 1912bv64); - free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69672bv64) == 1948bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2080bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2081bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2082bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2083bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2080bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1984bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1912bv64); - free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69672bv64) == 1948bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R29_3: bool; - var Gamma_R30_5: bool; - var R29_3: bv64; - var R30_5: bv64; + var Cse0__5$3$0: bv64; + var Gamma_Cse0__5$3$0: bool; $main$__0__$w7eGi8EzQxu0kP7hQuHVUA: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R1_in); + assume {:captureState "$main$__0__$w7eGi8EzQxu0kP7hQuHVUA"} true; + Cse0__5$3$0, Gamma_Cse0__5$3$0 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$3$0, R29), gamma_store64(Gamma_stack, Cse0__5$3$0, Gamma_R29); + assume {:captureState "1984$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$3$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$3$0, 8bv64), Gamma_R30); + assume {:captureState "1984$2"} true; + R31, Gamma_R31 := Cse0__5$3$0, Gamma_Cse0__5$3$0; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1992$0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "1996$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + call rely(); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + R30, Gamma_R30 := 2016bv64, true; call add_two(); goto $main$__1__$GHoZzu8MSj2vNAxUUuG_yw; $main$__1__$GHoZzu8MSj2vNAxUUuG_yw: + assume {:captureState "$main$__1__$GHoZzu8MSj2vNAxUUuG_yw"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + call rely(); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 8bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 8bv64)) || L(mem, bvadd64(R0, 8bv64))); + R30, Gamma_R30 := 2016bv64, true; call add_six(); goto $main$__2__$ZuhsVpJtT7GuDYpY3MOTrg; $main$__2__$ZuhsVpJtT7GuDYpY3MOTrg: + assume {:captureState "$main$__2__$ZuhsVpJtT7GuDYpY3MOTrg"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + call rely(); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 16bv64)) || L(mem, bvadd64(R0, 16bv64))); + R30, Gamma_R30 := 2016bv64, true; call sub_seven(); goto $main$__3__$pfScaWraQ9qCs0VAc_LK4w; $main$__3__$pfScaWraQ9qCs0VAc_LK4w: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - R30_5, Gamma_R30_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "$main$__3__$pfScaWraQ9qCs0VAc_LK4w"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_in, R29_3, R30_5, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_in, Gamma_R29_3, Gamma_R30_5, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/jumptable2/gcc_O2/jumptable2_gtirb.expected b/src/test/correct/jumptable2/gcc_O2/jumptable2_gtirb.expected index c00443177..f0ab465db 100644 --- a/src/test/correct/jumptable2/gcc_O2/jumptable2_gtirb.expected +++ b/src/test/correct/jumptable2/gcc_O2/jumptable2_gtirb.expected @@ -1,5 +1,17 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R19: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R19: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -8,26 +20,12 @@ const {:extern} $jump_table_addr: bv64; axiom ($jump_table_addr == 69656bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69648bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -37,15 +35,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -56,38 +50,32 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2040bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2041bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2042bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2043bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2040bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69016bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69024bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1600bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1952bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1972bv64); - free ensures (memory_load64_le(mem, 69024bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69672bv64) == 2000bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -101,195 +89,193 @@ procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure add_two(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2040bv64) == 1bv8); - free requires (memory_load8_le(mem, 2041bv64) == 0bv8); - free requires (memory_load8_le(mem, 2042bv64) == 2bv8); - free requires (memory_load8_le(mem, 2043bv64) == 0bv8); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2040bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69016bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69024bv64) == 1856bv64); free requires (memory_load64_le(mem, 69616bv64) == 1600bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69656bv64) == 1952bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1936bv64); free requires (memory_load64_le(mem, 69664bv64) == 1972bv64); - free requires (memory_load64_le(mem, 69024bv64) == 1856bv64); free requires (memory_load64_le(mem, 69672bv64) == 2000bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2040bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2041bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2042bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2043bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2040bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69016bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69024bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1600bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1952bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1972bv64); - free ensures (memory_load64_le(mem, 69024bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69672bv64) == 2000bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); implementation add_two() { - var Gamma_R0_1: bool; - var Gamma_R0_2: bool; - var R0_1: bv32; - var R0_2: bv32; $add_two$__0__$PJOnl6EiQpak9~3sAS5yAg: + assume {:captureState "$add_two$__0__$PJOnl6EiQpak9~3sAS5yAg"} true; + R1, Gamma_R1 := 69632bv64, true; call rely(); - R0_1, Gamma_R0_1 := memory_load32_le(mem, 69648bv64), (gamma_load32(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - R0_2, Gamma_R0_2 := bvadd32(R0_1, 2bv32), Gamma_R0_1; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 2bv32)), Gamma_R0; call rely(); - assert (L(mem, 69648bv64) ==> Gamma_R0_2); - mem, Gamma_mem := memory_store32_le(mem, 69648bv64, R0_2), gamma_store32(Gamma_mem, 69648bv64, Gamma_R0_2); + assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "1964$0"} true; goto add_two_basil_return; add_two_basil_return: + assume {:captureState "add_two_basil_return"} true; return; } -procedure main(R19_in: bv64, Gamma_R19_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R19, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R19, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69648bv64) == 5bv64); free requires (memory_load64_le(mem, 69656bv64) == 1952bv64); free requires (memory_load64_le(mem, 69664bv64) == 1972bv64); free requires (memory_load64_le(mem, 69672bv64) == 2000bv64); - free requires (memory_load8_le(mem, 2040bv64) == 1bv8); - free requires (memory_load8_le(mem, 2041bv64) == 0bv8); - free requires (memory_load8_le(mem, 2042bv64) == 2bv8); - free requires (memory_load8_le(mem, 2043bv64) == 0bv8); + free requires (memory_load32_le(mem, 2040bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69016bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69024bv64) == 1856bv64); free requires (memory_load64_le(mem, 69616bv64) == 1600bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69656bv64) == 1952bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1936bv64); free requires (memory_load64_le(mem, 69664bv64) == 1972bv64); - free requires (memory_load64_le(mem, 69024bv64) == 1856bv64); free requires (memory_load64_le(mem, 69672bv64) == 2000bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2040bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2041bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2042bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2043bv64) == 0bv8); + free ensures (Gamma_R19 == old(Gamma_R19)); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R19 == old(R19)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2040bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69016bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69024bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1600bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1952bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1972bv64); - free ensures (memory_load64_le(mem, 69024bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69672bv64) == 2000bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R19_in: bv64, Gamma_R19_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R1: bool; - var Gamma_R19_3: bool; - var Gamma_R29_3: bool; - var Gamma_R30_5: bool; - var R1: bv64; - var R19_3: bv64; - var R29_3: bv64; - var R30_5: bv64; + var Cse0__5$2$0: bv64; + var Gamma_Cse0__5$2$0: bool; $main$__0__$qxn5kvI1Qb20o759oZW7og: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R19_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R19_in); + assume {:captureState "$main$__0__$qxn5kvI1Qb20o759oZW7og"} true; + Cse0__5$2$0, Gamma_Cse0__5$2$0 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$2$0, R29), gamma_store64(Gamma_stack, Cse0__5$2$0, Gamma_R29); + assume {:captureState "1600$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$2$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$2$0, 8bv64), Gamma_R30); + assume {:captureState "1600$2"} true; + R31, Gamma_R31 := Cse0__5$2$0, Gamma_Cse0__5$2$0; + R0, Gamma_R0 := 69632bv64, true; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R19), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R19); + assume {:captureState "1612$0"} true; + R19, Gamma_R19 := bvadd64(R0, 24bv64), Gamma_R0; + call rely(); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 24bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 24bv64)) || L(mem, bvadd64(R0, 24bv64))); + R30, Gamma_R30 := 1628bv64, true; call add_two(); goto $main$__1__$QY_U0Yl6SpejbEOj4iwjmA; $main$__1__$QY_U0Yl6SpejbEOj4iwjmA: + assume {:captureState "$main$__1__$QY_U0Yl6SpejbEOj4iwjmA"} true; + call rely(); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R19, 8bv64)), (gamma_load64(Gamma_mem, bvadd64(R19, 8bv64)) || L(mem, bvadd64(R19, 8bv64))); + R30, Gamma_R30 := 1628bv64, true; call add_six(); goto $main$__2__$FEo8kCy_S~yuUaueq991zg; $main$__2__$FEo8kCy_S~yuUaueq991zg: + assume {:captureState "$main$__2__$FEo8kCy_S~yuUaueq991zg"} true; + call rely(); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R19, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R19, 16bv64)) || L(mem, bvadd64(R19, 16bv64))); + R30, Gamma_R30 := 1628bv64, true; call sub_seven(); goto $main$__3__$b24tuus8Sm6VPGFLPjIJzQ; $main$__3__$b24tuus8Sm6VPGFLPjIJzQ: - R19_3, Gamma_R19_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - R30_5, Gamma_R30_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "$main$__3__$b24tuus8Sm6VPGFLPjIJzQ"} true; + R0, Gamma_R0 := 0bv64, true; + R19, Gamma_R19 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R19_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R19_3, R1, R29_3, R30_5, R31_in; - Gamma_R0_out, Gamma_R19_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R19_3, Gamma_R1, Gamma_R29_3, Gamma_R30_5, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } procedure sub_seven(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2040bv64) == 1bv8); - free requires (memory_load8_le(mem, 2041bv64) == 0bv8); - free requires (memory_load8_le(mem, 2042bv64) == 2bv8); - free requires (memory_load8_le(mem, 2043bv64) == 0bv8); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2040bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69016bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69024bv64) == 1856bv64); free requires (memory_load64_le(mem, 69616bv64) == 1600bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69656bv64) == 1952bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1936bv64); free requires (memory_load64_le(mem, 69664bv64) == 1972bv64); - free requires (memory_load64_le(mem, 69024bv64) == 1856bv64); free requires (memory_load64_le(mem, 69672bv64) == 2000bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2040bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2041bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2042bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2043bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2040bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69016bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69024bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1600bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1952bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1972bv64); - free ensures (memory_load64_le(mem, 69024bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69672bv64) == 2000bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); implementation sub_seven() { - var Gamma_R0_1: bool; - var Gamma_R0_2: bool; - var R0_1: bv32; - var R0_2: bv32; $sub_seven$__0__$X3yfVq36TdmZRiUe3JnW5Q: + assume {:captureState "$sub_seven$__0__$X3yfVq36TdmZRiUe3JnW5Q"} true; + R1, Gamma_R1 := 69632bv64, true; call rely(); - R0_1, Gamma_R0_1 := memory_load32_le(mem, 69648bv64), (gamma_load32(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - R0_2, Gamma_R0_2 := bvadd32(R0_1, 4294967289bv32), Gamma_R0_1; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 4294967289bv32)), Gamma_R0; call rely(); - assert (L(mem, 69648bv64) ==> Gamma_R0_2); - mem, Gamma_mem := memory_store32_le(mem, 69648bv64, R0_2), gamma_store32(Gamma_mem, 69648bv64, Gamma_R0_2); + assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "2012$0"} true; goto sub_seven_basil_return; sub_seven_basil_return: + assume {:captureState "sub_seven_basil_return"} true; return; } procedure add_six(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2040bv64) == 1bv8); - free requires (memory_load8_le(mem, 2041bv64) == 0bv8); - free requires (memory_load8_le(mem, 2042bv64) == 2bv8); - free requires (memory_load8_le(mem, 2043bv64) == 0bv8); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2040bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69016bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69024bv64) == 1856bv64); free requires (memory_load64_le(mem, 69616bv64) == 1600bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69656bv64) == 1952bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1936bv64); free requires (memory_load64_le(mem, 69664bv64) == 1972bv64); - free requires (memory_load64_le(mem, 69024bv64) == 1856bv64); free requires (memory_load64_le(mem, 69672bv64) == 2000bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2040bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2041bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2042bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2043bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2040bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69016bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69024bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1600bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1952bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1972bv64); - free ensures (memory_load64_le(mem, 69024bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69672bv64) == 2000bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); implementation add_six() { - var Gamma_R0_1: bool; - var Gamma_R0_2: bool; - var R0_1: bv32; - var R0_2: bv32; $add_six$__0__$ZqFkXi0rTbONoLjBM0hAkA: + assume {:captureState "$add_six$__0__$ZqFkXi0rTbONoLjBM0hAkA"} true; + R1, Gamma_R1 := 69632bv64, true; call rely(); - R0_1, Gamma_R0_1 := memory_load32_le(mem, 69648bv64), (gamma_load32(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - R0_2, Gamma_R0_2 := bvadd32(R0_1, 6bv32), Gamma_R0_1; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 6bv32)), Gamma_R0; call rely(); - assert (L(mem, 69648bv64) ==> Gamma_R0_2); - mem, Gamma_mem := memory_store32_le(mem, 69648bv64, R0_2), gamma_store32(Gamma_mem, 69648bv64, Gamma_R0_2); + assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "1984$0"} true; goto add_six_basil_return; add_six_basil_return: + assume {:captureState "add_six_basil_return"} true; return; } diff --git a/src/test/correct/jumptable2/gcc_pic/jumptable2_gtirb.expected b/src/test/correct/jumptable2/gcc_pic/jumptable2_gtirb.expected index 1b45657df..b5833af5e 100644 --- a/src/test/correct/jumptable2/gcc_pic/jumptable2_gtirb.expected +++ b/src/test/correct/jumptable2/gcc_pic/jumptable2_gtirb.expected @@ -1,5 +1,15 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; @@ -8,26 +18,12 @@ const {:extern} $jump_table_addr: bv64; axiom ($jump_table_addr == 69656bv64); const {:extern} $x_addr: bv64; axiom ($x_addr == 69648bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -37,15 +33,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -56,40 +48,34 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2144bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2145bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2146bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2147bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2144bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69592bv64) == 69648bv64); free ensures (memory_load64_le(mem, 69608bv64) == 2048bv64); + free ensures (memory_load64_le(mem, 69624bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1976bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); - free ensures (memory_load64_le(mem, 69624bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69592bv64) == 69648bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69672bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -103,231 +89,230 @@ procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure add_two(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2144bv64) == 1bv8); - free requires (memory_load8_le(mem, 2145bv64) == 0bv8); - free requires (memory_load8_le(mem, 2146bv64) == 2bv8); - free requires (memory_load8_le(mem, 2147bv64) == 0bv8); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2144bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69592bv64) == 69648bv64); free requires (memory_load64_le(mem, 69608bv64) == 2048bv64); + free requires (memory_load64_le(mem, 69624bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69656bv64) == 1940bv64); free requires (memory_load64_le(mem, 69664bv64) == 1976bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); - free requires (memory_load64_le(mem, 69624bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69592bv64) == 69648bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1936bv64); free requires (memory_load64_le(mem, 69672bv64) == 2012bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2144bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2145bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2146bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2147bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2144bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69592bv64) == 69648bv64); free ensures (memory_load64_le(mem, 69608bv64) == 2048bv64); + free ensures (memory_load64_le(mem, 69624bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1976bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); - free ensures (memory_load64_le(mem, 69624bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69592bv64) == 69648bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69672bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); implementation add_two() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R1_1: bool; - var R0_2: bv64; - var R0_3: bv32; - var R0_5: bv64; - var R1_1: bv32; $add_two$__0__$ACkGoC6ATEib99m8m22xRg: + assume {:captureState "$add_two$__0__$ACkGoC6ATEib99m8m22xRg"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, R0_2), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - R1_1, Gamma_R1_1 := bvadd32(R0_3, 2bv32), Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 2bv32)), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_1), gamma_store32(Gamma_mem, R0_5, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1964$0"} true; goto add_two_basil_return; add_two_basil_return: + assume {:captureState "add_two_basil_return"} true; return; } procedure sub_seven(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2144bv64) == 1bv8); - free requires (memory_load8_le(mem, 2145bv64) == 0bv8); - free requires (memory_load8_le(mem, 2146bv64) == 2bv8); - free requires (memory_load8_le(mem, 2147bv64) == 0bv8); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2144bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69592bv64) == 69648bv64); free requires (memory_load64_le(mem, 69608bv64) == 2048bv64); + free requires (memory_load64_le(mem, 69624bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69656bv64) == 1940bv64); free requires (memory_load64_le(mem, 69664bv64) == 1976bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); - free requires (memory_load64_le(mem, 69624bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69592bv64) == 69648bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1936bv64); free requires (memory_load64_le(mem, 69672bv64) == 2012bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2144bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2145bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2146bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2147bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2144bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69592bv64) == 69648bv64); free ensures (memory_load64_le(mem, 69608bv64) == 2048bv64); + free ensures (memory_load64_le(mem, 69624bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1976bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); - free ensures (memory_load64_le(mem, 69624bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69592bv64) == 69648bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69672bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); implementation sub_seven() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R1_1: bool; - var R0_2: bv64; - var R0_3: bv32; - var R0_5: bv64; - var R1_1: bv32; $sub_seven$__0__$mxkvrZFjT0OVHvaLG5jKfA: + assume {:captureState "$sub_seven$__0__$mxkvrZFjT0OVHvaLG5jKfA"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, R0_2), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - R1_1, Gamma_R1_1 := bvadd32(R0_3, 4294967289bv32), Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 4294967289bv32)), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_1), gamma_store32(Gamma_mem, R0_5, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2036$0"} true; goto sub_seven_basil_return; sub_seven_basil_return: + assume {:captureState "sub_seven_basil_return"} true; return; } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69648bv64) == 5bv64); free requires (memory_load64_le(mem, 69656bv64) == 1940bv64); free requires (memory_load64_le(mem, 69664bv64) == 1976bv64); free requires (memory_load64_le(mem, 69672bv64) == 2012bv64); - free requires (memory_load8_le(mem, 2144bv64) == 1bv8); - free requires (memory_load8_le(mem, 2145bv64) == 0bv8); - free requires (memory_load8_le(mem, 2146bv64) == 2bv8); - free requires (memory_load8_le(mem, 2147bv64) == 0bv8); + free requires (memory_load32_le(mem, 2144bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69592bv64) == 69648bv64); free requires (memory_load64_le(mem, 69608bv64) == 2048bv64); + free requires (memory_load64_le(mem, 69624bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69656bv64) == 1940bv64); free requires (memory_load64_le(mem, 69664bv64) == 1976bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); - free requires (memory_load64_le(mem, 69624bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69592bv64) == 69648bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1936bv64); free requires (memory_load64_le(mem, 69672bv64) == 2012bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2144bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2145bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2146bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2147bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2144bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69592bv64) == 69648bv64); free ensures (memory_load64_le(mem, 69608bv64) == 2048bv64); + free ensures (memory_load64_le(mem, 69624bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1976bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); - free ensures (memory_load64_le(mem, 69624bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69592bv64) == 69648bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69672bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R29_3: bool; - var Gamma_R30_5: bool; - var R29_3: bv64; - var R30_5: bv64; + var Cse0__5$2$0: bv64; + var Gamma_Cse0__5$2$0: bool; $main$__0__$WpLalhBxTN28CzXBzaW2jg: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R1_in); + assume {:captureState "$main$__0__$WpLalhBxTN28CzXBzaW2jg"} true; + Cse0__5$2$0, Gamma_Cse0__5$2$0 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$2$0, R29), gamma_store64(Gamma_stack, Cse0__5$2$0, Gamma_R29); + assume {:captureState "2048$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$2$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$2$0, 8bv64), Gamma_R30); + assume {:captureState "2048$2"} true; + R31, Gamma_R31 := Cse0__5$2$0, Gamma_Cse0__5$2$0; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "2056$0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "2060$0"} true; + R0, Gamma_R0 := 65536bv64, true; + call rely(); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4088bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4088bv64)) || L(mem, bvadd64(R0, 4088bv64))); + call rely(); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + R30, Gamma_R30 := 2080bv64, true; call add_two(); goto $main$__1__$sDnYWAohRBuHbEQ~zVQGsQ; $main$__1__$sDnYWAohRBuHbEQ~zVQGsQ: + assume {:captureState "$main$__1__$sDnYWAohRBuHbEQ~zVQGsQ"} true; + R0, Gamma_R0 := 65536bv64, true; + call rely(); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4088bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4088bv64)) || L(mem, bvadd64(R0, 4088bv64))); + call rely(); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 8bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 8bv64)) || L(mem, bvadd64(R0, 8bv64))); + R30, Gamma_R30 := 2080bv64, true; call add_six(); goto $main$__2__$L~8jkqoxTpihgr9AvP0~jA; $main$__2__$L~8jkqoxTpihgr9AvP0~jA: + assume {:captureState "$main$__2__$L~8jkqoxTpihgr9AvP0~jA"} true; + R0, Gamma_R0 := 65536bv64, true; + call rely(); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4088bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4088bv64)) || L(mem, bvadd64(R0, 4088bv64))); + call rely(); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 16bv64)) || L(mem, bvadd64(R0, 16bv64))); + R30, Gamma_R30 := 2080bv64, true; call sub_seven(); goto $main$__3__$QIGh3XotTZ6dibPcFRtsag; $main$__3__$QIGh3XotTZ6dibPcFRtsag: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - R30_5, Gamma_R30_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "$main$__3__$QIGh3XotTZ6dibPcFRtsag"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_in, R29_3, R30_5, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_in, Gamma_R29_3, Gamma_R30_5, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } procedure add_six(); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 2144bv64) == 1bv8); - free requires (memory_load8_le(mem, 2145bv64) == 0bv8); - free requires (memory_load8_le(mem, 2146bv64) == 2bv8); - free requires (memory_load8_le(mem, 2147bv64) == 0bv8); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; + free requires (memory_load32_le(mem, 2144bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1936bv64); + free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); + free requires (memory_load64_le(mem, 69592bv64) == 69648bv64); free requires (memory_load64_le(mem, 69608bv64) == 2048bv64); + free requires (memory_load64_le(mem, 69624bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69656bv64) == 1940bv64); free requires (memory_load64_le(mem, 69664bv64) == 1976bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1856bv64); - free requires (memory_load64_le(mem, 69624bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69592bv64) == 69648bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1936bv64); free requires (memory_load64_le(mem, 69672bv64) == 2012bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 2144bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2145bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2146bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2147bv64) == 0bv8); + free ensures (memory_load32_le(mem, 2144bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); + free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); + free ensures (memory_load64_le(mem, 69592bv64) == 69648bv64); free ensures (memory_load64_le(mem, 69608bv64) == 2048bv64); + free ensures (memory_load64_le(mem, 69624bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69656bv64) == 1940bv64); free ensures (memory_load64_le(mem, 69664bv64) == 1976bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1856bv64); - free ensures (memory_load64_le(mem, 69624bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69592bv64) == 69648bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69672bv64) == 2012bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); implementation add_six() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R1_1: bool; - var R0_2: bv64; - var R0_3: bv32; - var R0_5: bv64; - var R1_1: bv32; $add_six$__0__$csIZPpeWTza5lU2dTuTP6g: + assume {:captureState "$add_six$__0__$csIZPpeWTza5lU2dTuTP6g"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, R0_2), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - R1_1, Gamma_R1_1 := bvadd32(R0_3, 6bv32), Gamma_R0_3; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 6bv32)), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_1), gamma_store32(Gamma_mem, R0_5, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2000$0"} true; goto add_six_basil_return; add_six_basil_return: + assume {:captureState "add_six_basil_return"} true; return; } diff --git a/src/test/correct/malloc_with_local/clang/malloc_with_local.expected b/src/test/correct/malloc_with_local/clang/malloc_with_local.expected index de1d70a79..d54c96082 100644 --- a/src/test/correct/malloc_with_local/clang/malloc_with_local.expected +++ b/src/test/correct/malloc_with_local/clang/malloc_with_local.expected @@ -1,32 +1,32 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2256bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -40,21 +40,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -68,23 +64,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2264bv64) == 4211825664600402019bv64); free ensures (memory_load64_le(mem, 2272bv64) == 7307182754559632672bv64); @@ -100,8 +96,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -114,7 +110,7 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2264bv64) == 4211825664600402019bv64); @@ -141,8 +137,8 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69688bv64) == 0bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); free requires (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); @@ -157,6 +153,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1984bv64); free requires (memory_load64_le(mem, 69592bv64) == 2068bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2264bv64) == 4211825664600402019bv64); free ensures (memory_load64_le(mem, 2272bv64) == 7307182754559632672bv64); @@ -170,591 +170,109 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_13: bool; - var Gamma_R0_14: bool; - var Gamma_R0_15: bool; - var Gamma_R0_16: bool; - var Gamma_R0_17: bool; - var Gamma_R0_18: bool; - var Gamma_R0_2: bool; - var Gamma_R0_4: bool; - var Gamma_R0_7: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R10_2: bool; - var Gamma_R10_3: bool; - var Gamma_R10_4: bool; - var Gamma_R10_5: bool; - var Gamma_R10_6: bool; - var Gamma_R10_7: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R11_2: bool; - var Gamma_R11_3: bool; - var Gamma_R11_4: bool; - var Gamma_R11_5: bool; - var Gamma_R11_6: bool; - var Gamma_R11_7: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R12_2: bool; - var Gamma_R12_3: bool; - var Gamma_R12_4: bool; - var Gamma_R12_5: bool; - var Gamma_R12_6: bool; - var Gamma_R12_7: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R13_2: bool; - var Gamma_R13_3: bool; - var Gamma_R13_4: bool; - var Gamma_R13_5: bool; - var Gamma_R13_6: bool; - var Gamma_R13_7: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R14_2: bool; - var Gamma_R14_3: bool; - var Gamma_R14_4: bool; - var Gamma_R14_5: bool; - var Gamma_R14_6: bool; - var Gamma_R14_7: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R15_2: bool; - var Gamma_R15_3: bool; - var Gamma_R15_4: bool; - var Gamma_R15_5: bool; - var Gamma_R15_6: bool; - var Gamma_R15_7: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R16_7: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R17_7: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R18_2: bool; - var Gamma_R18_3: bool; - var Gamma_R18_4: bool; - var Gamma_R18_5: bool; - var Gamma_R18_6: bool; - var Gamma_R18_7: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R19_2: bool; - var Gamma_R19_3: bool; - var Gamma_R19_4: bool; - var Gamma_R19_5: bool; - var Gamma_R19_6: bool; - var Gamma_R19_7: bool; - var Gamma_R1_1: bool; - var Gamma_R1_10: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var Gamma_R1_6: bool; - var Gamma_R1_7: bool; - var Gamma_R1_8: bool; - var Gamma_R1_9: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R20_2: bool; - var Gamma_R20_3: bool; - var Gamma_R20_4: bool; - var Gamma_R20_5: bool; - var Gamma_R20_6: bool; - var Gamma_R20_7: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R21_2: bool; - var Gamma_R21_3: bool; - var Gamma_R21_4: bool; - var Gamma_R21_5: bool; - var Gamma_R21_6: bool; - var Gamma_R21_7: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R22_2: bool; - var Gamma_R22_3: bool; - var Gamma_R22_4: bool; - var Gamma_R22_5: bool; - var Gamma_R22_6: bool; - var Gamma_R22_7: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R23_2: bool; - var Gamma_R23_3: bool; - var Gamma_R23_4: bool; - var Gamma_R23_5: bool; - var Gamma_R23_6: bool; - var Gamma_R23_7: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R24_2: bool; - var Gamma_R24_3: bool; - var Gamma_R24_4: bool; - var Gamma_R24_5: bool; - var Gamma_R24_6: bool; - var Gamma_R24_7: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R25_2: bool; - var Gamma_R25_3: bool; - var Gamma_R25_4: bool; - var Gamma_R25_5: bool; - var Gamma_R25_6: bool; - var Gamma_R25_7: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R26_2: bool; - var Gamma_R26_3: bool; - var Gamma_R26_4: bool; - var Gamma_R26_5: bool; - var Gamma_R26_6: bool; - var Gamma_R26_7: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R27_2: bool; - var Gamma_R27_3: bool; - var Gamma_R27_4: bool; - var Gamma_R27_5: bool; - var Gamma_R27_6: bool; - var Gamma_R27_7: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R28_2: bool; - var Gamma_R28_3: bool; - var Gamma_R28_4: bool; - var Gamma_R28_5: bool; - var Gamma_R28_6: bool; - var Gamma_R28_7: bool; - var Gamma_R29_10: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R29_5: bool; - var Gamma_R29_6: bool; - var Gamma_R29_7: bool; - var Gamma_R29_8: bool; - var Gamma_R29_9: bool; - var Gamma_R2_1: bool; - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var Gamma_R2_4: bool; - var Gamma_R2_5: bool; - var Gamma_R2_6: bool; - var Gamma_R2_7: bool; - var Gamma_R3: bool; - var Gamma_R30_11: bool; - var Gamma_R30_13: bool; - var Gamma_R30_15: bool; - var Gamma_R30_16: bool; - var Gamma_R30_3: bool; - var Gamma_R30_5: bool; - var Gamma_R30_7: bool; - var Gamma_R30_9: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R31_5: bool; - var Gamma_R31_6: bool; - var Gamma_R31_7: bool; - var Gamma_R31_8: bool; - var Gamma_R31_9: bool; - var Gamma_R3_1: bool; - var Gamma_R3_2: bool; - var Gamma_R3_3: bool; - var Gamma_R3_4: bool; - var Gamma_R3_5: bool; - var Gamma_R3_6: bool; - var Gamma_R3_7: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R4_2: bool; - var Gamma_R4_3: bool; - var Gamma_R4_4: bool; - var Gamma_R4_5: bool; - var Gamma_R4_6: bool; - var Gamma_R4_7: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R5_2: bool; - var Gamma_R5_3: bool; - var Gamma_R5_4: bool; - var Gamma_R5_5: bool; - var Gamma_R5_6: bool; - var Gamma_R5_7: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R6_2: bool; - var Gamma_R6_3: bool; - var Gamma_R6_4: bool; - var Gamma_R6_5: bool; - var Gamma_R6_6: bool; - var Gamma_R6_7: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R7_2: bool; - var Gamma_R7_3: bool; - var Gamma_R7_4: bool; - var Gamma_R7_5: bool; - var Gamma_R7_6: bool; - var Gamma_R7_7: bool; - var Gamma_R8_10: bool; - var Gamma_R8_11: bool; - var Gamma_R8_12: bool; - var Gamma_R8_13: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_7: bool; - var Gamma_R8_8: bool; - var Gamma_R8_9: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var Gamma_R9_4: bool; - var Gamma_R9_5: bool; - var Gamma_R9_6: bool; - var Gamma_R9_7: bool; - var Gamma_R9_8: bool; - var Gamma_R9_9: bool; - var R0_10: bv64; - var R0_13: bv64; - var R0_14: bv64; - var R0_15: bv64; - var R0_16: bv64; - var R0_17: bv64; - var R0_18: bv64; - var R0_2: bv64; - var R0_4: bv64; - var R0_7: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R10_2: bv64; - var R10_3: bv64; - var R10_4: bv64; - var R10_5: bv64; - var R10_6: bv64; - var R10_7: bv64; - var R11: bv64; - var R11_1: bv64; - var R11_2: bv64; - var R11_3: bv64; - var R11_4: bv64; - var R11_5: bv64; - var R11_6: bv64; - var R11_7: bv64; - var R12: bv64; - var R12_1: bv64; - var R12_2: bv64; - var R12_3: bv64; - var R12_4: bv64; - var R12_5: bv64; - var R12_6: bv64; - var R12_7: bv64; - var R13: bv64; - var R13_1: bv64; - var R13_2: bv64; - var R13_3: bv64; - var R13_4: bv64; - var R13_5: bv64; - var R13_6: bv64; - var R13_7: bv64; - var R14: bv64; - var R14_1: bv64; - var R14_2: bv64; - var R14_3: bv64; - var R14_4: bv64; - var R14_5: bv64; - var R14_6: bv64; - var R14_7: bv64; - var R15: bv64; - var R15_1: bv64; - var R15_2: bv64; - var R15_3: bv64; - var R15_4: bv64; - var R15_5: bv64; - var R15_6: bv64; - var R15_7: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R16_7: bv64; - var R17: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R17_7: bv64; - var R18: bv64; - var R18_1: bv64; - var R18_2: bv64; - var R18_3: bv64; - var R18_4: bv64; - var R18_5: bv64; - var R18_6: bv64; - var R18_7: bv64; - var R19: bv64; - var R19_1: bv64; - var R19_2: bv64; - var R19_3: bv64; - var R19_4: bv64; - var R19_5: bv64; - var R19_6: bv64; - var R19_7: bv64; - var R1_1: bv64; - var R1_10: bv64; - var R1_2: bv64; - var R1_3: bv64; - var R1_4: bv64; - var R1_5: bv64; - var R1_6: bv64; - var R1_7: bv64; - var R1_8: bv64; - var R1_9: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R20_2: bv64; - var R20_3: bv64; - var R20_4: bv64; - var R20_5: bv64; - var R20_6: bv64; - var R20_7: bv64; - var R21: bv64; - var R21_1: bv64; - var R21_2: bv64; - var R21_3: bv64; - var R21_4: bv64; - var R21_5: bv64; - var R21_6: bv64; - var R21_7: bv64; - var R22: bv64; - var R22_1: bv64; - var R22_2: bv64; - var R22_3: bv64; - var R22_4: bv64; - var R22_5: bv64; - var R22_6: bv64; - var R22_7: bv64; - var R23: bv64; - var R23_1: bv64; - var R23_2: bv64; - var R23_3: bv64; - var R23_4: bv64; - var R23_5: bv64; - var R23_6: bv64; - var R23_7: bv64; - var R24: bv64; - var R24_1: bv64; - var R24_2: bv64; - var R24_3: bv64; - var R24_4: bv64; - var R24_5: bv64; - var R24_6: bv64; - var R24_7: bv64; - var R25: bv64; - var R25_1: bv64; - var R25_2: bv64; - var R25_3: bv64; - var R25_4: bv64; - var R25_5: bv64; - var R25_6: bv64; - var R25_7: bv64; - var R26: bv64; - var R26_1: bv64; - var R26_2: bv64; - var R26_3: bv64; - var R26_4: bv64; - var R26_5: bv64; - var R26_6: bv64; - var R26_7: bv64; - var R27: bv64; - var R27_1: bv64; - var R27_2: bv64; - var R27_3: bv64; - var R27_4: bv64; - var R27_5: bv64; - var R27_6: bv64; - var R27_7: bv64; - var R28: bv64; - var R28_1: bv64; - var R28_2: bv64; - var R28_3: bv64; - var R28_4: bv64; - var R28_5: bv64; - var R28_6: bv64; - var R28_7: bv64; - var R29_10: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R29_5: bv64; - var R29_6: bv64; - var R29_7: bv64; - var R29_8: bv64; - var R29_9: bv64; - var R2_1: bv64; - var R2_2: bv64; - var R2_3: bv64; - var R2_4: bv64; - var R2_5: bv64; - var R2_6: bv64; - var R2_7: bv64; - var R3: bv64; - var R30_11: bv64; - var R30_13: bv64; - var R30_15: bv64; - var R30_16: bv64; - var R30_3: bv64; - var R30_5: bv64; - var R30_7: bv64; - var R30_9: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R31_5: bv64; - var R31_6: bv64; - var R31_7: bv64; - var R31_8: bv64; - var R31_9: bv64; - var R3_1: bv64; - var R3_2: bv64; - var R3_3: bv64; - var R3_4: bv64; - var R3_5: bv64; - var R3_6: bv64; - var R3_7: bv64; - var R4: bv64; - var R4_1: bv64; - var R4_2: bv64; - var R4_3: bv64; - var R4_4: bv64; - var R4_5: bv64; - var R4_6: bv64; - var R4_7: bv64; - var R5: bv64; - var R5_1: bv64; - var R5_2: bv64; - var R5_3: bv64; - var R5_4: bv64; - var R5_5: bv64; - var R5_6: bv64; - var R5_7: bv64; - var R6: bv64; - var R6_1: bv64; - var R6_2: bv64; - var R6_3: bv64; - var R6_4: bv64; - var R6_5: bv64; - var R6_6: bv64; - var R6_7: bv64; - var R7: bv64; - var R7_1: bv64; - var R7_2: bv64; - var R7_3: bv64; - var R7_4: bv64; - var R7_5: bv64; - var R7_6: bv64; - var R7_7: bv64; - var R8_10: bv64; - var R8_11: bv64; - var R8_12: bv64; - var R8_13: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R8_7: bv64; - var R8_8: bv64; - var R8_9: bv64; - var R9: bv64; - var R9_1: bv64; - var R9_2: bv64; - var R9_3: bv64; - var R9_4: bv64; - var R9_5: bv64; - var R9_6: bv64; - var R9_7: bv64; - var R9_8: bv64; - var R9_9: bv64; + var #4: bv64; + var #5: bv64; + var Gamma_#4: bool; + var Gamma_#5: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551568bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_2, Gamma_R8_2, R9_1, Gamma_R9_1 := malloc(1bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, R2, Gamma_R2, 2100bv64, true, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, 0bv64, true, R9, Gamma_R9); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + #4, Gamma_#4 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000362"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000368"} true; + R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; + R8, Gamma_R8 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, R31, R8[32:0]), gamma_store32(Gamma_stack, R31, Gamma_R8); + assume {:captureState "%0000037b"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%00000382"} true; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2100bv64, true; + call malloc(); goto l00000391; l00000391: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_3, 16bv64), R0_2), gamma_store64(Gamma_stack, bvadd64(R31_3, 16bv64), Gamma_R0_2); - call R0_4, Gamma_R0_4, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_2, Gamma_R1_2, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, R30_5, Gamma_R30_5, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_3, Gamma_R8_3, R9_2, Gamma_R9_2 := malloc(4bv64, true, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, 2112bv64, true, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_2, Gamma_R8_2, R9_1, Gamma_R9_1); + assume {:captureState "l00000391"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000397"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2112bv64, true; + call malloc(); goto l000003a5; l000003a5: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_4, 8bv64), R0_4), gamma_store64(Gamma_stack, bvadd64(R31_4, 8bv64), Gamma_R0_4); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_4, 4bv64), 10bv32), gamma_store32(Gamma_stack, bvadd64(R31_4, 4bv64), true); - R9_3, Gamma_R9_3 := memory_load64_le(stack, bvadd64(R31_4, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 16bv64)); + assume {:captureState "l000003a5"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%000003ab"} true; + R8, Gamma_R8 := 10bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%000003b8"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R8, Gamma_R8 := 65bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R9_3, 65bv8), gamma_store8(Gamma_mem, R9_3, true); - R9_4, Gamma_R9_4 := memory_load64_le(stack, bvadd64(R31_4, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 8bv64)); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000003cc"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R8, Gamma_R8 := 42bv64, true; call rely(); - assert (L(mem, R9_4) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_4, 42bv32), gamma_store32(Gamma_mem, R9_4, true); - R8_7, Gamma_R8_7 := memory_load64_le(stack, bvadd64(R31_4, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 16bv64)); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000003e0"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); call rely(); - R1_3, Gamma_R1_3 := zero_extend56_8(memory_load8_le(mem, R8_7)), (gamma_load8(Gamma_mem, R8_7) || L(mem, R8_7)); - call R0_7, Gamma_R0_7, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_4, Gamma_R1_4, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, R30_7, Gamma_R30_7, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_8, Gamma_R8_8, R9_5, Gamma_R9_5 := printf(2260bv64, true, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_3, Gamma_R1_3, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, 2168bv64, true, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_7, Gamma_R8_7, R9_4, Gamma_R9_4); + R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2260bv64), Gamma_R0; + R30, Gamma_R30 := 2168bv64, true; + call printf(); goto l00000403; l00000403: - R8_9, Gamma_R8_9 := memory_load64_le(stack, bvadd64(R31_5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 8bv64)); + assume {:captureState "l00000403"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - R1_5, Gamma_R1_5 := zero_extend32_32(memory_load32_le(mem, R8_9)), (gamma_load32(Gamma_mem, R8_9) || L(mem, R8_9)); - call R0_10, Gamma_R0_10, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_6, Gamma_R1_6, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, R30_9, Gamma_R30_9, R31_6, Gamma_R31_6, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_10, Gamma_R8_10, R9_6, Gamma_R9_6 := printf(2277bv64, true, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_5, Gamma_R1_5, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, 2188bv64, true, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_9, Gamma_R8_9, R9_5, Gamma_R9_5); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2277bv64), Gamma_R0; + R30, Gamma_R30 := 2188bv64, true; + call printf(); goto l00000423; l00000423: - R1_7, Gamma_R1_7 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_6, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31_6, 4bv64)); - call R0_13, Gamma_R0_13, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_8, Gamma_R1_8, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, R30_11, Gamma_R30_11, R31_7, Gamma_R31_7, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_11, Gamma_R8_11, R9_7, Gamma_R9_7 := printf(2293bv64, true, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_7, Gamma_R1_7, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, 2204bv64, true, R31_6, Gamma_R31_6, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_10, Gamma_R8_10, R9_6, Gamma_R9_6); + assume {:captureState "l00000423"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2293bv64), Gamma_R0; + R30, Gamma_R30 := 2204bv64, true; + call printf(); goto l0000043c; l0000043c: - R0_14, Gamma_R0_14 := memory_load64_le(stack, bvadd64(R31_7, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_7, 16bv64)); - call R0_15, Gamma_R0_15, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_9, Gamma_R1_9, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_8, Gamma_R29_8, R2_6, Gamma_R2_6, R30_13, Gamma_R30_13, R31_8, Gamma_R31_8, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_12, Gamma_R8_12, R9_8, Gamma_R9_8 := #free(R0_14, Gamma_R0_14, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_8, Gamma_R1_8, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, 2212bv64, true, R31_7, Gamma_R31_7, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_11, Gamma_R8_11, R9_7, Gamma_R9_7); + assume {:captureState "l0000043c"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R30, Gamma_R30 := 2212bv64, true; + call #free(); goto l0000044b; l0000044b: - R0_16, Gamma_R0_16 := memory_load64_le(stack, bvadd64(R31_8, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_8, 8bv64)); - call R0_17, Gamma_R0_17, R10_7, Gamma_R10_7, R11_7, Gamma_R11_7, R12_7, Gamma_R12_7, R13_7, Gamma_R13_7, R14_7, Gamma_R14_7, R15_7, Gamma_R15_7, R16_7, Gamma_R16_7, R17_7, Gamma_R17_7, R18_7, Gamma_R18_7, R19_7, Gamma_R19_7, R1_10, Gamma_R1_10, R20_7, Gamma_R20_7, R21_7, Gamma_R21_7, R22_7, Gamma_R22_7, R23_7, Gamma_R23_7, R24_7, Gamma_R24_7, R25_7, Gamma_R25_7, R26_7, Gamma_R26_7, R27_7, Gamma_R27_7, R28_7, Gamma_R28_7, R29_9, Gamma_R29_9, R2_7, Gamma_R2_7, R30_15, Gamma_R30_15, R31_9, Gamma_R31_9, R3_7, Gamma_R3_7, R4_7, Gamma_R4_7, R5_7, Gamma_R5_7, R6_7, Gamma_R6_7, R7_7, Gamma_R7_7, R8_13, Gamma_R8_13, R9_9, Gamma_R9_9 := #free(R0_16, Gamma_R0_16, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_9, Gamma_R1_9, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_8, Gamma_R29_8, R2_6, Gamma_R2_6, 2220bv64, true, R31_8, Gamma_R31_8, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_12, Gamma_R8_12, R9_8, Gamma_R9_8); + assume {:captureState "l0000044b"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R30, Gamma_R30 := 2220bv64, true; + call #free(); goto l00000459; l00000459: - R0_18, Gamma_R0_18 := zero_extend32_32(memory_load32_le(stack, R31_9)), gamma_load32(Gamma_stack, R31_9); - R29_10, Gamma_R29_10 := memory_load64_le(stack, bvadd64(R31_9, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_9, 32bv64)); - R30_16, Gamma_R30_16 := memory_load64_le(stack, bvadd64(R31_9, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_9, 40bv64)); + assume {:captureState "l00000459"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, R31)), gamma_load32(Gamma_stack, R31); + #5, Gamma_#5 := bvadd64(R31, 32bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#5, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out, R8_out, R9_out := R0_18, R1_10, R29_10, R30_16, bvadd64(R31_9, 48bv64), R8_13, R9_9; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_18, Gamma_R1_10, Gamma_R29_10, Gamma_R30_16, Gamma_R31_9, Gamma_R8_13, Gamma_R9_9; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2264bv64) == 4211825664600402019bv64); @@ -781,7 +299,7 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2264bv64) == 4211825664600402019bv64); diff --git a/src/test/correct/malloc_with_local/clang/malloc_with_local_gtirb.expected b/src/test/correct/malloc_with_local/clang/malloc_with_local_gtirb.expected index 40542b0fb..6793f6257 100644 --- a/src/test/correct/malloc_with_local/clang/malloc_with_local_gtirb.expected +++ b/src/test/correct/malloc_with_local/clang/malloc_with_local_gtirb.expected @@ -1,28 +1,32 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2256bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -31,22 +35,22 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { + gammaMap[index] +} + function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -55,23 +59,28 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { + memory[index] +} + function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2264bv64) == 4211825664600402019bv64); free ensures (memory_load64_le(mem, 2272bv64) == 7307182754559632672bv64); @@ -87,8 +96,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -101,8 +110,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_680(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2264bv64) == 4211825664600402019bv64); free requires (memory_load64_le(mem, 2272bv64) == 7307182754559632672bv64); @@ -128,143 +137,20 @@ procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_680() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_680$__0__$9vdUBrbQSwiaJeVuom5EvQ: + assume {:captureState "$FUN_680$__0__$9vdUBrbQSwiaJeVuom5EvQ"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69648bv64), (gamma_load64(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69648bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 16bv64)) || L(mem, bvadd64(R16, 16bv64))); + R16, Gamma_R16 := bvadd64(R16, 16bv64), Gamma_R16; + call malloc(); assume false; } -procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6b0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2264bv64) == 4211825664600402019bv64); free requires (memory_load64_le(mem, 2272bv64) == 7307182754559632672bv64); @@ -290,143 +176,20 @@ procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6b0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6b0$__0__$8CgJ347mTAagL8N803gTlQ: + assume {:captureState "$FUN_6b0$__0__$8CgJ347mTAagL8N803gTlQ"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69672bv64), (gamma_load64(Gamma_mem, 69672bv64) || L(mem, 69672bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := #free(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69672bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 40bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 40bv64)) || L(mem, bvadd64(R16, 40bv64))); + R16, Gamma_R16 := bvadd64(R16, 40bv64), Gamma_R16; + call #free(); assume false; } -procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6c0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2264bv64) == 4211825664600402019bv64); free requires (memory_load64_le(mem, 2272bv64) == 7307182754559632672bv64); @@ -452,143 +215,20 @@ procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6c0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6c0$__0__$4WlH9L7ETgacwvseUfY3jw: + assume {:captureState "$FUN_6c0$__0__$4WlH9L7ETgacwvseUfY3jw"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69680bv64), (gamma_load64(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69680bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 48bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 48bv64)) || L(mem, bvadd64(R16, 48bv64))); + R16, Gamma_R16 := bvadd64(R16, 48bv64), Gamma_R16; + call printf(); assume false; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69688bv64) == 0bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); free requires (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); @@ -603,6 +243,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1984bv64); free requires (memory_load64_le(mem, 69592bv64) == 2068bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2264bv64) == 4211825664600402019bv64); free ensures (memory_load64_le(mem, 2272bv64) == 7307182754559632672bv64); @@ -616,102 +260,109 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_11: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R16_7: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R17_7: bool; - var Gamma_R1_3: bool; - var Gamma_R29_3: bool; - var Gamma_R30_9: bool; - var Gamma_R8_6: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var R0_11: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R16_7: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R17_7: bv64; - var R1_3: bv64; - var R29_3: bv64; - var R30_9: bv64; - var R8_6: bv64; - var R9_1: bv64; - var R9_2: bv64; + var Cse0__5$2$1: bv64; + var Cse0__5$3$1: bv64; + var Gamma_Cse0__5$2$1: bool; + var Gamma_Cse0__5$3$1: bool; $main$__0__$uE7qCv5XQSaoZC2XHmZwIA: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551568bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_680(R16, Gamma_R16); + assume {:captureState "$main$__0__$uE7qCv5XQSaoZC2XHmZwIA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + Cse0__5$3$1, Gamma_Cse0__5$3$1 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$3$1, R29), gamma_store64(Gamma_stack, Cse0__5$3$1, Gamma_R29); + assume {:captureState "2072$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$3$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$3$1, 8bv64), Gamma_R30); + assume {:captureState "2072$2"} true; + R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; + R8, Gamma_R8 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, R31, R8[32:0]), gamma_store32(Gamma_stack, R31, Gamma_R8); + assume {:captureState "2084$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "2088$0"} true; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2100bv64, true; + call FUN_680(); goto $main$__1__$dgj~vxjdRmWAIHXijPkJIw; $main$__1__$dgj~vxjdRmWAIHXijPkJIw: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), 1bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), true); - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := FUN_680(R16_1, Gamma_R16_1); + assume {:captureState "$main$__1__$dgj~vxjdRmWAIHXijPkJIw"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "2100$0"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2112bv64, true; + call FUN_680(); goto $main$__2__$AbMdt8szSHac6Me44gUD3g; $main$__2__$AbMdt8szSHac6Me44gUD3g: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551576bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551572bv64), 10bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551572bv64), true); - R9_1, Gamma_R9_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); + assume {:captureState "$main$__2__$AbMdt8szSHac6Me44gUD3g"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "2112$0"} true; + R8, Gamma_R8 := 10bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "2120$0"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R8, Gamma_R8 := 65bv64, true; call rely(); - assert (L(mem, R9_1) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R9_1, 65bv8), gamma_store8(Gamma_mem, R9_1, true); - R9_2, Gamma_R9_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551576bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64)); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "2132$0"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R8, Gamma_R8 := 42bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 42bv32), gamma_store32(Gamma_mem, R9_2, true); - call R16_3, Gamma_R16_3, R17_3, Gamma_R17_3 := FUN_6c0(R16_2, Gamma_R16_2); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "2144$0"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + call rely(); + R1, Gamma_R1 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R8))), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2260bv64), Gamma_R0; + R30, Gamma_R30 := 2168bv64, true; + call FUN_6c0(); goto $main$__3__$YiNkuzyxSAi8ch4~JRnQRw; $main$__3__$YiNkuzyxSAi8ch4~JRnQRw: - R8_6, Gamma_R8_6 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551576bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64)); - call R16_4, Gamma_R16_4, R17_4, Gamma_R17_4 := FUN_6c0(R16_3, Gamma_R16_3); + assume {:captureState "$main$__3__$YiNkuzyxSAi8ch4~JRnQRw"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + call rely(); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2277bv64), Gamma_R0; + R30, Gamma_R30 := 2188bv64, true; + call FUN_6c0(); goto $main$__4__$sePoi2e_Tqq7bHfBWVfW5g; $main$__4__$sePoi2e_Tqq7bHfBWVfW5g: - R1_3, Gamma_R1_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551572bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551572bv64)); - call R16_5, Gamma_R16_5, R17_5, Gamma_R17_5 := FUN_6c0(R16_4, Gamma_R16_4); + assume {:captureState "$main$__4__$sePoi2e_Tqq7bHfBWVfW5g"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2293bv64), Gamma_R0; + R30, Gamma_R30 := 2204bv64, true; + call FUN_6c0(); goto $main$__5__$J4PaOyLLQDaFhYWMa4o2Xw; $main$__5__$J4PaOyLLQDaFhYWMa4o2Xw: - call R16_6, Gamma_R16_6, R17_6, Gamma_R17_6 := FUN_6b0(R16_5, Gamma_R16_5); + assume {:captureState "$main$__5__$J4PaOyLLQDaFhYWMa4o2Xw"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R30, Gamma_R30 := 2212bv64, true; + call FUN_6b0(); goto $main$__6__$r9k1rsQ0R9i49NDTDexoJg; $main$__6__$r9k1rsQ0R9i49NDTDexoJg: - call R16_7, Gamma_R16_7, R17_7, Gamma_R17_7 := FUN_6b0(R16_6, Gamma_R16_6); + assume {:captureState "$main$__6__$r9k1rsQ0R9i49NDTDexoJg"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R30, Gamma_R30 := 2220bv64, true; + call FUN_6b0(); goto $main$__7__$2lSrma4tR0KhXTbZ8h2uhw; $main$__7__$2lSrma4tR0KhXTbZ8h2uhw: - R0_11, Gamma_R0_11 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551568bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64)); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_9, Gamma_R30_9 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__7__$2lSrma4tR0KhXTbZ8h2uhw"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, R31)), gamma_load32(Gamma_stack, R31); + Cse0__5$2$1, Gamma_Cse0__5$2$1 := bvadd64(R31, 32bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$2$1), gamma_load64(Gamma_stack, Cse0__5$2$1); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$2$1, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$2$1, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R1_out, R29_out, R30_out, R31_out, R8_out, R9_out := R0_11, R16_7, R17_7, R1_3, R29_3, R30_9, R31_in, R8_6, R9_2; - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_11, Gamma_R16_7, Gamma_R17_7, Gamma_R1_3, Gamma_R29_3, Gamma_R30_9, Gamma_R31_in, Gamma_R8_6, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); free requires (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2264bv64) == 4211825664600402019bv64); free requires (memory_load64_le(mem, 2272bv64) == 7307182754559632672bv64); @@ -737,7 +388,7 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); free requires (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2264bv64) == 4211825664600402019bv64); free requires (memory_load64_le(mem, 2272bv64) == 7307182754559632672bv64); @@ -763,7 +414,7 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load64_le(mem, 2256bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2264bv64) == 4211825664600402019bv64); free requires (memory_load64_le(mem, 2272bv64) == 7307182754559632672bv64); diff --git a/src/test/correct/malloc_with_local/clang_O2/malloc_with_local.expected b/src/test/correct/malloc_with_local/clang_O2/malloc_with_local.expected index df587f2be..ac16f7d10 100644 --- a/src/test/correct/malloc_with_local/clang_O2/malloc_with_local.expected +++ b/src/test/correct/malloc_with_local/clang_O2/malloc_with_local.expected @@ -1,33 +1,30 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1964bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { @@ -39,13 +36,13 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); @@ -68,8 +65,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -82,8 +79,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_stack, R16, R17, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, stack; free requires (memory_load64_le(mem, 69672bv64) == 0bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free requires (memory_load8_le(mem, 1964bv64) == 1bv8); @@ -105,6 +102,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); @@ -125,280 +126,54 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_6: bool; - var Gamma_R0_9: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R10_2: bool; - var Gamma_R10_3: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R11_2: bool; - var Gamma_R11_3: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R12_2: bool; - var Gamma_R12_3: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R13_2: bool; - var Gamma_R13_3: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R14_2: bool; - var Gamma_R14_3: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R15_2: bool; - var Gamma_R15_3: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R18_2: bool; - var Gamma_R18_3: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R19_2: bool; - var Gamma_R19_3: bool; - var Gamma_R1_2: bool; - var Gamma_R1_4: bool; - var Gamma_R1_6: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R20_2: bool; - var Gamma_R20_3: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R21_2: bool; - var Gamma_R21_3: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R22_2: bool; - var Gamma_R22_3: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R23_2: bool; - var Gamma_R23_3: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R24_2: bool; - var Gamma_R24_3: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R25_2: bool; - var Gamma_R25_3: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R26_2: bool; - var Gamma_R26_3: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R27_2: bool; - var Gamma_R27_3: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R28_2: bool; - var Gamma_R28_3: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R29_5: bool; - var Gamma_R29_6: bool; - var Gamma_R2_1: bool; - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var Gamma_R3: bool; - var Gamma_R30_3: bool; - var Gamma_R30_5: bool; - var Gamma_R30_7: bool; - var Gamma_R30_8: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R31_5: bool; - var Gamma_R3_1: bool; - var Gamma_R3_2: bool; - var Gamma_R3_3: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R4_2: bool; - var Gamma_R4_3: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R5_2: bool; - var Gamma_R5_3: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R6_2: bool; - var Gamma_R6_3: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R7_2: bool; - var Gamma_R7_3: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var R0_3: bv64; - var R0_6: bv64; - var R0_9: bv64; - var R10: bv64; - var R10_1: bv64; - var R10_2: bv64; - var R10_3: bv64; - var R11: bv64; - var R11_1: bv64; - var R11_2: bv64; - var R11_3: bv64; - var R12: bv64; - var R12_1: bv64; - var R12_2: bv64; - var R12_3: bv64; - var R13: bv64; - var R13_1: bv64; - var R13_2: bv64; - var R13_3: bv64; - var R14: bv64; - var R14_1: bv64; - var R14_2: bv64; - var R14_3: bv64; - var R15: bv64; - var R15_1: bv64; - var R15_2: bv64; - var R15_3: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R17: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R18: bv64; - var R18_1: bv64; - var R18_2: bv64; - var R18_3: bv64; - var R19: bv64; - var R19_1: bv64; - var R19_2: bv64; - var R19_3: bv64; - var R1_2: bv64; - var R1_4: bv64; - var R1_6: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R20_2: bv64; - var R20_3: bv64; - var R21: bv64; - var R21_1: bv64; - var R21_2: bv64; - var R21_3: bv64; - var R22: bv64; - var R22_1: bv64; - var R22_2: bv64; - var R22_3: bv64; - var R23: bv64; - var R23_1: bv64; - var R23_2: bv64; - var R23_3: bv64; - var R24: bv64; - var R24_1: bv64; - var R24_2: bv64; - var R24_3: bv64; - var R25: bv64; - var R25_1: bv64; - var R25_2: bv64; - var R25_3: bv64; - var R26: bv64; - var R26_1: bv64; - var R26_2: bv64; - var R26_3: bv64; - var R27: bv64; - var R27_1: bv64; - var R27_2: bv64; - var R27_3: bv64; - var R28: bv64; - var R28_1: bv64; - var R28_2: bv64; - var R28_3: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R29_5: bv64; - var R29_6: bv64; - var R2_1: bv64; - var R2_2: bv64; - var R2_3: bv64; - var R3: bv64; - var R30_3: bv64; - var R30_5: bv64; - var R30_7: bv64; - var R30_8: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R31_5: bv64; - var R3_1: bv64; - var R3_2: bv64; - var R3_3: bv64; - var R4: bv64; - var R4_1: bv64; - var R4_2: bv64; - var R4_3: bv64; - var R5: bv64; - var R5_1: bv64; - var R5_2: bv64; - var R5_3: bv64; - var R6: bv64; - var R6_1: bv64; - var R6_2: bv64; - var R6_3: bv64; - var R7: bv64; - var R7_1: bv64; - var R7_2: bv64; - var R7_3: bv64; - var R8: bv64; - var R8_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R9: bv64; - var R9_1: bv64; - var R9_2: bv64; - var R9_3: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - call R0_3, Gamma_R0_3, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_2, Gamma_R1_2, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(1968bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, 65bv64, true, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, R2, Gamma_R2, 1900bv64, true, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002f8"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002fe"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 1968bv64), Gamma_R0; + R1, Gamma_R1 := 65bv64, true; + R30, Gamma_R30 := 1900bv64, true; + call printf(); goto l00000322; l00000322: - call R0_6, Gamma_R0_6, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_4, Gamma_R1_4, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, R30_5, Gamma_R30_5, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2 := printf(1985bv64, true, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, 42bv64, true, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, 1916bv64, true, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1); + assume {:captureState "l00000322"} true; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 1985bv64), Gamma_R0; + R1, Gamma_R1 := 42bv64, true; + R30, Gamma_R30 := 1916bv64, true; + call printf(); goto l00000339; l00000339: - call R0_9, Gamma_R0_9, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_6, Gamma_R1_6, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, R30_7, Gamma_R30_7, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_3, Gamma_R8_3, R9_3, Gamma_R9_3 := printf(2001bv64, true, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, 10bv64, true, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, 1932bv64, true, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2); + assume {:captureState "l00000339"} true; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2001bv64), Gamma_R0; + R1, Gamma_R1 := 10bv64, true; + R30, Gamma_R30 := 1932bv64, true; + call printf(); goto l00000350; l00000350: - R29_6, Gamma_R29_6 := memory_load64_le(stack, R31_5), gamma_load64(Gamma_stack, R31_5); - R30_8, Gamma_R30_8 := memory_load64_le(stack, bvadd64(R31_5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 8bv64)); + assume {:captureState "l00000350"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_6, R29_6, R30_8, bvadd64(R31_5, 16bv64); - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_6, Gamma_R29_6, Gamma_R30_8, Gamma_R31_5; + assume {:captureState "main_basil_return"} true; return; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load8_le(mem, 1964bv64) == 1bv8); free requires (memory_load8_le(mem, 1965bv64) == 0bv8); diff --git a/src/test/correct/malloc_with_local/clang_O2/malloc_with_local_gtirb.expected b/src/test/correct/malloc_with_local/clang_O2/malloc_with_local_gtirb.expected index c4a8ab0b3..1f4ef0422 100644 --- a/src/test/correct/malloc_with_local/clang_O2/malloc_with_local_gtirb.expected +++ b/src/test/correct/malloc_with_local/clang_O2/malloc_with_local_gtirb.expected @@ -1,33 +1,34 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1964bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { @@ -39,13 +40,13 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); @@ -68,8 +69,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -82,8 +83,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_630(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load8_le(mem, 1964bv64) == 1bv8); free requires (memory_load8_le(mem, 1965bv64) == 0bv8); free requires (memory_load8_le(mem, 1966bv64) == 2bv8); @@ -123,143 +124,20 @@ procedure FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation FUN_630(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_630() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_630$__0__$Q70X6WVjRICVO79dZjxubQ: + assume {:captureState "$FUN_630$__0__$Q70X6WVjRICVO79dZjxubQ"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69664bv64), (gamma_load64(Gamma_mem, 69664bv64) || L(mem, 69664bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69664bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 32bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 32bv64)) || L(mem, bvadd64(R16, 32bv64))); + R16, Gamma_R16 := bvadd64(R16, 32bv64), Gamma_R16; + call printf(); assume false; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69672bv64) == 0bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); free requires (memory_load8_le(mem, 1964bv64) == 1bv8); @@ -281,6 +159,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); @@ -301,48 +183,54 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R29_3: bool; - var Gamma_R30_5: bool; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R29_3: bv64; - var R30_5: bv64; + var Cse0__5$3$0: bv64; + var Gamma_Cse0__5$3$0: bool; $main$__0__$qsNWZvfmT3SqwMLjWcYSLA: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_630(R16, Gamma_R16); + assume {:captureState "$main$__0__$qsNWZvfmT3SqwMLjWcYSLA"} true; + Cse0__5$3$0, Gamma_Cse0__5$3$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$3$0, R29), gamma_store64(Gamma_stack, Cse0__5$3$0, Gamma_R29); + assume {:captureState "1876$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$3$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$3$0, 8bv64), Gamma_R30); + assume {:captureState "1876$2"} true; + R31, Gamma_R31 := Cse0__5$3$0, Gamma_Cse0__5$3$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 1968bv64), Gamma_R0; + R1, Gamma_R1 := 65bv64, true; + R30, Gamma_R30 := 1900bv64, true; + call FUN_630(); goto $main$__1__$i1LEKl1vSbiR7lae0n2rcw; $main$__1__$i1LEKl1vSbiR7lae0n2rcw: - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := FUN_630(R16_1, Gamma_R16_1); + assume {:captureState "$main$__1__$i1LEKl1vSbiR7lae0n2rcw"} true; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 1985bv64), Gamma_R0; + R1, Gamma_R1 := 42bv64, true; + R30, Gamma_R30 := 1916bv64, true; + call FUN_630(); goto $main$__2__$TtIWNKMwRKK1do~W4tjTkA; $main$__2__$TtIWNKMwRKK1do~W4tjTkA: - call R16_3, Gamma_R16_3, R17_3, Gamma_R17_3 := FUN_630(R16_2, Gamma_R16_2); + assume {:captureState "$main$__2__$TtIWNKMwRKK1do~W4tjTkA"} true; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2001bv64), Gamma_R0; + R1, Gamma_R1 := 10bv64, true; + R30, Gamma_R30 := 1932bv64, true; + call FUN_630(); goto $main$__3__$f8mE4zYMSriGzPYQZgWMTA; $main$__3__$f8mE4zYMSriGzPYQZgWMTA: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_5, Gamma_R30_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__3__$f8mE4zYMSriGzPYQZgWMTA"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R16_3, R17_3, 10bv64, R29_3, R30_5, R31_in; - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R16_3, Gamma_R17_3, true, Gamma_R29_3, Gamma_R30_5, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load8_le(mem, 1964bv64) == 1bv8); free requires (memory_load8_le(mem, 1965bv64) == 0bv8); free requires (memory_load8_le(mem, 1966bv64) == 2bv8); diff --git a/src/test/correct/malloc_with_local/gcc/malloc_with_local.expected b/src/test/correct/malloc_with_local/gcc/malloc_with_local.expected index 42b9d04ff..a85bcc599 100644 --- a/src/test/correct/malloc_with_local/gcc/malloc_with_local.expected +++ b/src/test/correct/malloc_with_local/gcc/malloc_with_local.expected @@ -1,32 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2248bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -40,21 +36,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -68,23 +60,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2248bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2256bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2264bv64) == 748482783423457568bv64); @@ -104,8 +96,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -118,7 +110,7 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2248bv64) == 131073bv64); free requires (memory_load64_le(mem, 2256bv64) == 8241983568019286100bv64); @@ -153,8 +145,8 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2248bv64) == 131073bv64); @@ -173,6 +165,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69000bv64) == 1984bv64); free requires (memory_load64_le(mem, 69616bv64) == 2068bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2248bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2256bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2264bv64) == 748482783423457568bv64); @@ -190,594 +186,103 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_12: bool; - var Gamma_R0_13: bool; - var Gamma_R0_14: bool; - var Gamma_R0_17: bool; - var Gamma_R0_2: bool; - var Gamma_R0_20: bool; - var Gamma_R0_21: bool; - var Gamma_R0_22: bool; - var Gamma_R0_23: bool; - var Gamma_R0_24: bool; - var Gamma_R0_4: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R0_9: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R10_2: bool; - var Gamma_R10_3: bool; - var Gamma_R10_4: bool; - var Gamma_R10_5: bool; - var Gamma_R10_6: bool; - var Gamma_R10_7: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R11_2: bool; - var Gamma_R11_3: bool; - var Gamma_R11_4: bool; - var Gamma_R11_5: bool; - var Gamma_R11_6: bool; - var Gamma_R11_7: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R12_2: bool; - var Gamma_R12_3: bool; - var Gamma_R12_4: bool; - var Gamma_R12_5: bool; - var Gamma_R12_6: bool; - var Gamma_R12_7: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R13_2: bool; - var Gamma_R13_3: bool; - var Gamma_R13_4: bool; - var Gamma_R13_5: bool; - var Gamma_R13_6: bool; - var Gamma_R13_7: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R14_2: bool; - var Gamma_R14_3: bool; - var Gamma_R14_4: bool; - var Gamma_R14_5: bool; - var Gamma_R14_6: bool; - var Gamma_R14_7: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R15_2: bool; - var Gamma_R15_3: bool; - var Gamma_R15_4: bool; - var Gamma_R15_5: bool; - var Gamma_R15_6: bool; - var Gamma_R15_7: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R16_7: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R17_7: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R18_2: bool; - var Gamma_R18_3: bool; - var Gamma_R18_4: bool; - var Gamma_R18_5: bool; - var Gamma_R18_6: bool; - var Gamma_R18_7: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R19_2: bool; - var Gamma_R19_3: bool; - var Gamma_R19_4: bool; - var Gamma_R19_5: bool; - var Gamma_R19_6: bool; - var Gamma_R19_7: bool; - var Gamma_R1_1: bool; - var Gamma_R1_10: bool; - var Gamma_R1_11: bool; - var Gamma_R1_12: bool; - var Gamma_R1_2: bool; - var Gamma_R1_5: bool; - var Gamma_R1_6: bool; - var Gamma_R1_7: bool; - var Gamma_R1_8: bool; - var Gamma_R1_9: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R20_2: bool; - var Gamma_R20_3: bool; - var Gamma_R20_4: bool; - var Gamma_R20_5: bool; - var Gamma_R20_6: bool; - var Gamma_R20_7: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R21_2: bool; - var Gamma_R21_3: bool; - var Gamma_R21_4: bool; - var Gamma_R21_5: bool; - var Gamma_R21_6: bool; - var Gamma_R21_7: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R22_2: bool; - var Gamma_R22_3: bool; - var Gamma_R22_4: bool; - var Gamma_R22_5: bool; - var Gamma_R22_6: bool; - var Gamma_R22_7: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R23_2: bool; - var Gamma_R23_3: bool; - var Gamma_R23_4: bool; - var Gamma_R23_5: bool; - var Gamma_R23_6: bool; - var Gamma_R23_7: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R24_2: bool; - var Gamma_R24_3: bool; - var Gamma_R24_4: bool; - var Gamma_R24_5: bool; - var Gamma_R24_6: bool; - var Gamma_R24_7: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R25_2: bool; - var Gamma_R25_3: bool; - var Gamma_R25_4: bool; - var Gamma_R25_5: bool; - var Gamma_R25_6: bool; - var Gamma_R25_7: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R26_2: bool; - var Gamma_R26_3: bool; - var Gamma_R26_4: bool; - var Gamma_R26_5: bool; - var Gamma_R26_6: bool; - var Gamma_R26_7: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R27_2: bool; - var Gamma_R27_3: bool; - var Gamma_R27_4: bool; - var Gamma_R27_5: bool; - var Gamma_R27_6: bool; - var Gamma_R27_7: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R28_2: bool; - var Gamma_R28_3: bool; - var Gamma_R28_4: bool; - var Gamma_R28_5: bool; - var Gamma_R28_6: bool; - var Gamma_R28_7: bool; - var Gamma_R29_10: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R29_5: bool; - var Gamma_R29_6: bool; - var Gamma_R29_7: bool; - var Gamma_R29_8: bool; - var Gamma_R29_9: bool; - var Gamma_R2_1: bool; - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var Gamma_R2_4: bool; - var Gamma_R2_5: bool; - var Gamma_R2_6: bool; - var Gamma_R2_7: bool; - var Gamma_R3: bool; - var Gamma_R30_11: bool; - var Gamma_R30_13: bool; - var Gamma_R30_15: bool; - var Gamma_R30_16: bool; - var Gamma_R30_3: bool; - var Gamma_R30_5: bool; - var Gamma_R30_7: bool; - var Gamma_R30_9: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R31_5: bool; - var Gamma_R31_6: bool; - var Gamma_R31_7: bool; - var Gamma_R31_8: bool; - var Gamma_R31_9: bool; - var Gamma_R3_1: bool; - var Gamma_R3_2: bool; - var Gamma_R3_3: bool; - var Gamma_R3_4: bool; - var Gamma_R3_5: bool; - var Gamma_R3_6: bool; - var Gamma_R3_7: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R4_2: bool; - var Gamma_R4_3: bool; - var Gamma_R4_4: bool; - var Gamma_R4_5: bool; - var Gamma_R4_6: bool; - var Gamma_R4_7: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R5_2: bool; - var Gamma_R5_3: bool; - var Gamma_R5_4: bool; - var Gamma_R5_5: bool; - var Gamma_R5_6: bool; - var Gamma_R5_7: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R6_2: bool; - var Gamma_R6_3: bool; - var Gamma_R6_4: bool; - var Gamma_R6_5: bool; - var Gamma_R6_6: bool; - var Gamma_R6_7: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R7_2: bool; - var Gamma_R7_3: bool; - var Gamma_R7_4: bool; - var Gamma_R7_5: bool; - var Gamma_R7_6: bool; - var Gamma_R7_7: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R8_5: bool; - var Gamma_R8_6: bool; - var Gamma_R8_7: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var Gamma_R9_4: bool; - var Gamma_R9_5: bool; - var Gamma_R9_6: bool; - var Gamma_R9_7: bool; - var R0_12: bv64; - var R0_13: bv64; - var R0_14: bv32; - var R0_17: bv64; - var R0_2: bv64; - var R0_20: bv64; - var R0_21: bv64; - var R0_22: bv64; - var R0_23: bv64; - var R0_24: bv64; - var R0_4: bv64; - var R0_6: bv64; - var R0_7: bv64; - var R0_8: bv64; - var R0_9: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R10_2: bv64; - var R10_3: bv64; - var R10_4: bv64; - var R10_5: bv64; - var R10_6: bv64; - var R10_7: bv64; - var R11: bv64; - var R11_1: bv64; - var R11_2: bv64; - var R11_3: bv64; - var R11_4: bv64; - var R11_5: bv64; - var R11_6: bv64; - var R11_7: bv64; - var R12: bv64; - var R12_1: bv64; - var R12_2: bv64; - var R12_3: bv64; - var R12_4: bv64; - var R12_5: bv64; - var R12_6: bv64; - var R12_7: bv64; - var R13: bv64; - var R13_1: bv64; - var R13_2: bv64; - var R13_3: bv64; - var R13_4: bv64; - var R13_5: bv64; - var R13_6: bv64; - var R13_7: bv64; - var R14: bv64; - var R14_1: bv64; - var R14_2: bv64; - var R14_3: bv64; - var R14_4: bv64; - var R14_5: bv64; - var R14_6: bv64; - var R14_7: bv64; - var R15: bv64; - var R15_1: bv64; - var R15_2: bv64; - var R15_3: bv64; - var R15_4: bv64; - var R15_5: bv64; - var R15_6: bv64; - var R15_7: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R16_7: bv64; - var R17: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R17_7: bv64; - var R18: bv64; - var R18_1: bv64; - var R18_2: bv64; - var R18_3: bv64; - var R18_4: bv64; - var R18_5: bv64; - var R18_6: bv64; - var R18_7: bv64; - var R19: bv64; - var R19_1: bv64; - var R19_2: bv64; - var R19_3: bv64; - var R19_4: bv64; - var R19_5: bv64; - var R19_6: bv64; - var R19_7: bv64; - var R1_1: bv64; - var R1_10: bv64; - var R1_11: bv64; - var R1_12: bv64; - var R1_2: bv64; - var R1_5: bv64; - var R1_6: bv64; - var R1_7: bv64; - var R1_8: bv64; - var R1_9: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R20_2: bv64; - var R20_3: bv64; - var R20_4: bv64; - var R20_5: bv64; - var R20_6: bv64; - var R20_7: bv64; - var R21: bv64; - var R21_1: bv64; - var R21_2: bv64; - var R21_3: bv64; - var R21_4: bv64; - var R21_5: bv64; - var R21_6: bv64; - var R21_7: bv64; - var R22: bv64; - var R22_1: bv64; - var R22_2: bv64; - var R22_3: bv64; - var R22_4: bv64; - var R22_5: bv64; - var R22_6: bv64; - var R22_7: bv64; - var R23: bv64; - var R23_1: bv64; - var R23_2: bv64; - var R23_3: bv64; - var R23_4: bv64; - var R23_5: bv64; - var R23_6: bv64; - var R23_7: bv64; - var R24: bv64; - var R24_1: bv64; - var R24_2: bv64; - var R24_3: bv64; - var R24_4: bv64; - var R24_5: bv64; - var R24_6: bv64; - var R24_7: bv64; - var R25: bv64; - var R25_1: bv64; - var R25_2: bv64; - var R25_3: bv64; - var R25_4: bv64; - var R25_5: bv64; - var R25_6: bv64; - var R25_7: bv64; - var R26: bv64; - var R26_1: bv64; - var R26_2: bv64; - var R26_3: bv64; - var R26_4: bv64; - var R26_5: bv64; - var R26_6: bv64; - var R26_7: bv64; - var R27: bv64; - var R27_1: bv64; - var R27_2: bv64; - var R27_3: bv64; - var R27_4: bv64; - var R27_5: bv64; - var R27_6: bv64; - var R27_7: bv64; - var R28: bv64; - var R28_1: bv64; - var R28_2: bv64; - var R28_3: bv64; - var R28_4: bv64; - var R28_5: bv64; - var R28_6: bv64; - var R28_7: bv64; - var R29_10: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R29_5: bv64; - var R29_6: bv64; - var R29_7: bv64; - var R29_8: bv64; - var R29_9: bv64; - var R2_1: bv64; - var R2_2: bv64; - var R2_3: bv64; - var R2_4: bv64; - var R2_5: bv64; - var R2_6: bv64; - var R2_7: bv64; - var R3: bv64; - var R30_11: bv64; - var R30_13: bv64; - var R30_15: bv64; - var R30_16: bv64; - var R30_3: bv64; - var R30_5: bv64; - var R30_7: bv64; - var R30_9: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R31_5: bv64; - var R31_6: bv64; - var R31_7: bv64; - var R31_8: bv64; - var R31_9: bv64; - var R3_1: bv64; - var R3_2: bv64; - var R3_3: bv64; - var R3_4: bv64; - var R3_5: bv64; - var R3_6: bv64; - var R3_7: bv64; - var R4: bv64; - var R4_1: bv64; - var R4_2: bv64; - var R4_3: bv64; - var R4_4: bv64; - var R4_5: bv64; - var R4_6: bv64; - var R4_7: bv64; - var R5: bv64; - var R5_1: bv64; - var R5_2: bv64; - var R5_3: bv64; - var R5_4: bv64; - var R5_5: bv64; - var R5_6: bv64; - var R5_7: bv64; - var R6: bv64; - var R6_1: bv64; - var R6_2: bv64; - var R6_3: bv64; - var R6_4: bv64; - var R6_5: bv64; - var R6_6: bv64; - var R6_7: bv64; - var R7: bv64; - var R7_1: bv64; - var R7_2: bv64; - var R7_3: bv64; - var R7_4: bv64; - var R7_5: bv64; - var R7_6: bv64; - var R7_7: bv64; - var R8: bv64; - var R8_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R8_4: bv64; - var R8_5: bv64; - var R8_6: bv64; - var R8_7: bv64; - var R9: bv64; - var R9_1: bv64; - var R9_2: bv64; - var R9_3: bv64; - var R9_4: bv64; - var R9_5: bv64; - var R9_6: bv64; - var R9_7: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551576bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64), Gamma_R30_in); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(1bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R31_in, R2, Gamma_R2, 2084bv64, true, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000350"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000356"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2084bv64, true; + call malloc(); goto l0000036f; l0000036f: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_3, 32bv64), R0_2), gamma_store64(Gamma_stack, bvadd64(R31_3, 32bv64), Gamma_R0_2); - call R0_4, Gamma_R0_4, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_2, Gamma_R1_2, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, R30_5, Gamma_R30_5, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2 := malloc(4bv64, true, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, 2096bv64, true, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1); + assume {:captureState "l0000036f"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "%00000375"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2096bv64, true; + call malloc(); goto l00000383; l00000383: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_4, 40bv64), R0_4), gamma_store64(Gamma_stack, bvadd64(R31_4, 40bv64), Gamma_R0_4); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_4, 28bv64), 10bv32), gamma_store32(Gamma_stack, bvadd64(R31_4, 28bv64), true); - R0_6, Gamma_R0_6 := memory_load64_le(stack, bvadd64(R31_4, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 32bv64)); + assume {:captureState "l00000383"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "%00000389"} true; + R0, Gamma_R0 := 10bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000396"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + R1, Gamma_R1 := 65bv64, true; call rely(); - assert (L(mem, R0_6) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R0_6, 65bv8), gamma_store8(Gamma_mem, R0_6, true); - R0_7, Gamma_R0_7 := memory_load64_le(stack, bvadd64(R31_4, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 40bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003aa"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R1, Gamma_R1 := 42bv64, true; call rely(); - assert (L(mem, R0_7) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_7, 42bv32), gamma_store32(Gamma_mem, R0_7, true); - R0_8, Gamma_R0_8 := memory_load64_le(stack, bvadd64(R31_4, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 32bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003be"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); call rely(); - R0_9, Gamma_R0_9 := zero_extend56_8(memory_load8_le(mem, R0_8)), (gamma_load8(Gamma_mem, R0_8) || L(mem, R0_8)); - R1_5, Gamma_R1_5 := zero_extend32_32(R0_9[32:0]), Gamma_R0_9; - call R0_12, Gamma_R0_12, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_6, Gamma_R1_6, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, R30_7, Gamma_R30_7, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_3, Gamma_R8_3, R9_3, Gamma_R9_3 := printf(2256bv64, true, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_5, Gamma_R1_5, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, 2156bv64, true, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2); + R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2256bv64), Gamma_R0; + R30, Gamma_R30 := 2156bv64, true; + call printf(); goto l000003e7; l000003e7: - R0_13, Gamma_R0_13 := memory_load64_le(stack, bvadd64(R31_5, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 40bv64)); + assume {:captureState "l000003e7"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); call rely(); - R0_14, Gamma_R0_14 := memory_load32_le(mem, R0_13), (gamma_load32(Gamma_mem, R0_13) || L(mem, R0_13)); - R1_7, Gamma_R1_7 := zero_extend32_32(R0_14), Gamma_R0_14; - call R0_17, Gamma_R0_17, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_8, Gamma_R1_8, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, R30_9, Gamma_R30_9, R31_6, Gamma_R31_6, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_4, Gamma_R8_4, R9_4, Gamma_R9_4 := printf(2280bv64, true, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_7, Gamma_R1_7, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, 2180bv64, true, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_3, Gamma_R8_3, R9_3, Gamma_R9_3); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2280bv64), Gamma_R0; + R30, Gamma_R30 := 2180bv64, true; + call printf(); goto l0000040d; l0000040d: - R1_9, Gamma_R1_9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_6, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31_6, 28bv64)); - call R0_20, Gamma_R0_20, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_10, Gamma_R1_10, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, R30_11, Gamma_R30_11, R31_7, Gamma_R31_7, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_5, Gamma_R8_5, R9_5, Gamma_R9_5 := printf(2296bv64, true, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_9, Gamma_R1_9, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, 2196bv64, true, R31_6, Gamma_R31_6, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_4, Gamma_R8_4, R9_4, Gamma_R9_4); + assume {:captureState "l0000040d"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2296bv64), Gamma_R0; + R30, Gamma_R30 := 2196bv64, true; + call printf(); goto l00000426; l00000426: - R0_21, Gamma_R0_21 := memory_load64_le(stack, bvadd64(R31_7, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_7, 32bv64)); - call R0_22, Gamma_R0_22, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_11, Gamma_R1_11, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_8, Gamma_R29_8, R2_6, Gamma_R2_6, R30_13, Gamma_R30_13, R31_8, Gamma_R31_8, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_6, Gamma_R8_6, R9_6, Gamma_R9_6 := #free(R0_21, Gamma_R0_21, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_10, Gamma_R1_10, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, 2204bv64, true, R31_7, Gamma_R31_7, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_5, Gamma_R8_5, R9_5, Gamma_R9_5); + assume {:captureState "l00000426"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + R30, Gamma_R30 := 2204bv64, true; + call #free(); goto l00000435; l00000435: - R0_23, Gamma_R0_23 := memory_load64_le(stack, bvadd64(R31_8, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_8, 40bv64)); - call R0_24, Gamma_R0_24, R10_7, Gamma_R10_7, R11_7, Gamma_R11_7, R12_7, Gamma_R12_7, R13_7, Gamma_R13_7, R14_7, Gamma_R14_7, R15_7, Gamma_R15_7, R16_7, Gamma_R16_7, R17_7, Gamma_R17_7, R18_7, Gamma_R18_7, R19_7, Gamma_R19_7, R1_12, Gamma_R1_12, R20_7, Gamma_R20_7, R21_7, Gamma_R21_7, R22_7, Gamma_R22_7, R23_7, Gamma_R23_7, R24_7, Gamma_R24_7, R25_7, Gamma_R25_7, R26_7, Gamma_R26_7, R27_7, Gamma_R27_7, R28_7, Gamma_R28_7, R29_9, Gamma_R29_9, R2_7, Gamma_R2_7, R30_15, Gamma_R30_15, R31_9, Gamma_R31_9, R3_7, Gamma_R3_7, R4_7, Gamma_R4_7, R5_7, Gamma_R5_7, R6_7, Gamma_R6_7, R7_7, Gamma_R7_7, R8_7, Gamma_R8_7, R9_7, Gamma_R9_7 := #free(R0_23, Gamma_R0_23, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_11, Gamma_R1_11, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_8, Gamma_R29_8, R2_6, Gamma_R2_6, 2212bv64, true, R31_8, Gamma_R31_8, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_6, Gamma_R8_6, R9_6, Gamma_R9_6); + assume {:captureState "l00000435"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R30, Gamma_R30 := 2212bv64, true; + call #free(); goto l00000443; l00000443: - R29_10, Gamma_R29_10 := memory_load64_le(stack, R31_9), gamma_load64(Gamma_stack, R31_9); - R30_16, Gamma_R30_16 := memory_load64_le(stack, bvadd64(R31_9, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_9, 8bv64)); + assume {:captureState "l00000443"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_12, R29_10, R30_16, bvadd64(R31_9, 48bv64); - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_12, Gamma_R29_10, Gamma_R30_16, Gamma_R31_9; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2248bv64) == 131073bv64); free requires (memory_load64_le(mem, 2256bv64) == 8241983568019286100bv64); @@ -812,7 +317,7 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2248bv64) == 131073bv64); free requires (memory_load64_le(mem, 2256bv64) == 8241983568019286100bv64); diff --git a/src/test/correct/malloc_with_local/gcc/malloc_with_local_gtirb.expected b/src/test/correct/malloc_with_local/gcc/malloc_with_local_gtirb.expected index 536f13d47..b0dce8dca 100644 --- a/src/test/correct/malloc_with_local/gcc/malloc_with_local_gtirb.expected +++ b/src/test/correct/malloc_with_local/gcc/malloc_with_local_gtirb.expected @@ -1,28 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2248bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -31,22 +31,22 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { + gammaMap[index] +} + function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -60,22 +60,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2248bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2256bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2264bv64) == 748482783423457568bv64); @@ -95,8 +96,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -109,8 +110,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_680(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2248bv64) == 131073bv64); free requires (memory_load64_le(mem, 2256bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2264bv64) == 748482783423457568bv64); @@ -144,143 +145,20 @@ procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_680() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_680$__0__$G9dTDoYvRG25kbHLw1VfkA: + assume {:captureState "$FUN_680$__0__$G9dTDoYvRG25kbHLw1VfkA"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69544bv64), (gamma_load64(Gamma_mem, 69544bv64) || L(mem, 69544bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69544bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4008bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4008bv64)) || L(mem, bvadd64(R16, 4008bv64))); + R16, Gamma_R16 := bvadd64(R16, 4008bv64), Gamma_R16; + call malloc(); assume false; } -procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6b0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2248bv64) == 131073bv64); free requires (memory_load64_le(mem, 2256bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2264bv64) == 748482783423457568bv64); @@ -314,143 +192,20 @@ procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6b0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6b0$__0__$zCVLckCjR0u8KR3z1jE6GQ: + assume {:captureState "$FUN_6b0$__0__$zCVLckCjR0u8KR3z1jE6GQ"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := #free(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69568bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4032bv64)) || L(mem, bvadd64(R16, 4032bv64))); + R16, Gamma_R16 := bvadd64(R16, 4032bv64), Gamma_R16; + call #free(); assume false; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2248bv64) == 131073bv64); @@ -469,6 +224,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69000bv64) == 1984bv64); free requires (memory_load64_le(mem, 69616bv64) == 2068bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2248bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2256bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2264bv64) == 748482783423457568bv64); @@ -486,101 +245,104 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R16_7: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R17_7: bool; - var Gamma_R1_5: bool; - var Gamma_R29_3: bool; - var Gamma_R30_9: bool; - var R0_10: bv64; - var R0_4: bv64; - var R0_5: bv64; - var R0_6: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R16_7: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R17_7: bv64; - var R1_5: bv64; - var R29_3: bv64; - var R30_9: bv64; + var Cse0__5$1$0: bv64; + var Gamma_Cse0__5$1$0: bool; $main$__0__$SUJRVtnjRyS2h6Rx4EyZkw: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551576bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64), Gamma_R30_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_680(R16, Gamma_R16); + assume {:captureState "$main$__0__$SUJRVtnjRyS2h6Rx4EyZkw"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$0, R29), gamma_store64(Gamma_stack, Cse0__5$1$0, Gamma_R29); + assume {:captureState "2068$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$0, 8bv64), Gamma_R30); + assume {:captureState "2068$2"} true; + R31, Gamma_R31 := Cse0__5$1$0, Gamma_Cse0__5$1$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2084bv64, true; + call FUN_680(); goto $main$__1__$dXGr9aYyQ8G9hHSr5qB_Fg; $main$__1__$dXGr9aYyQ8G9hHSr5qB_Fg: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), 1bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), true); - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := FUN_680(R16_1, Gamma_R16_1); + assume {:captureState "$main$__1__$dXGr9aYyQ8G9hHSr5qB_Fg"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "2084$0"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2096bv64, true; + call FUN_680(); goto $main$__2__$kxvGNkmcRTWZLsX2IG8zQg; $main$__2__$kxvGNkmcRTWZLsX2IG8zQg: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 10bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - R0_4, Gamma_R0_4 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); + assume {:captureState "$main$__2__$kxvGNkmcRTWZLsX2IG8zQg"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "2096$0"} true; + R0, Gamma_R0 := 10bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "2104$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + R1, Gamma_R1 := 65bv64, true; + call rely(); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2116$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R1, Gamma_R1 := 42bv64, true; call rely(); - assert (L(mem, R0_4) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R0_4, 65bv8), gamma_store8(Gamma_mem, R0_4, true); - R0_5, Gamma_R0_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2128$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); call rely(); - assert (L(mem, R0_5) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_5, 42bv32), gamma_store32(Gamma_mem, R0_5, true); - R0_6, Gamma_R0_6 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - call R16_3, Gamma_R16_3, R17_3, Gamma_R17_3 := FUN_6c0(R16_2, Gamma_R16_2); + R0, Gamma_R0 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R0))), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2256bv64), Gamma_R0; + R30, Gamma_R30 := 2156bv64, true; + call FUN_6c0(); goto $main$__3__$KeIk_ZKFT1GwKspywoVEIw; $main$__3__$KeIk_ZKFT1GwKspywoVEIw: - R0_10, Gamma_R0_10 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - call R16_4, Gamma_R16_4, R17_4, Gamma_R17_4 := FUN_6c0(R16_3, Gamma_R16_3); + assume {:captureState "$main$__3__$KeIk_ZKFT1GwKspywoVEIw"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + call rely(); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2280bv64), Gamma_R0; + R30, Gamma_R30 := 2180bv64, true; + call FUN_6c0(); goto $main$__4__$NWXkJAFcTsylQC0_~kBpIg; $main$__4__$NWXkJAFcTsylQC0_~kBpIg: - R1_5, Gamma_R1_5 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - call R16_5, Gamma_R16_5, R17_5, Gamma_R17_5 := FUN_6c0(R16_4, Gamma_R16_4); + assume {:captureState "$main$__4__$NWXkJAFcTsylQC0_~kBpIg"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2296bv64), Gamma_R0; + R30, Gamma_R30 := 2196bv64, true; + call FUN_6c0(); goto $main$__5__$HGIidlGjSU~nVJyWDq3sTA; $main$__5__$HGIidlGjSU~nVJyWDq3sTA: - call R16_6, Gamma_R16_6, R17_6, Gamma_R17_6 := FUN_6b0(R16_5, Gamma_R16_5); + assume {:captureState "$main$__5__$HGIidlGjSU~nVJyWDq3sTA"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + R30, Gamma_R30 := 2204bv64, true; + call FUN_6b0(); goto $main$__6__$oMn7uKPqTSOK6gp7Lrg3TQ; $main$__6__$oMn7uKPqTSOK6gp7Lrg3TQ: - call R16_7, Gamma_R16_7, R17_7, Gamma_R17_7 := FUN_6b0(R16_6, Gamma_R16_6); + assume {:captureState "$main$__6__$oMn7uKPqTSOK6gp7Lrg3TQ"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R30, Gamma_R30 := 2212bv64, true; + call FUN_6b0(); goto $main$__7__$1RsW4Nh~QjukdAMYUoDwdg; $main$__7__$1RsW4Nh~QjukdAMYUoDwdg: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551568bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64)); - R30_9, Gamma_R30_9 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551576bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64)); + assume {:captureState "$main$__7__$1RsW4Nh~QjukdAMYUoDwdg"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R16_7, R17_7, R1_5, R29_3, R30_9, R31_in; - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R16_7, Gamma_R17_7, Gamma_R1_5, Gamma_R29_3, Gamma_R30_9, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } -procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6c0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2248bv64) == 131073bv64); free requires (memory_load64_le(mem, 2256bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2264bv64) == 748482783423457568bv64); @@ -614,142 +376,19 @@ procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6c0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6c0$__0__$z3eRO9k2T_a0u0N1n7WjQg: + assume {:captureState "$FUN_6c0$__0__$z3eRO9k2T_a0u0N1n7WjQg"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69576bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4040bv64)) || L(mem, bvadd64(R16, 4040bv64))); + R16, Gamma_R16 := bvadd64(R16, 4040bv64), Gamma_R16; + call printf(); assume false; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); free requires (memory_load64_le(mem, 2248bv64) == 131073bv64); free requires (memory_load64_le(mem, 2256bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2264bv64) == 748482783423457568bv64); @@ -783,7 +422,7 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); free requires (memory_load64_le(mem, 2248bv64) == 131073bv64); free requires (memory_load64_le(mem, 2256bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2264bv64) == 748482783423457568bv64); @@ -817,7 +456,7 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load64_le(mem, 2248bv64) == 131073bv64); free requires (memory_load64_le(mem, 2256bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2264bv64) == 748482783423457568bv64); diff --git a/src/test/correct/malloc_with_local/gcc_O2/malloc_with_local.expected b/src/test/correct/malloc_with_local/gcc_O2/malloc_with_local.expected index 0806a2d73..715409413 100644 --- a/src/test/correct/malloc_with_local/gcc_O2/malloc_with_local.expected +++ b/src/test/correct/malloc_with_local/gcc_O2/malloc_with_local.expected @@ -1,33 +1,32 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2088bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { @@ -39,13 +38,13 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2088bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2096bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2104bv64) == 748482783423457568bv64); @@ -65,8 +64,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -79,7 +78,7 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure __printf_chk(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure __printf_chk(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2088bv64) == 131073bv64); free requires (memory_load64_le(mem, 2096bv64) == 8241983568019286100bv64); @@ -114,8 +113,8 @@ procedure __printf_chk(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_i free ensures (memory_load64_le(mem, 69616bv64) == 1664bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_stack, R16, R17, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R2, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_stack, R0, R1, R16, R17, R2, R29, R30, R31, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2088bv64) == 131073bv64); @@ -134,6 +133,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69016bv64) == 1984bv64); free requires (memory_load64_le(mem, 69616bv64) == 1664bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2088bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2096bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2104bv64) == 748482783423457568bv64); @@ -151,274 +154,53 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 1664bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_4: bool; - var Gamma_R0_6: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R10_2: bool; - var Gamma_R10_3: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R11_2: bool; - var Gamma_R11_3: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R12_2: bool; - var Gamma_R12_3: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R13_2: bool; - var Gamma_R13_3: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R14_2: bool; - var Gamma_R14_3: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R15_2: bool; - var Gamma_R15_3: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R18_2: bool; - var Gamma_R18_3: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R19_2: bool; - var Gamma_R19_3: bool; - var Gamma_R1_3: bool; - var Gamma_R1_6: bool; - var Gamma_R1_9: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R20_2: bool; - var Gamma_R20_3: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R21_2: bool; - var Gamma_R21_3: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R22_2: bool; - var Gamma_R22_3: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R23_2: bool; - var Gamma_R23_3: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R24_2: bool; - var Gamma_R24_3: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R25_2: bool; - var Gamma_R25_3: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R26_2: bool; - var Gamma_R26_3: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R27_2: bool; - var Gamma_R27_3: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R28_2: bool; - var Gamma_R28_3: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R29_5: bool; - var Gamma_R29_6: bool; - var Gamma_R2_2: bool; - var Gamma_R2_4: bool; - var Gamma_R2_6: bool; - var Gamma_R3: bool; - var Gamma_R30_3: bool; - var Gamma_R30_5: bool; - var Gamma_R30_7: bool; - var Gamma_R30_8: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R31_5: bool; - var Gamma_R3_1: bool; - var Gamma_R3_2: bool; - var Gamma_R3_3: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R4_2: bool; - var Gamma_R4_3: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R5_2: bool; - var Gamma_R5_3: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R6_2: bool; - var Gamma_R6_3: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R7_2: bool; - var Gamma_R7_3: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var R0_2: bv64; - var R0_4: bv64; - var R0_6: bv64; - var R10: bv64; - var R10_1: bv64; - var R10_2: bv64; - var R10_3: bv64; - var R11: bv64; - var R11_1: bv64; - var R11_2: bv64; - var R11_3: bv64; - var R12: bv64; - var R12_1: bv64; - var R12_2: bv64; - var R12_3: bv64; - var R13: bv64; - var R13_1: bv64; - var R13_2: bv64; - var R13_3: bv64; - var R14: bv64; - var R14_1: bv64; - var R14_2: bv64; - var R14_3: bv64; - var R15: bv64; - var R15_1: bv64; - var R15_2: bv64; - var R15_3: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R17: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R18: bv64; - var R18_1: bv64; - var R18_2: bv64; - var R18_3: bv64; - var R19: bv64; - var R19_1: bv64; - var R19_2: bv64; - var R19_3: bv64; - var R1_3: bv64; - var R1_6: bv64; - var R1_9: bv64; - var R20: bv64; - var R20_1: bv64; - var R20_2: bv64; - var R20_3: bv64; - var R21: bv64; - var R21_1: bv64; - var R21_2: bv64; - var R21_3: bv64; - var R22: bv64; - var R22_1: bv64; - var R22_2: bv64; - var R22_3: bv64; - var R23: bv64; - var R23_1: bv64; - var R23_2: bv64; - var R23_3: bv64; - var R24: bv64; - var R24_1: bv64; - var R24_2: bv64; - var R24_3: bv64; - var R25: bv64; - var R25_1: bv64; - var R25_2: bv64; - var R25_3: bv64; - var R26: bv64; - var R26_1: bv64; - var R26_2: bv64; - var R26_3: bv64; - var R27: bv64; - var R27_1: bv64; - var R27_2: bv64; - var R27_3: bv64; - var R28: bv64; - var R28_1: bv64; - var R28_2: bv64; - var R28_3: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R29_5: bv64; - var R29_6: bv64; - var R2_2: bv64; - var R2_4: bv64; - var R2_6: bv64; - var R3: bv64; - var R30_3: bv64; - var R30_5: bv64; - var R30_7: bv64; - var R30_8: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R31_5: bv64; - var R3_1: bv64; - var R3_2: bv64; - var R3_3: bv64; - var R4: bv64; - var R4_1: bv64; - var R4_2: bv64; - var R4_3: bv64; - var R5: bv64; - var R5_1: bv64; - var R5_2: bv64; - var R5_3: bv64; - var R6: bv64; - var R6_1: bv64; - var R6_2: bv64; - var R6_3: bv64; - var R7: bv64; - var R7_1: bv64; - var R7_2: bv64; - var R7_3: bv64; - var R8: bv64; - var R8_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R9: bv64; - var R9_1: bv64; - var R9_2: bv64; - var R9_3: bv64; + var #1: bv64; + var Gamma_#1: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_3, Gamma_R1_3, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_2, Gamma_R2_2, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := __printf_chk(1bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, 2096bv64, true, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, 65bv64, true, 1692bv64, true, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + assume {:captureState "lmain"} true; + #1, Gamma_#1 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #1, R29), gamma_store64(Gamma_stack, #1, Gamma_R29); + assume {:captureState "%000001f2"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#1, 8bv64), Gamma_R30); + assume {:captureState "%000001f8"} true; + R31, Gamma_R31 := #1, Gamma_#1; + R2, Gamma_R2 := 65bv64, true; + R1, Gamma_R1 := 0bv64, true; + R29, Gamma_R29 := R31, Gamma_R31; + R1, Gamma_R1 := bvadd64(R1, 2096bv64), Gamma_R1; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 1692bv64, true; + call __printf_chk(); goto l00000221; l00000221: - call R0_4, Gamma_R0_4, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_6, Gamma_R1_6, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_4, Gamma_R2_4, R30_5, Gamma_R30_5, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2 := __printf_chk(1bv64, true, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, 2120bv64, true, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, 42bv64, true, 1712bv64, true, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1); + assume {:captureState "l00000221"} true; + R2, Gamma_R2 := 42bv64, true; + R1, Gamma_R1 := 0bv64, true; + R0, Gamma_R0 := 1bv64, true; + R1, Gamma_R1 := bvadd64(R1, 2120bv64), Gamma_R1; + R30, Gamma_R30 := 1712bv64, true; + call __printf_chk(); goto l0000023d; l0000023d: - call R0_6, Gamma_R0_6, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_9, Gamma_R1_9, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_6, Gamma_R2_6, R30_7, Gamma_R30_7, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_3, Gamma_R8_3, R9_3, Gamma_R9_3 := __printf_chk(1bv64, true, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, 2136bv64, true, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, 10bv64, true, 1732bv64, true, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2); + assume {:captureState "l0000023d"} true; + R2, Gamma_R2 := 10bv64, true; + R1, Gamma_R1 := 0bv64, true; + R0, Gamma_R0 := 1bv64, true; + R1, Gamma_R1 := bvadd64(R1, 2136bv64), Gamma_R1; + R30, Gamma_R30 := 1732bv64, true; + call __printf_chk(); goto l00000259; l00000259: - R29_6, Gamma_R29_6 := memory_load64_le(stack, R31_5), gamma_load64(Gamma_stack, R31_5); - R30_8, Gamma_R30_8 := memory_load64_le(stack, bvadd64(R31_5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 8bv64)); + assume {:captureState "l00000259"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R2_out, R30_out, R31_out := 0bv64, R1_9, R29_6, R2_6, R30_8, bvadd64(R31_5, 16bv64); - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_9, Gamma_R29_6, Gamma_R2_6, Gamma_R30_8, Gamma_R31_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/malloc_with_local/gcc_O2/malloc_with_local_gtirb.expected b/src/test/correct/malloc_with_local/gcc_O2/malloc_with_local_gtirb.expected index 2dd693da0..3b14ada56 100644 --- a/src/test/correct/malloc_with_local/gcc_O2/malloc_with_local_gtirb.expected +++ b/src/test/correct/malloc_with_local/gcc_O2/malloc_with_local_gtirb.expected @@ -1,33 +1,36 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2088bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { @@ -39,13 +42,13 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2088bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2096bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2104bv64) == 748482783423457568bv64); @@ -65,8 +68,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -79,8 +82,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_620(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_620(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2088bv64) == 131073bv64); free requires (memory_load64_le(mem, 2096bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2104bv64) == 748482783423457568bv64); @@ -114,143 +117,20 @@ procedure FUN_620(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 1664bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_620(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_620() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_620$__0__$qaPbEwmeQ4Or9EH8own00w: + assume {:captureState "$FUN_620$__0__$qaPbEwmeQ4Or9EH8own00w"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69560bv64), (gamma_load64(Gamma_mem, 69560bv64) || L(mem, 69560bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := __printf_chk(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69560bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4024bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4024bv64)) || L(mem, bvadd64(R16, 4024bv64))); + R16, Gamma_R16 := bvadd64(R16, 4024bv64), Gamma_R16; + call __printf_chk(); assume false; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R2, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R2, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2088bv64) == 131073bv64); @@ -269,6 +149,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69016bv64) == 1984bv64); free requires (memory_load64_le(mem, 69616bv64) == 1664bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2088bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2096bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2104bv64) == 748482783423457568bv64); @@ -286,48 +170,57 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 1664bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R29_3: bool; - var Gamma_R30_5: bool; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R29_3: bv64; - var R30_5: bv64; + var Cse0__5$2$0: bv64; + var Gamma_Cse0__5$2$0: bool; $main$__0__$ItZEqVtrTPCOwqXa82Hwsg: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_620(R16, Gamma_R16); + assume {:captureState "$main$__0__$ItZEqVtrTPCOwqXa82Hwsg"} true; + Cse0__5$2$0, Gamma_Cse0__5$2$0 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$2$0, R29), gamma_store64(Gamma_stack, Cse0__5$2$0, Gamma_R29); + assume {:captureState "1664$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$2$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$2$0, 8bv64), Gamma_R30); + assume {:captureState "1664$2"} true; + R31, Gamma_R31 := Cse0__5$2$0, Gamma_Cse0__5$2$0; + R2, Gamma_R2 := 65bv64, true; + R1, Gamma_R1 := 0bv64, true; + R29, Gamma_R29 := R31, Gamma_R31; + R1, Gamma_R1 := bvadd64(R1, 2096bv64), Gamma_R1; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 1692bv64, true; + call FUN_620(); goto $main$__1__$6_uJfVJBSzy6iG4r9DVpgQ; $main$__1__$6_uJfVJBSzy6iG4r9DVpgQ: - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := FUN_620(R16_1, Gamma_R16_1); + assume {:captureState "$main$__1__$6_uJfVJBSzy6iG4r9DVpgQ"} true; + R2, Gamma_R2 := 42bv64, true; + R1, Gamma_R1 := 0bv64, true; + R0, Gamma_R0 := 1bv64, true; + R1, Gamma_R1 := bvadd64(R1, 2120bv64), Gamma_R1; + R30, Gamma_R30 := 1712bv64, true; + call FUN_620(); goto $main$__2__$fcYUL~TbQFeL~A7mbUFIWQ; $main$__2__$fcYUL~TbQFeL~A7mbUFIWQ: - call R16_3, Gamma_R16_3, R17_3, Gamma_R17_3 := FUN_620(R16_2, Gamma_R16_2); + assume {:captureState "$main$__2__$fcYUL~TbQFeL~A7mbUFIWQ"} true; + R2, Gamma_R2 := 10bv64, true; + R1, Gamma_R1 := 0bv64, true; + R0, Gamma_R0 := 1bv64, true; + R1, Gamma_R1 := bvadd64(R1, 2136bv64), Gamma_R1; + R30, Gamma_R30 := 1732bv64, true; + call FUN_620(); goto $main$__3__$Yc641wYvRgyME32XFwFaxw; $main$__3__$Yc641wYvRgyME32XFwFaxw: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_5, Gamma_R30_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__3__$Yc641wYvRgyME32XFwFaxw"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R1_out, R29_out, R2_out, R30_out, R31_out := 0bv64, R16_3, R17_3, 2136bv64, R29_3, 10bv64, R30_5, R31_in; - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R1_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R16_3, Gamma_R17_3, true, Gamma_R29_3, true, Gamma_R30_5, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } -procedure __printf_chk(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure __printf_chk(); free requires (memory_load64_le(mem, 2088bv64) == 131073bv64); free requires (memory_load64_le(mem, 2096bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2104bv64) == 748482783423457568bv64); diff --git a/src/test/correct/malloc_with_local2/clang/malloc_with_local2.expected b/src/test/correct/malloc_with_local2/clang/malloc_with_local2.expected index d0d80f95d..b2883ffa9 100644 --- a/src/test/correct/malloc_with_local2/clang/malloc_with_local2.expected +++ b/src/test/correct/malloc_with_local2/clang/malloc_with_local2.expected @@ -1,32 +1,32 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2292bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -40,21 +40,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -68,23 +64,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load8_le(mem, 2292bv64) == 1bv8); free ensures (memory_load8_le(mem, 2293bv64) == 0bv8); free ensures (memory_load8_le(mem, 2294bv64) == 2bv8); @@ -107,8 +103,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -121,7 +117,7 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load8_le(mem, 2292bv64) == 1bv8); free requires (memory_load8_le(mem, 2293bv64) == 0bv8); @@ -162,8 +158,8 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69688bv64) == 0bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); free requires (memory_load8_le(mem, 2292bv64) == 1bv8); @@ -185,6 +181,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1984bv64); free requires (memory_load64_le(mem, 69592bv64) == 2068bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load8_le(mem, 2292bv64) == 1bv8); free ensures (memory_load8_le(mem, 2293bv64) == 0bv8); free ensures (memory_load8_le(mem, 2294bv64) == 2bv8); @@ -205,672 +205,126 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_12: bool; - var Gamma_R0_15: bool; - var Gamma_R0_16: bool; - var Gamma_R0_17: bool; - var Gamma_R0_18: bool; - var Gamma_R0_19: bool; - var Gamma_R0_2: bool; - var Gamma_R0_20: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_9: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R10_2: bool; - var Gamma_R10_3: bool; - var Gamma_R10_4: bool; - var Gamma_R10_5: bool; - var Gamma_R10_6: bool; - var Gamma_R10_7: bool; - var Gamma_R10_8: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R11_2: bool; - var Gamma_R11_3: bool; - var Gamma_R11_4: bool; - var Gamma_R11_5: bool; - var Gamma_R11_6: bool; - var Gamma_R11_7: bool; - var Gamma_R11_8: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R12_2: bool; - var Gamma_R12_3: bool; - var Gamma_R12_4: bool; - var Gamma_R12_5: bool; - var Gamma_R12_6: bool; - var Gamma_R12_7: bool; - var Gamma_R12_8: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R13_2: bool; - var Gamma_R13_3: bool; - var Gamma_R13_4: bool; - var Gamma_R13_5: bool; - var Gamma_R13_6: bool; - var Gamma_R13_7: bool; - var Gamma_R13_8: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R14_2: bool; - var Gamma_R14_3: bool; - var Gamma_R14_4: bool; - var Gamma_R14_5: bool; - var Gamma_R14_6: bool; - var Gamma_R14_7: bool; - var Gamma_R14_8: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R15_2: bool; - var Gamma_R15_3: bool; - var Gamma_R15_4: bool; - var Gamma_R15_5: bool; - var Gamma_R15_6: bool; - var Gamma_R15_7: bool; - var Gamma_R15_8: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R16_7: bool; - var Gamma_R16_8: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R17_7: bool; - var Gamma_R17_8: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R18_2: bool; - var Gamma_R18_3: bool; - var Gamma_R18_4: bool; - var Gamma_R18_5: bool; - var Gamma_R18_6: bool; - var Gamma_R18_7: bool; - var Gamma_R18_8: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R19_2: bool; - var Gamma_R19_3: bool; - var Gamma_R19_4: bool; - var Gamma_R19_5: bool; - var Gamma_R19_6: bool; - var Gamma_R19_7: bool; - var Gamma_R19_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_10: bool; - var Gamma_R1_11: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var Gamma_R1_6: bool; - var Gamma_R1_7: bool; - var Gamma_R1_8: bool; - var Gamma_R1_9: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R20_2: bool; - var Gamma_R20_3: bool; - var Gamma_R20_4: bool; - var Gamma_R20_5: bool; - var Gamma_R20_6: bool; - var Gamma_R20_7: bool; - var Gamma_R20_8: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R21_2: bool; - var Gamma_R21_3: bool; - var Gamma_R21_4: bool; - var Gamma_R21_5: bool; - var Gamma_R21_6: bool; - var Gamma_R21_7: bool; - var Gamma_R21_8: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R22_2: bool; - var Gamma_R22_3: bool; - var Gamma_R22_4: bool; - var Gamma_R22_5: bool; - var Gamma_R22_6: bool; - var Gamma_R22_7: bool; - var Gamma_R22_8: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R23_2: bool; - var Gamma_R23_3: bool; - var Gamma_R23_4: bool; - var Gamma_R23_5: bool; - var Gamma_R23_6: bool; - var Gamma_R23_7: bool; - var Gamma_R23_8: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R24_2: bool; - var Gamma_R24_3: bool; - var Gamma_R24_4: bool; - var Gamma_R24_5: bool; - var Gamma_R24_6: bool; - var Gamma_R24_7: bool; - var Gamma_R24_8: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R25_2: bool; - var Gamma_R25_3: bool; - var Gamma_R25_4: bool; - var Gamma_R25_5: bool; - var Gamma_R25_6: bool; - var Gamma_R25_7: bool; - var Gamma_R25_8: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R26_2: bool; - var Gamma_R26_3: bool; - var Gamma_R26_4: bool; - var Gamma_R26_5: bool; - var Gamma_R26_6: bool; - var Gamma_R26_7: bool; - var Gamma_R26_8: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R27_2: bool; - var Gamma_R27_3: bool; - var Gamma_R27_4: bool; - var Gamma_R27_5: bool; - var Gamma_R27_6: bool; - var Gamma_R27_7: bool; - var Gamma_R27_8: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R28_2: bool; - var Gamma_R28_3: bool; - var Gamma_R28_4: bool; - var Gamma_R28_5: bool; - var Gamma_R28_6: bool; - var Gamma_R28_7: bool; - var Gamma_R28_8: bool; - var Gamma_R29_10: bool; - var Gamma_R29_11: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R29_5: bool; - var Gamma_R29_6: bool; - var Gamma_R29_7: bool; - var Gamma_R29_8: bool; - var Gamma_R29_9: bool; - var Gamma_R2_1: bool; - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var Gamma_R2_4: bool; - var Gamma_R2_5: bool; - var Gamma_R2_6: bool; - var Gamma_R2_7: bool; - var Gamma_R2_8: bool; - var Gamma_R3: bool; - var Gamma_R30_11: bool; - var Gamma_R30_13: bool; - var Gamma_R30_15: bool; - var Gamma_R30_17: bool; - var Gamma_R30_18: bool; - var Gamma_R30_3: bool; - var Gamma_R30_5: bool; - var Gamma_R30_7: bool; - var Gamma_R30_9: bool; - var Gamma_R31_10: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R31_5: bool; - var Gamma_R31_6: bool; - var Gamma_R31_7: bool; - var Gamma_R31_8: bool; - var Gamma_R31_9: bool; - var Gamma_R3_1: bool; - var Gamma_R3_2: bool; - var Gamma_R3_3: bool; - var Gamma_R3_4: bool; - var Gamma_R3_5: bool; - var Gamma_R3_6: bool; - var Gamma_R3_7: bool; - var Gamma_R3_8: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R4_2: bool; - var Gamma_R4_3: bool; - var Gamma_R4_4: bool; - var Gamma_R4_5: bool; - var Gamma_R4_6: bool; - var Gamma_R4_7: bool; - var Gamma_R4_8: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R5_2: bool; - var Gamma_R5_3: bool; - var Gamma_R5_4: bool; - var Gamma_R5_5: bool; - var Gamma_R5_6: bool; - var Gamma_R5_7: bool; - var Gamma_R5_8: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R6_2: bool; - var Gamma_R6_3: bool; - var Gamma_R6_4: bool; - var Gamma_R6_5: bool; - var Gamma_R6_6: bool; - var Gamma_R6_7: bool; - var Gamma_R6_8: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R7_2: bool; - var Gamma_R7_3: bool; - var Gamma_R7_4: bool; - var Gamma_R7_5: bool; - var Gamma_R7_6: bool; - var Gamma_R7_7: bool; - var Gamma_R7_8: bool; - var Gamma_R8_11: bool; - var Gamma_R8_12: bool; - var Gamma_R8_13: bool; - var Gamma_R8_14: bool; - var Gamma_R8_15: bool; - var Gamma_R8_16: bool; - var Gamma_R8_17: bool; - var Gamma_R8_2: bool; - var Gamma_R8_4: bool; - var Gamma_R8_7: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_10: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var Gamma_R9_4: bool; - var Gamma_R9_5: bool; - var Gamma_R9_6: bool; - var Gamma_R9_7: bool; - var Gamma_R9_8: bool; - var Gamma_R9_9: bool; - var R0_12: bv64; - var R0_15: bv64; - var R0_16: bv64; - var R0_17: bv64; - var R0_18: bv64; - var R0_19: bv64; - var R0_2: bv64; - var R0_20: bv64; - var R0_4: bv64; - var R0_5: bv64; - var R0_6: bv64; - var R0_9: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R10_2: bv64; - var R10_3: bv64; - var R10_4: bv64; - var R10_5: bv64; - var R10_6: bv64; - var R10_7: bv64; - var R10_8: bv64; - var R11: bv64; - var R11_1: bv64; - var R11_2: bv64; - var R11_3: bv64; - var R11_4: bv64; - var R11_5: bv64; - var R11_6: bv64; - var R11_7: bv64; - var R11_8: bv64; - var R12: bv64; - var R12_1: bv64; - var R12_2: bv64; - var R12_3: bv64; - var R12_4: bv64; - var R12_5: bv64; - var R12_6: bv64; - var R12_7: bv64; - var R12_8: bv64; - var R13: bv64; - var R13_1: bv64; - var R13_2: bv64; - var R13_3: bv64; - var R13_4: bv64; - var R13_5: bv64; - var R13_6: bv64; - var R13_7: bv64; - var R13_8: bv64; - var R14: bv64; - var R14_1: bv64; - var R14_2: bv64; - var R14_3: bv64; - var R14_4: bv64; - var R14_5: bv64; - var R14_6: bv64; - var R14_7: bv64; - var R14_8: bv64; - var R15: bv64; - var R15_1: bv64; - var R15_2: bv64; - var R15_3: bv64; - var R15_4: bv64; - var R15_5: bv64; - var R15_6: bv64; - var R15_7: bv64; - var R15_8: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R16_7: bv64; - var R16_8: bv64; - var R17: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R17_7: bv64; - var R17_8: bv64; - var R18: bv64; - var R18_1: bv64; - var R18_2: bv64; - var R18_3: bv64; - var R18_4: bv64; - var R18_5: bv64; - var R18_6: bv64; - var R18_7: bv64; - var R18_8: bv64; - var R19: bv64; - var R19_1: bv64; - var R19_2: bv64; - var R19_3: bv64; - var R19_4: bv64; - var R19_5: bv64; - var R19_6: bv64; - var R19_7: bv64; - var R19_8: bv64; - var R1_1: bv64; - var R1_10: bv64; - var R1_11: bv64; - var R1_2: bv64; - var R1_3: bv64; - var R1_4: bv64; - var R1_5: bv64; - var R1_6: bv64; - var R1_7: bv64; - var R1_8: bv64; - var R1_9: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R20_2: bv64; - var R20_3: bv64; - var R20_4: bv64; - var R20_5: bv64; - var R20_6: bv64; - var R20_7: bv64; - var R20_8: bv64; - var R21: bv64; - var R21_1: bv64; - var R21_2: bv64; - var R21_3: bv64; - var R21_4: bv64; - var R21_5: bv64; - var R21_6: bv64; - var R21_7: bv64; - var R21_8: bv64; - var R22: bv64; - var R22_1: bv64; - var R22_2: bv64; - var R22_3: bv64; - var R22_4: bv64; - var R22_5: bv64; - var R22_6: bv64; - var R22_7: bv64; - var R22_8: bv64; - var R23: bv64; - var R23_1: bv64; - var R23_2: bv64; - var R23_3: bv64; - var R23_4: bv64; - var R23_5: bv64; - var R23_6: bv64; - var R23_7: bv64; - var R23_8: bv64; - var R24: bv64; - var R24_1: bv64; - var R24_2: bv64; - var R24_3: bv64; - var R24_4: bv64; - var R24_5: bv64; - var R24_6: bv64; - var R24_7: bv64; - var R24_8: bv64; - var R25: bv64; - var R25_1: bv64; - var R25_2: bv64; - var R25_3: bv64; - var R25_4: bv64; - var R25_5: bv64; - var R25_6: bv64; - var R25_7: bv64; - var R25_8: bv64; - var R26: bv64; - var R26_1: bv64; - var R26_2: bv64; - var R26_3: bv64; - var R26_4: bv64; - var R26_5: bv64; - var R26_6: bv64; - var R26_7: bv64; - var R26_8: bv64; - var R27: bv64; - var R27_1: bv64; - var R27_2: bv64; - var R27_3: bv64; - var R27_4: bv64; - var R27_5: bv64; - var R27_6: bv64; - var R27_7: bv64; - var R27_8: bv64; - var R28: bv64; - var R28_1: bv64; - var R28_2: bv64; - var R28_3: bv64; - var R28_4: bv64; - var R28_5: bv64; - var R28_6: bv64; - var R28_7: bv64; - var R28_8: bv64; - var R29_10: bv64; - var R29_11: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R29_5: bv64; - var R29_6: bv64; - var R29_7: bv64; - var R29_8: bv64; - var R29_9: bv64; - var R2_1: bv64; - var R2_2: bv64; - var R2_3: bv64; - var R2_4: bv64; - var R2_5: bv64; - var R2_6: bv64; - var R2_7: bv64; - var R2_8: bv64; - var R3: bv64; - var R30_11: bv64; - var R30_13: bv64; - var R30_15: bv64; - var R30_17: bv64; - var R30_18: bv64; - var R30_3: bv64; - var R30_5: bv64; - var R30_7: bv64; - var R30_9: bv64; - var R31_10: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R31_5: bv64; - var R31_6: bv64; - var R31_7: bv64; - var R31_8: bv64; - var R31_9: bv64; - var R3_1: bv64; - var R3_2: bv64; - var R3_3: bv64; - var R3_4: bv64; - var R3_5: bv64; - var R3_6: bv64; - var R3_7: bv64; - var R3_8: bv64; - var R4: bv64; - var R4_1: bv64; - var R4_2: bv64; - var R4_3: bv64; - var R4_4: bv64; - var R4_5: bv64; - var R4_6: bv64; - var R4_7: bv64; - var R4_8: bv64; - var R5: bv64; - var R5_1: bv64; - var R5_2: bv64; - var R5_3: bv64; - var R5_4: bv64; - var R5_5: bv64; - var R5_6: bv64; - var R5_7: bv64; - var R5_8: bv64; - var R6: bv64; - var R6_1: bv64; - var R6_2: bv64; - var R6_3: bv64; - var R6_4: bv64; - var R6_5: bv64; - var R6_6: bv64; - var R6_7: bv64; - var R6_8: bv64; - var R7: bv64; - var R7_1: bv64; - var R7_2: bv64; - var R7_3: bv64; - var R7_4: bv64; - var R7_5: bv64; - var R7_6: bv64; - var R7_7: bv64; - var R7_8: bv64; - var R8_11: bv64; - var R8_12: bv64; - var R8_13: bv64; - var R8_14: bv64; - var R8_15: bv64; - var R8_16: bv64; - var R8_17: bv64; - var R8_2: bv64; - var R8_4: bv64; - var R8_7: bv64; - var R9: bv64; - var R9_1: bv64; - var R9_10: bv64; - var R9_2: bv64; - var R9_3: bv64; - var R9_4: bv64; - var R9_5: bv64; - var R9_6: bv64; - var R9_7: bv64; - var R9_8: bv64; - var R9_9: bv64; + var #4: bv64; + var #5: bv64; + var Gamma_#4: bool; + var Gamma_#5: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551544bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551544bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_2, Gamma_R8_2, R9_1, Gamma_R9_1 := malloc(1bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, R2, Gamma_R2, 2100bv64, true, bvadd64(R31_in, 18446744073709551536bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, 0bv64, true, R9, Gamma_R9); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551536bv64), Gamma_R31; + #4, Gamma_#4 := bvadd64(R31, 64bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000386"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000038c"} true; + R29, Gamma_R29 := bvadd64(R31, 64bv64), Gamma_R31; + R8, Gamma_R8 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000039f"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%000003a6"} true; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2100bv64, true; + call malloc(); goto l000003b5; l000003b5: - call rely(); - assert (L(mem, bvadd64(R29_3, 18446744073709551600bv64)) ==> Gamma_R0_2); - mem, Gamma_mem := memory_store64_le(mem, bvadd64(R29_3, 18446744073709551600bv64), R0_2), gamma_store64(Gamma_mem, bvadd64(R29_3, 18446744073709551600bv64), Gamma_R0_2); - call rely(); - assert (L(mem, bvadd64(R29_3, 18446744073709551596bv64)) ==> true); - mem, Gamma_mem := memory_store32_le(mem, bvadd64(R29_3, 18446744073709551596bv64), 11bv32), gamma_store32(Gamma_mem, bvadd64(R29_3, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store64_le(stack, R31_3, 4bv64), gamma_store64(Gamma_stack, R31_3, true); - call R0_4, Gamma_R0_4, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_2, Gamma_R1_2, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, R30_5, Gamma_R30_5, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_4, Gamma_R8_4, R9_2, Gamma_R9_2 := malloc(4bv64, true, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, 2124bv64, true, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, 11bv64, true, R9_1, Gamma_R9_1); + assume {:captureState "l000003b5"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R29, 18446744073709551600bv64), R0), gamma_store64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64), Gamma_R0); + assume {:captureState "%000003bb"} true; + R8, Gamma_R8 := 11bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551596bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551596bv64), Gamma_R8); + assume {:captureState "%000003c8"} true; + R0, Gamma_R0 := 4bv64, true; + stack, Gamma_stack := memory_store64_le(stack, R31, R0), gamma_store64(Gamma_stack, R31, Gamma_R0); + assume {:captureState "%000003d5"} true; + R30, Gamma_R30 := 2124bv64, true; + call malloc(); goto l000003de; l000003de: - R0_5, Gamma_R0_5 := memory_load64_le(stack, R31_4), gamma_load64(Gamma_stack, R31_4); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_4, 32bv64), R0_4), gamma_store64(Gamma_stack, bvadd64(R31_4, 32bv64), Gamma_R0_4); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_4, 28bv64), 10bv32), gamma_store32(Gamma_stack, bvadd64(R31_4, 28bv64), true); - call R0_6, Gamma_R0_6, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_3, Gamma_R1_3, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, R30_7, Gamma_R30_7, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_7, Gamma_R8_7, R9_3, Gamma_R9_3 := malloc(R0_5, Gamma_R0_5, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_2, Gamma_R1_2, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, 2148bv64, true, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, 10bv64, true, R9_2, Gamma_R9_2); + assume {:captureState "l000003de"} true; + R8, Gamma_R8 := R0, Gamma_R0; + R0, Gamma_R0 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R8); + assume {:captureState "%000003f1"} true; + R8, Gamma_R8 := 10bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "%000003fe"} true; + R30, Gamma_R30 := 2148bv64, true; + call malloc(); goto l00000407; l00000407: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_5, 16bv64), R0_6), gamma_store64(Gamma_stack, bvadd64(R31_5, 16bv64), Gamma_R0_6); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_5, 12bv64), 9bv32), gamma_store32(Gamma_stack, bvadd64(R31_5, 12bv64), true); + assume {:captureState "l00000407"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%0000040d"} true; + R8, Gamma_R8 := 9bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%0000041a"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); + R8, Gamma_R8 := 65bv64, true; call rely(); - R9_4, Gamma_R9_4 := memory_load64_le(mem, bvadd64(R29_5, 18446744073709551600bv64)), (gamma_load64(Gamma_mem, bvadd64(R29_5, 18446744073709551600bv64)) || L(mem, bvadd64(R29_5, 18446744073709551600bv64))); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%0000042e"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + R8, Gamma_R8 := 42bv64, true; call rely(); - assert (L(mem, R9_4) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R9_4, 65bv8), gamma_store8(Gamma_mem, R9_4, true); - R9_5, Gamma_R9_5 := memory_load64_le(stack, bvadd64(R31_5, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 32bv64)); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000442"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); call rely(); - assert (L(mem, R9_5) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_5, 42bv32), gamma_store32(Gamma_mem, R9_5, true); - call rely(); - R8_11, Gamma_R8_11 := memory_load64_le(mem, bvadd64(R29_5, 18446744073709551600bv64)), (gamma_load64(Gamma_mem, bvadd64(R29_5, 18446744073709551600bv64)) || L(mem, bvadd64(R29_5, 18446744073709551600bv64))); - call rely(); - R1_4, Gamma_R1_4 := zero_extend56_8(memory_load8_le(mem, R8_11)), (gamma_load8(Gamma_mem, R8_11) || L(mem, R8_11)); - call R0_9, Gamma_R0_9, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_5, Gamma_R1_5, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, R30_9, Gamma_R30_9, R31_6, Gamma_R31_6, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_12, Gamma_R8_12, R9_6, Gamma_R9_6 := printf(2296bv64, true, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_4, Gamma_R1_4, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, 2204bv64, true, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_11, Gamma_R8_11, R9_5, Gamma_R9_5); + R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2296bv64), Gamma_R0; + R30, Gamma_R30 := 2204bv64, true; + call printf(); goto l00000465; l00000465: - R8_13, Gamma_R8_13 := memory_load64_le(stack, bvadd64(R31_6, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_6, 32bv64)); + assume {:captureState "l00000465"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); call rely(); - R1_6, Gamma_R1_6 := zero_extend32_32(memory_load32_le(mem, R8_13)), (gamma_load32(Gamma_mem, R8_13) || L(mem, R8_13)); - call R0_12, Gamma_R0_12, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_7, Gamma_R1_7, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, R30_11, Gamma_R30_11, R31_7, Gamma_R31_7, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_14, Gamma_R8_14, R9_7, Gamma_R9_7 := printf(2313bv64, true, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_6, Gamma_R1_6, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, 2224bv64, true, R31_6, Gamma_R31_6, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_13, Gamma_R8_13, R9_6, Gamma_R9_6); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2313bv64), Gamma_R0; + R30, Gamma_R30 := 2224bv64, true; + call printf(); goto l00000485; l00000485: - R1_8, Gamma_R1_8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_7, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31_7, 28bv64)); - call R0_15, Gamma_R0_15, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_9, Gamma_R1_9, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_8, Gamma_R29_8, R2_6, Gamma_R2_6, R30_13, Gamma_R30_13, R31_8, Gamma_R31_8, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_15, Gamma_R8_15, R9_8, Gamma_R9_8 := printf(2329bv64, true, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_8, Gamma_R1_8, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, 2240bv64, true, R31_7, Gamma_R31_7, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_14, Gamma_R8_14, R9_7, Gamma_R9_7); + assume {:captureState "l00000485"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2329bv64), Gamma_R0; + R30, Gamma_R30 := 2240bv64, true; + call printf(); goto l0000049e; l0000049e: - call rely(); - R0_16, Gamma_R0_16 := memory_load64_le(mem, bvadd64(R29_8, 18446744073709551600bv64)), (gamma_load64(Gamma_mem, bvadd64(R29_8, 18446744073709551600bv64)) || L(mem, bvadd64(R29_8, 18446744073709551600bv64))); - call R0_17, Gamma_R0_17, R10_7, Gamma_R10_7, R11_7, Gamma_R11_7, R12_7, Gamma_R12_7, R13_7, Gamma_R13_7, R14_7, Gamma_R14_7, R15_7, Gamma_R15_7, R16_7, Gamma_R16_7, R17_7, Gamma_R17_7, R18_7, Gamma_R18_7, R19_7, Gamma_R19_7, R1_10, Gamma_R1_10, R20_7, Gamma_R20_7, R21_7, Gamma_R21_7, R22_7, Gamma_R22_7, R23_7, Gamma_R23_7, R24_7, Gamma_R24_7, R25_7, Gamma_R25_7, R26_7, Gamma_R26_7, R27_7, Gamma_R27_7, R28_7, Gamma_R28_7, R29_9, Gamma_R29_9, R2_7, Gamma_R2_7, R30_15, Gamma_R30_15, R31_9, Gamma_R31_9, R3_7, Gamma_R3_7, R4_7, Gamma_R4_7, R5_7, Gamma_R5_7, R6_7, Gamma_R6_7, R7_7, Gamma_R7_7, R8_16, Gamma_R8_16, R9_9, Gamma_R9_9 := #free(R0_16, Gamma_R0_16, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_9, Gamma_R1_9, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_8, Gamma_R29_8, R2_6, Gamma_R2_6, 2248bv64, true, R31_8, Gamma_R31_8, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_15, Gamma_R8_15, R9_8, Gamma_R9_8); + assume {:captureState "l0000049e"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); + R30, Gamma_R30 := 2248bv64, true; + call #free(); goto l000004ad; l000004ad: - R0_18, Gamma_R0_18 := memory_load64_le(stack, bvadd64(R31_9, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_9, 32bv64)); - call R0_19, Gamma_R0_19, R10_8, Gamma_R10_8, R11_8, Gamma_R11_8, R12_8, Gamma_R12_8, R13_8, Gamma_R13_8, R14_8, Gamma_R14_8, R15_8, Gamma_R15_8, R16_8, Gamma_R16_8, R17_8, Gamma_R17_8, R18_8, Gamma_R18_8, R19_8, Gamma_R19_8, R1_11, Gamma_R1_11, R20_8, Gamma_R20_8, R21_8, Gamma_R21_8, R22_8, Gamma_R22_8, R23_8, Gamma_R23_8, R24_8, Gamma_R24_8, R25_8, Gamma_R25_8, R26_8, Gamma_R26_8, R27_8, Gamma_R27_8, R28_8, Gamma_R28_8, R29_10, Gamma_R29_10, R2_8, Gamma_R2_8, R30_17, Gamma_R30_17, R31_10, Gamma_R31_10, R3_8, Gamma_R3_8, R4_8, Gamma_R4_8, R5_8, Gamma_R5_8, R6_8, Gamma_R6_8, R7_8, Gamma_R7_8, R8_17, Gamma_R8_17, R9_10, Gamma_R9_10 := #free(R0_18, Gamma_R0_18, R10_7, Gamma_R10_7, R11_7, Gamma_R11_7, R12_7, Gamma_R12_7, R13_7, Gamma_R13_7, R14_7, Gamma_R14_7, R15_7, Gamma_R15_7, R16_7, Gamma_R16_7, R17_7, Gamma_R17_7, R18_7, Gamma_R18_7, R19_7, Gamma_R19_7, R1_10, Gamma_R1_10, R20_7, Gamma_R20_7, R21_7, Gamma_R21_7, R22_7, Gamma_R22_7, R23_7, Gamma_R23_7, R24_7, Gamma_R24_7, R25_7, Gamma_R25_7, R26_7, Gamma_R26_7, R27_7, Gamma_R27_7, R28_7, Gamma_R28_7, R29_9, Gamma_R29_9, R2_7, Gamma_R2_7, 2256bv64, true, R31_9, Gamma_R31_9, R3_7, Gamma_R3_7, R4_7, Gamma_R4_7, R5_7, Gamma_R5_7, R6_7, Gamma_R6_7, R7_7, Gamma_R7_7, R8_16, Gamma_R8_16, R9_9, Gamma_R9_9); + assume {:captureState "l000004ad"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + R30, Gamma_R30 := 2256bv64, true; + call #free(); goto l000004bb; l000004bb: - R0_20, Gamma_R0_20 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_10, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31_10, 8bv64)); - R29_11, Gamma_R29_11 := memory_load64_le(stack, bvadd64(R31_10, 64bv64)), gamma_load64(Gamma_stack, bvadd64(R31_10, 64bv64)); - R30_18, Gamma_R30_18 := memory_load64_le(stack, bvadd64(R31_10, 72bv64)), gamma_load64(Gamma_stack, bvadd64(R31_10, 72bv64)); + assume {:captureState "l000004bb"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + #5, Gamma_#5 := bvadd64(R31, 64bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#5, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 80bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out, R8_out, R9_out := R0_20, R1_11, R29_11, R30_18, bvadd64(R31_10, 80bv64), R8_17, R9_10; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_20, Gamma_R1_11, Gamma_R29_11, Gamma_R30_18, Gamma_R31_10, Gamma_R8_17, Gamma_R9_10; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load8_le(mem, 2292bv64) == 1bv8); free requires (memory_load8_le(mem, 2293bv64) == 0bv8); @@ -911,7 +365,7 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load8_le(mem, 2292bv64) == 1bv8); free requires (memory_load8_le(mem, 2293bv64) == 0bv8); diff --git a/src/test/correct/malloc_with_local2/clang/malloc_with_local2_gtirb.expected b/src/test/correct/malloc_with_local2/clang/malloc_with_local2_gtirb.expected index ea744f68f..076949b82 100644 --- a/src/test/correct/malloc_with_local2/clang/malloc_with_local2_gtirb.expected +++ b/src/test/correct/malloc_with_local2/clang/malloc_with_local2_gtirb.expected @@ -1,28 +1,32 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2292bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -31,22 +35,22 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { + gammaMap[index] +} + function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -60,22 +64,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load8_le(mem, 2292bv64) == 1bv8); free ensures (memory_load8_le(mem, 2293bv64) == 0bv8); free ensures (memory_load8_le(mem, 2294bv64) == 2bv8); @@ -98,8 +103,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -112,8 +117,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6c0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load8_le(mem, 2292bv64) == 1bv8); free requires (memory_load8_le(mem, 2293bv64) == 0bv8); free requires (memory_load8_le(mem, 2294bv64) == 2bv8); @@ -153,143 +158,20 @@ procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6c0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6c0$__0__$_Yurx7rnRDiQIbh1u7Z0dw: + assume {:captureState "$FUN_6c0$__0__$_Yurx7rnRDiQIbh1u7Z0dw"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69680bv64), (gamma_load64(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69680bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 48bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 48bv64)) || L(mem, bvadd64(R16, 48bv64))); + R16, Gamma_R16 := bvadd64(R16, 48bv64), Gamma_R16; + call printf(); assume false; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69688bv64) == 0bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); free requires (memory_load8_le(mem, 2292bv64) == 1bv8); @@ -311,6 +193,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1984bv64); free requires (memory_load64_le(mem, 69592bv64) == 2068bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load8_le(mem, 2292bv64) == 1bv8); free ensures (memory_load8_le(mem, 2293bv64) == 0bv8); free ensures (memory_load8_le(mem, 2294bv64) == 2bv8); @@ -331,117 +217,127 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_12: bool; - var Gamma_R0_3: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R16_7: bool; - var Gamma_R16_8: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R17_7: bool; - var Gamma_R17_8: bool; - var Gamma_R1_3: bool; - var Gamma_R29_3: bool; - var Gamma_R30_10: bool; - var Gamma_R8_9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var R0_12: bv64; - var R0_3: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R16_7: bv64; - var R16_8: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R17_7: bv64; - var R17_8: bv64; - var R1_3: bv64; - var R29_3: bv64; - var R30_10: bv64; - var R8_9: bv64; - var R9_1: bv64; - var R9_2: bv64; + var Cse0__5$0$1: bv64; + var Cse0__5$1$1: bv64; + var Gamma_Cse0__5$0$1: bool; + var Gamma_Cse0__5$1$1: bool; $main$__0__$yN1LokBAR9yRD4RMSXSfxQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551544bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551544bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_680(R16, Gamma_R16); + assume {:captureState "$main$__0__$yN1LokBAR9yRD4RMSXSfxQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551536bv64), Gamma_R31; + Cse0__5$0$1, Gamma_Cse0__5$0$1 := bvadd64(R31, 64bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$1, R29), gamma_store64(Gamma_stack, Cse0__5$0$1, Gamma_R29); + assume {:captureState "2072$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$1, 8bv64), Gamma_R30); + assume {:captureState "2072$2"} true; + R29, Gamma_R29 := bvadd64(R31, 64bv64), Gamma_R31; + R8, Gamma_R8 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "2084$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "2088$0"} true; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2100bv64, true; + call FUN_680(); goto $main$__1__$eCR9p3I6QnuW7E2ugOxN7g; $main$__1__$eCR9p3I6QnuW7E2ugOxN7g: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), 1bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551580bv64), 11bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64), true); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551536bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551536bv64), true); - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := FUN_680(R16_1, Gamma_R16_1); + assume {:captureState "$main$__1__$eCR9p3I6QnuW7E2ugOxN7g"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R29, 18446744073709551600bv64), R0), gamma_store64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64), Gamma_R0); + assume {:captureState "2100$0"} true; + R8, Gamma_R8 := 11bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551596bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551596bv64), Gamma_R8); + assume {:captureState "2108$0"} true; + R0, Gamma_R0 := 4bv64, true; + stack, Gamma_stack := memory_store64_le(stack, R31, R0), gamma_store64(Gamma_stack, R31, Gamma_R0); + assume {:captureState "2116$0"} true; + R30, Gamma_R30 := 2124bv64, true; + call FUN_680(); goto $main$__2__$FSETkqUYRWuqGvRhnzp0tA; $main$__2__$FSETkqUYRWuqGvRhnzp0tA: - R0_3, Gamma_R0_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551536bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551536bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551564bv64), 10bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551564bv64), true); - call R16_3, Gamma_R16_3, R17_3, Gamma_R17_3 := FUN_680(R16_2, Gamma_R16_2); + assume {:captureState "$main$__2__$FSETkqUYRWuqGvRhnzp0tA"} true; + R8, Gamma_R8 := R0, Gamma_R0; + R0, Gamma_R0 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R8); + assume {:captureState "2132$0"} true; + R8, Gamma_R8 := 10bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "2140$0"} true; + R30, Gamma_R30 := 2148bv64, true; + call FUN_680(); goto $main$__3__$trREPylQRuWIzMBYpyXfnQ; $main$__3__$trREPylQRuWIzMBYpyXfnQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551552bv64), R0_3), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551552bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551548bv64), 9bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551548bv64), true); - R9_1, Gamma_R9_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); + assume {:captureState "$main$__3__$trREPylQRuWIzMBYpyXfnQ"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "2148$0"} true; + R8, Gamma_R8 := 9bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "2156$0"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); + R8, Gamma_R8 := 65bv64, true; call rely(); - assert (L(mem, R9_1) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R9_1, 65bv8), gamma_store8(Gamma_mem, R9_1, true); - R9_2, Gamma_R9_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551568bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64)); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "2168$0"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + R8, Gamma_R8 := 42bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 42bv32), gamma_store32(Gamma_mem, R9_2, true); - call R16_4, Gamma_R16_4, R17_4, Gamma_R17_4 := FUN_6c0(R16_3, Gamma_R16_3); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "2180$0"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); + call rely(); + R1, Gamma_R1 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R8))), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2296bv64), Gamma_R0; + R30, Gamma_R30 := 2204bv64, true; + call FUN_6c0(); goto $main$__4__$qWMJh7qWT8yorxt1BpnoAg; $main$__4__$qWMJh7qWT8yorxt1BpnoAg: - R8_9, Gamma_R8_9 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551568bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64)); - call R16_5, Gamma_R16_5, R17_5, Gamma_R17_5 := FUN_6c0(R16_4, Gamma_R16_4); + assume {:captureState "$main$__4__$qWMJh7qWT8yorxt1BpnoAg"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + call rely(); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2313bv64), Gamma_R0; + R30, Gamma_R30 := 2224bv64, true; + call FUN_6c0(); goto $main$__5__$XGVqaesVShylRrbOWqzjFw; $main$__5__$XGVqaesVShylRrbOWqzjFw: - R1_3, Gamma_R1_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551564bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551564bv64)); - call R16_6, Gamma_R16_6, R17_6, Gamma_R17_6 := FUN_6c0(R16_5, Gamma_R16_5); + assume {:captureState "$main$__5__$XGVqaesVShylRrbOWqzjFw"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2329bv64), Gamma_R0; + R30, Gamma_R30 := 2240bv64, true; + call FUN_6c0(); goto $main$__6__$KOWJQzAnSc2QejZ1C9Zzjw; $main$__6__$KOWJQzAnSc2QejZ1C9Zzjw: - call R16_7, Gamma_R16_7, R17_7, Gamma_R17_7 := FUN_6b0(R16_6, Gamma_R16_6); + assume {:captureState "$main$__6__$KOWJQzAnSc2QejZ1C9Zzjw"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); + R30, Gamma_R30 := 2248bv64, true; + call FUN_6b0(); goto $main$__7__$XxlrxTEbSBSt~FnDRB3sPg; $main$__7__$XxlrxTEbSBSt~FnDRB3sPg: - call R16_8, Gamma_R16_8, R17_8, Gamma_R17_8 := FUN_6b0(R16_7, Gamma_R16_7); + assume {:captureState "$main$__7__$XxlrxTEbSBSt~FnDRB3sPg"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + R30, Gamma_R30 := 2256bv64, true; + call FUN_6b0(); goto $main$__8__$vRLqE2TDSi2s0PYIJ~bRSA; $main$__8__$vRLqE2TDSi2s0PYIJ~bRSA: - R0_12, Gamma_R0_12 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551544bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551544bv64)); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_10, Gamma_R30_10 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__8__$vRLqE2TDSi2s0PYIJ~bRSA"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + Cse0__5$1$1, Gamma_Cse0__5$1$1 := bvadd64(R31, 64bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$1$1), gamma_load64(Gamma_stack, Cse0__5$1$1); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$1$1, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$1$1, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 80bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R1_out, R29_out, R30_out, R31_out, R8_out, R9_out := R0_12, R16_8, R17_8, R1_3, R29_3, R30_10, R31_in, R8_9, R9_2; - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_12, Gamma_R16_8, Gamma_R17_8, Gamma_R1_3, Gamma_R29_3, Gamma_R30_10, Gamma_R31_in, Gamma_R8_9, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } -procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6b0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load8_le(mem, 2292bv64) == 1bv8); free requires (memory_load8_le(mem, 2293bv64) == 0bv8); free requires (memory_load8_le(mem, 2294bv64) == 2bv8); @@ -481,143 +377,20 @@ procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6b0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6b0$__0__$ftC9I58hTr~uInFEjp~qaQ: + assume {:captureState "$FUN_6b0$__0__$ftC9I58hTr~uInFEjp~qaQ"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69672bv64), (gamma_load64(Gamma_mem, 69672bv64) || L(mem, 69672bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := #free(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69672bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 40bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 40bv64)) || L(mem, bvadd64(R16, 40bv64))); + R16, Gamma_R16 := bvadd64(R16, 40bv64), Gamma_R16; + call #free(); assume false; } -procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_680(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load8_le(mem, 2292bv64) == 1bv8); free requires (memory_load8_le(mem, 2293bv64) == 0bv8); free requires (memory_load8_le(mem, 2294bv64) == 2bv8); @@ -657,142 +430,19 @@ procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_680() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_680$__0__$5~1SMMaYTnC_yOEStjKdRw: + assume {:captureState "$FUN_680$__0__$5~1SMMaYTnC_yOEStjKdRw"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69648bv64), (gamma_load64(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69648bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 16bv64)) || L(mem, bvadd64(R16, 16bv64))); + R16, Gamma_R16 := bvadd64(R16, 16bv64), Gamma_R16; + call malloc(); assume false; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load8_le(mem, 2292bv64) == 1bv8); free requires (memory_load8_le(mem, 2293bv64) == 0bv8); free requires (memory_load8_le(mem, 2294bv64) == 2bv8); @@ -832,7 +482,7 @@ procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); free requires (memory_load8_le(mem, 2292bv64) == 1bv8); free requires (memory_load8_le(mem, 2293bv64) == 0bv8); free requires (memory_load8_le(mem, 2294bv64) == 2bv8); @@ -872,7 +522,7 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); free requires (memory_load8_le(mem, 2292bv64) == 1bv8); free requires (memory_load8_le(mem, 2293bv64) == 0bv8); free requires (memory_load8_le(mem, 2294bv64) == 2bv8); diff --git a/src/test/correct/malloc_with_local2/gcc/malloc_with_local2.expected b/src/test/correct/malloc_with_local2/gcc/malloc_with_local2.expected index 894935975..553af7a9e 100644 --- a/src/test/correct/malloc_with_local2/gcc/malloc_with_local2.expected +++ b/src/test/correct/malloc_with_local2/gcc/malloc_with_local2.expected @@ -1,32 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2272bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -40,21 +36,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -68,23 +60,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2272bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2280bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2288bv64) == 748482783423457568bv64); @@ -104,8 +96,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -118,7 +110,7 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2272bv64) == 131073bv64); free requires (memory_load64_le(mem, 2280bv64) == 8241983568019286100bv64); @@ -153,8 +145,8 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2272bv64) == 131073bv64); @@ -173,6 +165,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69000bv64) == 1984bv64); free requires (memory_load64_le(mem, 69616bv64) == 2068bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2272bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2280bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2288bv64) == 748482783423457568bv64); @@ -190,664 +186,117 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_11: bool; - var Gamma_R0_12: bool; - var Gamma_R0_13: bool; - var Gamma_R0_16: bool; - var Gamma_R0_17: bool; - var Gamma_R0_18: bool; - var Gamma_R0_2: bool; - var Gamma_R0_21: bool; - var Gamma_R0_24: bool; - var Gamma_R0_25: bool; - var Gamma_R0_26: bool; - var Gamma_R0_27: bool; - var Gamma_R0_28: bool; - var Gamma_R0_5: bool; - var Gamma_R0_8: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R10_2: bool; - var Gamma_R10_3: bool; - var Gamma_R10_4: bool; - var Gamma_R10_5: bool; - var Gamma_R10_6: bool; - var Gamma_R10_7: bool; - var Gamma_R10_8: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R11_2: bool; - var Gamma_R11_3: bool; - var Gamma_R11_4: bool; - var Gamma_R11_5: bool; - var Gamma_R11_6: bool; - var Gamma_R11_7: bool; - var Gamma_R11_8: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R12_2: bool; - var Gamma_R12_3: bool; - var Gamma_R12_4: bool; - var Gamma_R12_5: bool; - var Gamma_R12_6: bool; - var Gamma_R12_7: bool; - var Gamma_R12_8: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R13_2: bool; - var Gamma_R13_3: bool; - var Gamma_R13_4: bool; - var Gamma_R13_5: bool; - var Gamma_R13_6: bool; - var Gamma_R13_7: bool; - var Gamma_R13_8: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R14_2: bool; - var Gamma_R14_3: bool; - var Gamma_R14_4: bool; - var Gamma_R14_5: bool; - var Gamma_R14_6: bool; - var Gamma_R14_7: bool; - var Gamma_R14_8: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R15_2: bool; - var Gamma_R15_3: bool; - var Gamma_R15_4: bool; - var Gamma_R15_5: bool; - var Gamma_R15_6: bool; - var Gamma_R15_7: bool; - var Gamma_R15_8: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R16_7: bool; - var Gamma_R16_8: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R17_7: bool; - var Gamma_R17_8: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R18_2: bool; - var Gamma_R18_3: bool; - var Gamma_R18_4: bool; - var Gamma_R18_5: bool; - var Gamma_R18_6: bool; - var Gamma_R18_7: bool; - var Gamma_R18_8: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R19_2: bool; - var Gamma_R19_3: bool; - var Gamma_R19_4: bool; - var Gamma_R19_5: bool; - var Gamma_R19_6: bool; - var Gamma_R19_7: bool; - var Gamma_R19_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_10: bool; - var Gamma_R1_11: bool; - var Gamma_R1_12: bool; - var Gamma_R1_13: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_6: bool; - var Gamma_R1_7: bool; - var Gamma_R1_8: bool; - var Gamma_R1_9: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R20_2: bool; - var Gamma_R20_3: bool; - var Gamma_R20_4: bool; - var Gamma_R20_5: bool; - var Gamma_R20_6: bool; - var Gamma_R20_7: bool; - var Gamma_R20_8: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R21_2: bool; - var Gamma_R21_3: bool; - var Gamma_R21_4: bool; - var Gamma_R21_5: bool; - var Gamma_R21_6: bool; - var Gamma_R21_7: bool; - var Gamma_R21_8: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R22_2: bool; - var Gamma_R22_3: bool; - var Gamma_R22_4: bool; - var Gamma_R22_5: bool; - var Gamma_R22_6: bool; - var Gamma_R22_7: bool; - var Gamma_R22_8: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R23_2: bool; - var Gamma_R23_3: bool; - var Gamma_R23_4: bool; - var Gamma_R23_5: bool; - var Gamma_R23_6: bool; - var Gamma_R23_7: bool; - var Gamma_R23_8: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R24_2: bool; - var Gamma_R24_3: bool; - var Gamma_R24_4: bool; - var Gamma_R24_5: bool; - var Gamma_R24_6: bool; - var Gamma_R24_7: bool; - var Gamma_R24_8: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R25_2: bool; - var Gamma_R25_3: bool; - var Gamma_R25_4: bool; - var Gamma_R25_5: bool; - var Gamma_R25_6: bool; - var Gamma_R25_7: bool; - var Gamma_R25_8: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R26_2: bool; - var Gamma_R26_3: bool; - var Gamma_R26_4: bool; - var Gamma_R26_5: bool; - var Gamma_R26_6: bool; - var Gamma_R26_7: bool; - var Gamma_R26_8: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R27_2: bool; - var Gamma_R27_3: bool; - var Gamma_R27_4: bool; - var Gamma_R27_5: bool; - var Gamma_R27_6: bool; - var Gamma_R27_7: bool; - var Gamma_R27_8: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R28_2: bool; - var Gamma_R28_3: bool; - var Gamma_R28_4: bool; - var Gamma_R28_5: bool; - var Gamma_R28_6: bool; - var Gamma_R28_7: bool; - var Gamma_R28_8: bool; - var Gamma_R29_10: bool; - var Gamma_R29_11: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R29_5: bool; - var Gamma_R29_6: bool; - var Gamma_R29_7: bool; - var Gamma_R29_8: bool; - var Gamma_R29_9: bool; - var Gamma_R2_1: bool; - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var Gamma_R2_4: bool; - var Gamma_R2_5: bool; - var Gamma_R2_6: bool; - var Gamma_R2_7: bool; - var Gamma_R2_8: bool; - var Gamma_R3: bool; - var Gamma_R30_11: bool; - var Gamma_R30_13: bool; - var Gamma_R30_15: bool; - var Gamma_R30_17: bool; - var Gamma_R30_18: bool; - var Gamma_R30_3: bool; - var Gamma_R30_5: bool; - var Gamma_R30_7: bool; - var Gamma_R30_9: bool; - var Gamma_R31_10: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R31_5: bool; - var Gamma_R31_6: bool; - var Gamma_R31_7: bool; - var Gamma_R31_8: bool; - var Gamma_R31_9: bool; - var Gamma_R3_1: bool; - var Gamma_R3_2: bool; - var Gamma_R3_3: bool; - var Gamma_R3_4: bool; - var Gamma_R3_5: bool; - var Gamma_R3_6: bool; - var Gamma_R3_7: bool; - var Gamma_R3_8: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R4_2: bool; - var Gamma_R4_3: bool; - var Gamma_R4_4: bool; - var Gamma_R4_5: bool; - var Gamma_R4_6: bool; - var Gamma_R4_7: bool; - var Gamma_R4_8: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R5_2: bool; - var Gamma_R5_3: bool; - var Gamma_R5_4: bool; - var Gamma_R5_5: bool; - var Gamma_R5_6: bool; - var Gamma_R5_7: bool; - var Gamma_R5_8: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R6_2: bool; - var Gamma_R6_3: bool; - var Gamma_R6_4: bool; - var Gamma_R6_5: bool; - var Gamma_R6_6: bool; - var Gamma_R6_7: bool; - var Gamma_R6_8: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R7_2: bool; - var Gamma_R7_3: bool; - var Gamma_R7_4: bool; - var Gamma_R7_5: bool; - var Gamma_R7_6: bool; - var Gamma_R7_7: bool; - var Gamma_R7_8: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R8_5: bool; - var Gamma_R8_6: bool; - var Gamma_R8_7: bool; - var Gamma_R8_8: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var Gamma_R9_4: bool; - var Gamma_R9_5: bool; - var Gamma_R9_6: bool; - var Gamma_R9_7: bool; - var Gamma_R9_8: bool; - var R0_10: bv64; - var R0_11: bv64; - var R0_12: bv64; - var R0_13: bv64; - var R0_16: bv64; - var R0_17: bv64; - var R0_18: bv32; - var R0_2: bv64; - var R0_21: bv64; - var R0_24: bv64; - var R0_25: bv64; - var R0_26: bv64; - var R0_27: bv64; - var R0_28: bv64; - var R0_5: bv64; - var R0_8: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R10_2: bv64; - var R10_3: bv64; - var R10_4: bv64; - var R10_5: bv64; - var R10_6: bv64; - var R10_7: bv64; - var R10_8: bv64; - var R11: bv64; - var R11_1: bv64; - var R11_2: bv64; - var R11_3: bv64; - var R11_4: bv64; - var R11_5: bv64; - var R11_6: bv64; - var R11_7: bv64; - var R11_8: bv64; - var R12: bv64; - var R12_1: bv64; - var R12_2: bv64; - var R12_3: bv64; - var R12_4: bv64; - var R12_5: bv64; - var R12_6: bv64; - var R12_7: bv64; - var R12_8: bv64; - var R13: bv64; - var R13_1: bv64; - var R13_2: bv64; - var R13_3: bv64; - var R13_4: bv64; - var R13_5: bv64; - var R13_6: bv64; - var R13_7: bv64; - var R13_8: bv64; - var R14: bv64; - var R14_1: bv64; - var R14_2: bv64; - var R14_3: bv64; - var R14_4: bv64; - var R14_5: bv64; - var R14_6: bv64; - var R14_7: bv64; - var R14_8: bv64; - var R15: bv64; - var R15_1: bv64; - var R15_2: bv64; - var R15_3: bv64; - var R15_4: bv64; - var R15_5: bv64; - var R15_6: bv64; - var R15_7: bv64; - var R15_8: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R16_7: bv64; - var R16_8: bv64; - var R17: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R17_7: bv64; - var R17_8: bv64; - var R18: bv64; - var R18_1: bv64; - var R18_2: bv64; - var R18_3: bv64; - var R18_4: bv64; - var R18_5: bv64; - var R18_6: bv64; - var R18_7: bv64; - var R18_8: bv64; - var R19: bv64; - var R19_1: bv64; - var R19_2: bv64; - var R19_3: bv64; - var R19_4: bv64; - var R19_5: bv64; - var R19_6: bv64; - var R19_7: bv64; - var R19_8: bv64; - var R1_1: bv64; - var R1_10: bv64; - var R1_11: bv64; - var R1_12: bv64; - var R1_13: bv64; - var R1_2: bv64; - var R1_3: bv64; - var R1_6: bv64; - var R1_7: bv64; - var R1_8: bv64; - var R1_9: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R20_2: bv64; - var R20_3: bv64; - var R20_4: bv64; - var R20_5: bv64; - var R20_6: bv64; - var R20_7: bv64; - var R20_8: bv64; - var R21: bv64; - var R21_1: bv64; - var R21_2: bv64; - var R21_3: bv64; - var R21_4: bv64; - var R21_5: bv64; - var R21_6: bv64; - var R21_7: bv64; - var R21_8: bv64; - var R22: bv64; - var R22_1: bv64; - var R22_2: bv64; - var R22_3: bv64; - var R22_4: bv64; - var R22_5: bv64; - var R22_6: bv64; - var R22_7: bv64; - var R22_8: bv64; - var R23: bv64; - var R23_1: bv64; - var R23_2: bv64; - var R23_3: bv64; - var R23_4: bv64; - var R23_5: bv64; - var R23_6: bv64; - var R23_7: bv64; - var R23_8: bv64; - var R24: bv64; - var R24_1: bv64; - var R24_2: bv64; - var R24_3: bv64; - var R24_4: bv64; - var R24_5: bv64; - var R24_6: bv64; - var R24_7: bv64; - var R24_8: bv64; - var R25: bv64; - var R25_1: bv64; - var R25_2: bv64; - var R25_3: bv64; - var R25_4: bv64; - var R25_5: bv64; - var R25_6: bv64; - var R25_7: bv64; - var R25_8: bv64; - var R26: bv64; - var R26_1: bv64; - var R26_2: bv64; - var R26_3: bv64; - var R26_4: bv64; - var R26_5: bv64; - var R26_6: bv64; - var R26_7: bv64; - var R26_8: bv64; - var R27: bv64; - var R27_1: bv64; - var R27_2: bv64; - var R27_3: bv64; - var R27_4: bv64; - var R27_5: bv64; - var R27_6: bv64; - var R27_7: bv64; - var R27_8: bv64; - var R28: bv64; - var R28_1: bv64; - var R28_2: bv64; - var R28_3: bv64; - var R28_4: bv64; - var R28_5: bv64; - var R28_6: bv64; - var R28_7: bv64; - var R28_8: bv64; - var R29_10: bv64; - var R29_11: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R29_5: bv64; - var R29_6: bv64; - var R29_7: bv64; - var R29_8: bv64; - var R29_9: bv64; - var R2_1: bv64; - var R2_2: bv64; - var R2_3: bv64; - var R2_4: bv64; - var R2_5: bv64; - var R2_6: bv64; - var R2_7: bv64; - var R2_8: bv64; - var R3: bv64; - var R30_11: bv64; - var R30_13: bv64; - var R30_15: bv64; - var R30_17: bv64; - var R30_18: bv64; - var R30_3: bv64; - var R30_5: bv64; - var R30_7: bv64; - var R30_9: bv64; - var R31_10: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R31_5: bv64; - var R31_6: bv64; - var R31_7: bv64; - var R31_8: bv64; - var R31_9: bv64; - var R3_1: bv64; - var R3_2: bv64; - var R3_3: bv64; - var R3_4: bv64; - var R3_5: bv64; - var R3_6: bv64; - var R3_7: bv64; - var R3_8: bv64; - var R4: bv64; - var R4_1: bv64; - var R4_2: bv64; - var R4_3: bv64; - var R4_4: bv64; - var R4_5: bv64; - var R4_6: bv64; - var R4_7: bv64; - var R4_8: bv64; - var R5: bv64; - var R5_1: bv64; - var R5_2: bv64; - var R5_3: bv64; - var R5_4: bv64; - var R5_5: bv64; - var R5_6: bv64; - var R5_7: bv64; - var R5_8: bv64; - var R6: bv64; - var R6_1: bv64; - var R6_2: bv64; - var R6_3: bv64; - var R6_4: bv64; - var R6_5: bv64; - var R6_6: bv64; - var R6_7: bv64; - var R6_8: bv64; - var R7: bv64; - var R7_1: bv64; - var R7_2: bv64; - var R7_3: bv64; - var R7_4: bv64; - var R7_5: bv64; - var R7_6: bv64; - var R7_7: bv64; - var R7_8: bv64; - var R8: bv64; - var R8_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R8_4: bv64; - var R8_5: bv64; - var R8_6: bv64; - var R8_7: bv64; - var R8_8: bv64; - var R9: bv64; - var R9_1: bv64; - var R9_2: bv64; - var R9_3: bv64; - var R9_4: bv64; - var R9_5: bv64; - var R9_6: bv64; - var R9_7: bv64; - var R9_8: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551552bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551552bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551560bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551560bv64), Gamma_R30_in); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(1bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551552bv64), Gamma_R31_in, R2, Gamma_R2, 2084bv64, true, bvadd64(R31_in, 18446744073709551552bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551552bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000036c"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000372"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2084bv64, true; + call malloc(); goto l0000038b; l0000038b: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_3, 40bv64), R0_2), gamma_store64(Gamma_stack, bvadd64(R31_3, 40bv64), Gamma_R0_2); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_3, 28bv64), 11bv32), gamma_store32(Gamma_stack, bvadd64(R31_3, 28bv64), true); - call R0_5, Gamma_R0_5, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_2, Gamma_R1_2, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, R30_5, Gamma_R30_5, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2 := malloc(4bv64, true, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, 2104bv64, true, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1); + assume {:captureState "l0000038b"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "%00000391"} true; + R0, Gamma_R0 := 11bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000039e"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2104bv64, true; + call malloc(); goto l000003ac; l000003ac: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_4, 48bv64), R0_5), gamma_store64(Gamma_stack, bvadd64(R31_4, 48bv64), Gamma_R0_5); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_4, 32bv64), 10bv32), gamma_store32(Gamma_stack, bvadd64(R31_4, 32bv64), true); - call R0_8, Gamma_R0_8, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_3, Gamma_R1_3, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, R30_7, Gamma_R30_7, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_3, Gamma_R8_3, R9_3, Gamma_R9_3 := malloc(4bv64, true, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_2, Gamma_R1_2, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, 2124bv64, true, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2); + assume {:captureState "l000003ac"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 48bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 48bv64), Gamma_R0); + assume {:captureState "%000003b2"} true; + R0, Gamma_R0 := 10bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 32bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "%000003bf"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2124bv64, true; + call malloc(); goto l000003cd; l000003cd: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_5, 56bv64), R0_8), gamma_store64(Gamma_stack, bvadd64(R31_5, 56bv64), Gamma_R0_8); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_5, 36bv64), 9bv32), gamma_store32(Gamma_stack, bvadd64(R31_5, 36bv64), true); - R0_10, Gamma_R0_10 := memory_load64_le(stack, bvadd64(R31_5, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 40bv64)); + assume {:captureState "l000003cd"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 56bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 56bv64), Gamma_R0); + assume {:captureState "%000003d3"} true; + R0, Gamma_R0 := 9bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_R0); + assume {:captureState "%000003e0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R1, Gamma_R1 := 65bv64, true; call rely(); - assert (L(mem, R0_10) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R0_10, 65bv8), gamma_store8(Gamma_mem, R0_10, true); - R0_11, Gamma_R0_11 := memory_load64_le(stack, bvadd64(R31_5, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 48bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003f4"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); + R1, Gamma_R1 := 42bv64, true; call rely(); - assert (L(mem, R0_11) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_11, 42bv32), gamma_store32(Gamma_mem, R0_11, true); - R0_12, Gamma_R0_12 := memory_load64_le(stack, bvadd64(R31_5, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 40bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000408"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); call rely(); - R0_13, Gamma_R0_13 := zero_extend56_8(memory_load8_le(mem, R0_12)), (gamma_load8(Gamma_mem, R0_12) || L(mem, R0_12)); - R1_6, Gamma_R1_6 := zero_extend32_32(R0_13[32:0]), Gamma_R0_13; - call R0_16, Gamma_R0_16, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_7, Gamma_R1_7, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, R30_9, Gamma_R30_9, R31_6, Gamma_R31_6, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_4, Gamma_R8_4, R9_4, Gamma_R9_4 := printf(2280bv64, true, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_6, Gamma_R1_6, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, 2184bv64, true, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_3, Gamma_R8_3, R9_3, Gamma_R9_3); + R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2280bv64), Gamma_R0; + R30, Gamma_R30 := 2184bv64, true; + call printf(); goto l00000431; l00000431: - R0_17, Gamma_R0_17 := memory_load64_le(stack, bvadd64(R31_6, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31_6, 48bv64)); + assume {:captureState "l00000431"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); call rely(); - R0_18, Gamma_R0_18 := memory_load32_le(mem, R0_17), (gamma_load32(Gamma_mem, R0_17) || L(mem, R0_17)); - R1_8, Gamma_R1_8 := zero_extend32_32(R0_18), Gamma_R0_18; - call R0_21, Gamma_R0_21, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_9, Gamma_R1_9, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, R30_11, Gamma_R30_11, R31_7, Gamma_R31_7, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_5, Gamma_R8_5, R9_5, Gamma_R9_5 := printf(2304bv64, true, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_8, Gamma_R1_8, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, 2208bv64, true, R31_6, Gamma_R31_6, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_4, Gamma_R8_4, R9_4, Gamma_R9_4); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2304bv64), Gamma_R0; + R30, Gamma_R30 := 2208bv64, true; + call printf(); goto l00000457; l00000457: - R1_10, Gamma_R1_10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_7, 32bv64))), gamma_load32(Gamma_stack, bvadd64(R31_7, 32bv64)); - call R0_24, Gamma_R0_24, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_11, Gamma_R1_11, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_8, Gamma_R29_8, R2_6, Gamma_R2_6, R30_13, Gamma_R30_13, R31_8, Gamma_R31_8, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_6, Gamma_R8_6, R9_6, Gamma_R9_6 := printf(2320bv64, true, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_10, Gamma_R1_10, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, 2224bv64, true, R31_7, Gamma_R31_7, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_5, Gamma_R8_5, R9_5, Gamma_R9_5); + assume {:captureState "l00000457"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 32bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 32bv64)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2320bv64), Gamma_R0; + R30, Gamma_R30 := 2224bv64, true; + call printf(); goto l00000470; l00000470: - R0_25, Gamma_R0_25 := memory_load64_le(stack, bvadd64(R31_8, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_8, 40bv64)); - call R0_26, Gamma_R0_26, R10_7, Gamma_R10_7, R11_7, Gamma_R11_7, R12_7, Gamma_R12_7, R13_7, Gamma_R13_7, R14_7, Gamma_R14_7, R15_7, Gamma_R15_7, R16_7, Gamma_R16_7, R17_7, Gamma_R17_7, R18_7, Gamma_R18_7, R19_7, Gamma_R19_7, R1_12, Gamma_R1_12, R20_7, Gamma_R20_7, R21_7, Gamma_R21_7, R22_7, Gamma_R22_7, R23_7, Gamma_R23_7, R24_7, Gamma_R24_7, R25_7, Gamma_R25_7, R26_7, Gamma_R26_7, R27_7, Gamma_R27_7, R28_7, Gamma_R28_7, R29_9, Gamma_R29_9, R2_7, Gamma_R2_7, R30_15, Gamma_R30_15, R31_9, Gamma_R31_9, R3_7, Gamma_R3_7, R4_7, Gamma_R4_7, R5_7, Gamma_R5_7, R6_7, Gamma_R6_7, R7_7, Gamma_R7_7, R8_7, Gamma_R8_7, R9_7, Gamma_R9_7 := #free(R0_25, Gamma_R0_25, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_11, Gamma_R1_11, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_8, Gamma_R29_8, R2_6, Gamma_R2_6, 2232bv64, true, R31_8, Gamma_R31_8, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_6, Gamma_R8_6, R9_6, Gamma_R9_6); + assume {:captureState "l00000470"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R30, Gamma_R30 := 2232bv64, true; + call #free(); goto l0000047f; l0000047f: - R0_27, Gamma_R0_27 := memory_load64_le(stack, bvadd64(R31_9, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31_9, 48bv64)); - call R0_28, Gamma_R0_28, R10_8, Gamma_R10_8, R11_8, Gamma_R11_8, R12_8, Gamma_R12_8, R13_8, Gamma_R13_8, R14_8, Gamma_R14_8, R15_8, Gamma_R15_8, R16_8, Gamma_R16_8, R17_8, Gamma_R17_8, R18_8, Gamma_R18_8, R19_8, Gamma_R19_8, R1_13, Gamma_R1_13, R20_8, Gamma_R20_8, R21_8, Gamma_R21_8, R22_8, Gamma_R22_8, R23_8, Gamma_R23_8, R24_8, Gamma_R24_8, R25_8, Gamma_R25_8, R26_8, Gamma_R26_8, R27_8, Gamma_R27_8, R28_8, Gamma_R28_8, R29_10, Gamma_R29_10, R2_8, Gamma_R2_8, R30_17, Gamma_R30_17, R31_10, Gamma_R31_10, R3_8, Gamma_R3_8, R4_8, Gamma_R4_8, R5_8, Gamma_R5_8, R6_8, Gamma_R6_8, R7_8, Gamma_R7_8, R8_8, Gamma_R8_8, R9_8, Gamma_R9_8 := #free(R0_27, Gamma_R0_27, R10_7, Gamma_R10_7, R11_7, Gamma_R11_7, R12_7, Gamma_R12_7, R13_7, Gamma_R13_7, R14_7, Gamma_R14_7, R15_7, Gamma_R15_7, R16_7, Gamma_R16_7, R17_7, Gamma_R17_7, R18_7, Gamma_R18_7, R19_7, Gamma_R19_7, R1_12, Gamma_R1_12, R20_7, Gamma_R20_7, R21_7, Gamma_R21_7, R22_7, Gamma_R22_7, R23_7, Gamma_R23_7, R24_7, Gamma_R24_7, R25_7, Gamma_R25_7, R26_7, Gamma_R26_7, R27_7, Gamma_R27_7, R28_7, Gamma_R28_7, R29_9, Gamma_R29_9, R2_7, Gamma_R2_7, 2240bv64, true, R31_9, Gamma_R31_9, R3_7, Gamma_R3_7, R4_7, Gamma_R4_7, R5_7, Gamma_R5_7, R6_7, Gamma_R6_7, R7_7, Gamma_R7_7, R8_7, Gamma_R8_7, R9_7, Gamma_R9_7); + assume {:captureState "l0000047f"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); + R30, Gamma_R30 := 2240bv64, true; + call #free(); goto l0000048d; l0000048d: - R29_11, Gamma_R29_11 := memory_load64_le(stack, R31_10), gamma_load64(Gamma_stack, R31_10); - R30_18, Gamma_R30_18 := memory_load64_le(stack, bvadd64(R31_10, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_10, 8bv64)); + assume {:captureState "l0000048d"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 64bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_13, R29_11, R30_18, bvadd64(R31_10, 64bv64); - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_13, Gamma_R29_11, Gamma_R30_18, Gamma_R31_10; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2272bv64) == 131073bv64); free requires (memory_load64_le(mem, 2280bv64) == 8241983568019286100bv64); @@ -882,7 +331,7 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2272bv64) == 131073bv64); free requires (memory_load64_le(mem, 2280bv64) == 8241983568019286100bv64); diff --git a/src/test/correct/malloc_with_local2/gcc/malloc_with_local2_gtirb.expected b/src/test/correct/malloc_with_local2/gcc/malloc_with_local2_gtirb.expected index b934e6ac8..782535552 100644 --- a/src/test/correct/malloc_with_local2/gcc/malloc_with_local2_gtirb.expected +++ b/src/test/correct/malloc_with_local2/gcc/malloc_with_local2_gtirb.expected @@ -1,28 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2272bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -31,22 +31,22 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { + gammaMap[index] +} + function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -60,22 +60,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2272bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2280bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2288bv64) == 748482783423457568bv64); @@ -95,8 +96,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -109,8 +110,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2272bv64) == 131073bv64); @@ -129,6 +130,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69000bv64) == 1984bv64); free requires (memory_load64_le(mem, 69616bv64) == 2068bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2272bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2280bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2288bv64) == 748482783423457568bv64); @@ -146,111 +151,118 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_13: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R0_9: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R16_7: bool; - var Gamma_R16_8: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R17_7: bool; - var Gamma_R17_8: bool; - var Gamma_R1_5: bool; - var Gamma_R29_3: bool; - var Gamma_R30_10: bool; - var R0_13: bv64; - var R0_7: bv64; - var R0_8: bv64; - var R0_9: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R16_7: bv64; - var R16_8: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R17_7: bv64; - var R17_8: bv64; - var R1_5: bv64; - var R29_3: bv64; - var R30_10: bv64; + var Cse0__5$8$0: bv64; + var Gamma_Cse0__5$8$0: bool; $main$__0__$AZzshZKtSEuJn8wjRf5oKw: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551552bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551552bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551560bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551560bv64), Gamma_R30_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_680(R16, Gamma_R16); + assume {:captureState "$main$__0__$AZzshZKtSEuJn8wjRf5oKw"} true; + Cse0__5$8$0, Gamma_Cse0__5$8$0 := bvadd64(R31, 18446744073709551552bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$8$0, R29), gamma_store64(Gamma_stack, Cse0__5$8$0, Gamma_R29); + assume {:captureState "2068$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$8$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$8$0, 8bv64), Gamma_R30); + assume {:captureState "2068$2"} true; + R31, Gamma_R31 := Cse0__5$8$0, Gamma_Cse0__5$8$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2084bv64, true; + call FUN_680(); goto $main$__1__$_Jt_AVu0STa3DsAXddfzmA; $main$__1__$_Jt_AVu0STa3DsAXddfzmA: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), 1bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551580bv64), 11bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64), true); - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := FUN_680(R16_1, Gamma_R16_1); + assume {:captureState "$main$__1__$_Jt_AVu0STa3DsAXddfzmA"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "2084$0"} true; + R0, Gamma_R0 := 11bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "2092$0"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2104bv64, true; + call FUN_680(); goto $main$__2__$vVSPHAjaRAyVtXo~vTrC7g; $main$__2__$vVSPHAjaRAyVtXo~vTrC7g: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551584bv64), 10bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), true); - call R16_3, Gamma_R16_3, R17_3, Gamma_R17_3 := FUN_680(R16_2, Gamma_R16_2); + assume {:captureState "$main$__2__$vVSPHAjaRAyVtXo~vTrC7g"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 48bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 48bv64), Gamma_R0); + assume {:captureState "2104$0"} true; + R0, Gamma_R0 := 10bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 32bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "2112$0"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2124bv64, true; + call FUN_680(); goto $main$__3__$qo4gHbnYSpa0qcz2RNo4Dw; $main$__3__$qo4gHbnYSpa0qcz2RNo4Dw: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551588bv64), 9bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64), true); - R0_7, Gamma_R0_7 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "$main$__3__$qo4gHbnYSpa0qcz2RNo4Dw"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 56bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 56bv64), Gamma_R0); + assume {:captureState "2124$0"} true; + R0, Gamma_R0 := 9bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_R0); + assume {:captureState "2132$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R1, Gamma_R1 := 65bv64, true; + call rely(); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2144$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); + R1, Gamma_R1 := 42bv64, true; call rely(); - assert (L(mem, R0_7) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R0_7, 65bv8), gamma_store8(Gamma_mem, R0_7, true); - R0_8, Gamma_R0_8 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2156$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); call rely(); - assert (L(mem, R0_8) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_8, 42bv32), gamma_store32(Gamma_mem, R0_8, true); - R0_9, Gamma_R0_9 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - call R16_4, Gamma_R16_4, R17_4, Gamma_R17_4 := FUN_6c0(R16_3, Gamma_R16_3); + R0, Gamma_R0 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R0))), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2280bv64), Gamma_R0; + R30, Gamma_R30 := 2184bv64, true; + call FUN_6c0(); goto $main$__4__$sKQEwpisRC~Deg8htVYDGA; $main$__4__$sKQEwpisRC~Deg8htVYDGA: - R0_13, Gamma_R0_13 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - call R16_5, Gamma_R16_5, R17_5, Gamma_R17_5 := FUN_6c0(R16_4, Gamma_R16_4); + assume {:captureState "$main$__4__$sKQEwpisRC~Deg8htVYDGA"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); + call rely(); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2304bv64), Gamma_R0; + R30, Gamma_R30 := 2208bv64, true; + call FUN_6c0(); goto $main$__5__$UU_sb98JQMuNTccrtfVShA; $main$__5__$UU_sb98JQMuNTccrtfVShA: - R1_5, Gamma_R1_5 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551584bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - call R16_6, Gamma_R16_6, R17_6, Gamma_R17_6 := FUN_6c0(R16_5, Gamma_R16_5); + assume {:captureState "$main$__5__$UU_sb98JQMuNTccrtfVShA"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 32bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 32bv64)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2320bv64), Gamma_R0; + R30, Gamma_R30 := 2224bv64, true; + call FUN_6c0(); goto $main$__6__$xqmLBBa1TNCvLDxmYyOHcQ; $main$__6__$xqmLBBa1TNCvLDxmYyOHcQ: - call R16_7, Gamma_R16_7, R17_7, Gamma_R17_7 := FUN_6b0(R16_6, Gamma_R16_6); + assume {:captureState "$main$__6__$xqmLBBa1TNCvLDxmYyOHcQ"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R30, Gamma_R30 := 2232bv64, true; + call FUN_6b0(); goto $main$__7__$9CEaMIK4TyKPblekpKg8LA; $main$__7__$9CEaMIK4TyKPblekpKg8LA: - call R16_8, Gamma_R16_8, R17_8, Gamma_R17_8 := FUN_6b0(R16_7, Gamma_R16_7); + assume {:captureState "$main$__7__$9CEaMIK4TyKPblekpKg8LA"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); + R30, Gamma_R30 := 2240bv64, true; + call FUN_6b0(); goto $main$__8__$kYgEsvZnR5mgdgIreZDDSA; $main$__8__$kYgEsvZnR5mgdgIreZDDSA: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551552bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551552bv64)); - R30_10, Gamma_R30_10 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551560bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551560bv64)); + assume {:captureState "$main$__8__$kYgEsvZnR5mgdgIreZDDSA"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 64bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_5, R29_3, R30_10, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_5, Gamma_R29_3, Gamma_R30_10, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } -procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6b0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2272bv64) == 131073bv64); free requires (memory_load64_le(mem, 2280bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2288bv64) == 748482783423457568bv64); @@ -284,143 +296,20 @@ procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6b0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6b0$__0__$dQPm~3VORAieWEy83BwbqQ: + assume {:captureState "$FUN_6b0$__0__$dQPm~3VORAieWEy83BwbqQ"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := #free(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69568bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4032bv64)) || L(mem, bvadd64(R16, 4032bv64))); + R16, Gamma_R16 := bvadd64(R16, 4032bv64), Gamma_R16; + call #free(); assume false; } -procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6c0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2272bv64) == 131073bv64); free requires (memory_load64_le(mem, 2280bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2288bv64) == 748482783423457568bv64); @@ -454,143 +343,20 @@ procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6c0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6c0$__0__$e2Fzppr9TBufcmss~nKX6w: + assume {:captureState "$FUN_6c0$__0__$e2Fzppr9TBufcmss~nKX6w"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69576bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4040bv64)) || L(mem, bvadd64(R16, 4040bv64))); + R16, Gamma_R16 := bvadd64(R16, 4040bv64), Gamma_R16; + call printf(); assume false; } -procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_680(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2272bv64) == 131073bv64); free requires (memory_load64_le(mem, 2280bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2288bv64) == 748482783423457568bv64); @@ -624,142 +390,19 @@ procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_680() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_680$__0__$6hxifqk6SUCUrrqeP4IHHw: + assume {:captureState "$FUN_680$__0__$6hxifqk6SUCUrrqeP4IHHw"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69544bv64), (gamma_load64(Gamma_mem, 69544bv64) || L(mem, 69544bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69544bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4008bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4008bv64)) || L(mem, bvadd64(R16, 4008bv64))); + R16, Gamma_R16 := bvadd64(R16, 4008bv64), Gamma_R16; + call malloc(); assume false; } -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); free requires (memory_load64_le(mem, 2272bv64) == 131073bv64); free requires (memory_load64_le(mem, 2280bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2288bv64) == 748482783423457568bv64); @@ -793,7 +436,7 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load64_le(mem, 2272bv64) == 131073bv64); free requires (memory_load64_le(mem, 2280bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2288bv64) == 748482783423457568bv64); @@ -827,7 +470,7 @@ procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); free requires (memory_load64_le(mem, 2272bv64) == 131073bv64); free requires (memory_load64_le(mem, 2280bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2288bv64) == 748482783423457568bv64); diff --git a/src/test/correct/malloc_with_local3/clang/malloc_with_local3.expected b/src/test/correct/malloc_with_local3/clang/malloc_with_local3.expected index fcba62a4d..e26d62293 100644 --- a/src/test/correct/malloc_with_local3/clang/malloc_with_local3.expected +++ b/src/test/correct/malloc_with_local3/clang/malloc_with_local3.expected @@ -1,33 +1,33 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2344bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +41,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,23 +65,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free ensures (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); @@ -107,8 +103,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -121,7 +117,7 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); @@ -160,8 +156,8 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69688bv64) == 0bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); free requires (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); @@ -182,6 +178,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1984bv64); free requires (memory_load64_le(mem, 69592bv64) == 2068bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free ensures (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); @@ -201,608 +201,122 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_13: bool; - var Gamma_R0_14: bool; - var Gamma_R0_15: bool; - var Gamma_R0_16: bool; - var Gamma_R0_17: bool; - var Gamma_R0_18: bool; - var Gamma_R0_2: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R10_2: bool; - var Gamma_R10_3: bool; - var Gamma_R10_4: bool; - var Gamma_R10_5: bool; - var Gamma_R10_6: bool; - var Gamma_R10_7: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R11_2: bool; - var Gamma_R11_3: bool; - var Gamma_R11_4: bool; - var Gamma_R11_5: bool; - var Gamma_R11_6: bool; - var Gamma_R11_7: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R12_2: bool; - var Gamma_R12_3: bool; - var Gamma_R12_4: bool; - var Gamma_R12_5: bool; - var Gamma_R12_6: bool; - var Gamma_R12_7: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R13_2: bool; - var Gamma_R13_3: bool; - var Gamma_R13_4: bool; - var Gamma_R13_5: bool; - var Gamma_R13_6: bool; - var Gamma_R13_7: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R14_2: bool; - var Gamma_R14_3: bool; - var Gamma_R14_4: bool; - var Gamma_R14_5: bool; - var Gamma_R14_6: bool; - var Gamma_R14_7: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R15_2: bool; - var Gamma_R15_3: bool; - var Gamma_R15_4: bool; - var Gamma_R15_5: bool; - var Gamma_R15_6: bool; - var Gamma_R15_7: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R16_7: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R17_7: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R18_2: bool; - var Gamma_R18_3: bool; - var Gamma_R18_4: bool; - var Gamma_R18_5: bool; - var Gamma_R18_6: bool; - var Gamma_R18_7: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R19_2: bool; - var Gamma_R19_3: bool; - var Gamma_R19_4: bool; - var Gamma_R19_5: bool; - var Gamma_R19_6: bool; - var Gamma_R19_7: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var Gamma_R1_6: bool; - var Gamma_R1_7: bool; - var Gamma_R1_8: bool; - var Gamma_R1_9: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R20_2: bool; - var Gamma_R20_3: bool; - var Gamma_R20_4: bool; - var Gamma_R20_5: bool; - var Gamma_R20_6: bool; - var Gamma_R20_7: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R21_2: bool; - var Gamma_R21_3: bool; - var Gamma_R21_4: bool; - var Gamma_R21_5: bool; - var Gamma_R21_6: bool; - var Gamma_R21_7: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R22_2: bool; - var Gamma_R22_3: bool; - var Gamma_R22_4: bool; - var Gamma_R22_5: bool; - var Gamma_R22_6: bool; - var Gamma_R22_7: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R23_2: bool; - var Gamma_R23_3: bool; - var Gamma_R23_4: bool; - var Gamma_R23_5: bool; - var Gamma_R23_6: bool; - var Gamma_R23_7: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R24_2: bool; - var Gamma_R24_3: bool; - var Gamma_R24_4: bool; - var Gamma_R24_5: bool; - var Gamma_R24_6: bool; - var Gamma_R24_7: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R25_2: bool; - var Gamma_R25_3: bool; - var Gamma_R25_4: bool; - var Gamma_R25_5: bool; - var Gamma_R25_6: bool; - var Gamma_R25_7: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R26_2: bool; - var Gamma_R26_3: bool; - var Gamma_R26_4: bool; - var Gamma_R26_5: bool; - var Gamma_R26_6: bool; - var Gamma_R26_7: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R27_2: bool; - var Gamma_R27_3: bool; - var Gamma_R27_4: bool; - var Gamma_R27_5: bool; - var Gamma_R27_6: bool; - var Gamma_R27_7: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R28_2: bool; - var Gamma_R28_3: bool; - var Gamma_R28_4: bool; - var Gamma_R28_5: bool; - var Gamma_R28_6: bool; - var Gamma_R28_7: bool; - var Gamma_R29_10: bool; - var Gamma_R29_11: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R29_5: bool; - var Gamma_R29_6: bool; - var Gamma_R29_7: bool; - var Gamma_R29_8: bool; - var Gamma_R29_9: bool; - var Gamma_R2_1: bool; - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var Gamma_R2_4: bool; - var Gamma_R2_5: bool; - var Gamma_R2_6: bool; - var Gamma_R2_7: bool; - var Gamma_R3: bool; - var Gamma_R30_10: bool; - var Gamma_R30_12: bool; - var Gamma_R30_14: bool; - var Gamma_R30_16: bool; - var Gamma_R30_17: bool; - var Gamma_R30_3: bool; - var Gamma_R30_5: bool; - var Gamma_R30_7: bool; - var Gamma_R31_10: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R31_5: bool; - var Gamma_R31_6: bool; - var Gamma_R31_7: bool; - var Gamma_R31_8: bool; - var Gamma_R31_9: bool; - var Gamma_R3_1: bool; - var Gamma_R3_2: bool; - var Gamma_R3_3: bool; - var Gamma_R3_4: bool; - var Gamma_R3_5: bool; - var Gamma_R3_6: bool; - var Gamma_R3_7: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R4_2: bool; - var Gamma_R4_3: bool; - var Gamma_R4_4: bool; - var Gamma_R4_5: bool; - var Gamma_R4_6: bool; - var Gamma_R4_7: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R5_2: bool; - var Gamma_R5_3: bool; - var Gamma_R5_4: bool; - var Gamma_R5_5: bool; - var Gamma_R5_6: bool; - var Gamma_R5_7: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R6_2: bool; - var Gamma_R6_3: bool; - var Gamma_R6_4: bool; - var Gamma_R6_5: bool; - var Gamma_R6_6: bool; - var Gamma_R6_7: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R7_2: bool; - var Gamma_R7_3: bool; - var Gamma_R7_4: bool; - var Gamma_R7_5: bool; - var Gamma_R7_6: bool; - var Gamma_R7_7: bool; - var Gamma_R8_11: bool; - var Gamma_R8_12: bool; - var Gamma_R8_13: bool; - var Gamma_R8_14: bool; - var Gamma_R8_15: bool; - var Gamma_R8_2: bool; - var Gamma_R8_4: bool; - var Gamma_R8_7: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var Gamma_R9_4: bool; - var Gamma_R9_5: bool; - var Gamma_R9_6: bool; - var Gamma_R9_7: bool; - var Gamma_R9_8: bool; - var Gamma_R9_9: bool; - var R0_10: bv64; - var R0_13: bv64; - var R0_14: bv64; - var R0_15: bv64; - var R0_16: bv64; - var R0_17: bv64; - var R0_18: bv64; - var R0_2: bv64; - var R0_4: bv64; - var R0_5: bv64; - var R0_6: bv64; - var R0_7: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R10_2: bv64; - var R10_3: bv64; - var R10_4: bv64; - var R10_5: bv64; - var R10_6: bv64; - var R10_7: bv64; - var R11: bv64; - var R11_1: bv64; - var R11_2: bv64; - var R11_3: bv64; - var R11_4: bv64; - var R11_5: bv64; - var R11_6: bv64; - var R11_7: bv64; - var R12: bv64; - var R12_1: bv64; - var R12_2: bv64; - var R12_3: bv64; - var R12_4: bv64; - var R12_5: bv64; - var R12_6: bv64; - var R12_7: bv64; - var R13: bv64; - var R13_1: bv64; - var R13_2: bv64; - var R13_3: bv64; - var R13_4: bv64; - var R13_5: bv64; - var R13_6: bv64; - var R13_7: bv64; - var R14: bv64; - var R14_1: bv64; - var R14_2: bv64; - var R14_3: bv64; - var R14_4: bv64; - var R14_5: bv64; - var R14_6: bv64; - var R14_7: bv64; - var R15: bv64; - var R15_1: bv64; - var R15_2: bv64; - var R15_3: bv64; - var R15_4: bv64; - var R15_5: bv64; - var R15_6: bv64; - var R15_7: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R16_7: bv64; - var R17: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R17_7: bv64; - var R18: bv64; - var R18_1: bv64; - var R18_2: bv64; - var R18_3: bv64; - var R18_4: bv64; - var R18_5: bv64; - var R18_6: bv64; - var R18_7: bv64; - var R19: bv64; - var R19_1: bv64; - var R19_2: bv64; - var R19_3: bv64; - var R19_4: bv64; - var R19_5: bv64; - var R19_6: bv64; - var R19_7: bv64; - var R1_1: bv64; - var R1_2: bv64; - var R1_3: bv64; - var R1_4: bv64; - var R1_5: bv64; - var R1_6: bv64; - var R1_7: bv64; - var R1_8: bv64; - var R1_9: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R20_2: bv64; - var R20_3: bv64; - var R20_4: bv64; - var R20_5: bv64; - var R20_6: bv64; - var R20_7: bv64; - var R21: bv64; - var R21_1: bv64; - var R21_2: bv64; - var R21_3: bv64; - var R21_4: bv64; - var R21_5: bv64; - var R21_6: bv64; - var R21_7: bv64; - var R22: bv64; - var R22_1: bv64; - var R22_2: bv64; - var R22_3: bv64; - var R22_4: bv64; - var R22_5: bv64; - var R22_6: bv64; - var R22_7: bv64; - var R23: bv64; - var R23_1: bv64; - var R23_2: bv64; - var R23_3: bv64; - var R23_4: bv64; - var R23_5: bv64; - var R23_6: bv64; - var R23_7: bv64; - var R24: bv64; - var R24_1: bv64; - var R24_2: bv64; - var R24_3: bv64; - var R24_4: bv64; - var R24_5: bv64; - var R24_6: bv64; - var R24_7: bv64; - var R25: bv64; - var R25_1: bv64; - var R25_2: bv64; - var R25_3: bv64; - var R25_4: bv64; - var R25_5: bv64; - var R25_6: bv64; - var R25_7: bv64; - var R26: bv64; - var R26_1: bv64; - var R26_2: bv64; - var R26_3: bv64; - var R26_4: bv64; - var R26_5: bv64; - var R26_6: bv64; - var R26_7: bv64; - var R27: bv64; - var R27_1: bv64; - var R27_2: bv64; - var R27_3: bv64; - var R27_4: bv64; - var R27_5: bv64; - var R27_6: bv64; - var R27_7: bv64; - var R28: bv64; - var R28_1: bv64; - var R28_2: bv64; - var R28_3: bv64; - var R28_4: bv64; - var R28_5: bv64; - var R28_6: bv64; - var R28_7: bv64; - var R29_10: bv64; - var R29_11: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R29_5: bv64; - var R29_6: bv64; - var R29_7: bv64; - var R29_8: bv64; - var R29_9: bv64; - var R2_1: bv64; - var R2_2: bv64; - var R2_3: bv64; - var R2_4: bv64; - var R2_5: bv64; - var R2_6: bv64; - var R2_7: bv64; - var R3: bv64; - var R30_10: bv64; - var R30_12: bv64; - var R30_14: bv64; - var R30_16: bv64; - var R30_17: bv64; - var R30_3: bv64; - var R30_5: bv64; - var R30_7: bv64; - var R31_10: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R31_5: bv64; - var R31_6: bv64; - var R31_7: bv64; - var R31_8: bv64; - var R31_9: bv64; - var R3_1: bv64; - var R3_2: bv64; - var R3_3: bv64; - var R3_4: bv64; - var R3_5: bv64; - var R3_6: bv64; - var R3_7: bv64; - var R4: bv64; - var R4_1: bv64; - var R4_2: bv64; - var R4_3: bv64; - var R4_4: bv64; - var R4_5: bv64; - var R4_6: bv64; - var R4_7: bv64; - var R5: bv64; - var R5_1: bv64; - var R5_2: bv64; - var R5_3: bv64; - var R5_4: bv64; - var R5_5: bv64; - var R5_6: bv64; - var R5_7: bv64; - var R6: bv64; - var R6_1: bv64; - var R6_2: bv64; - var R6_3: bv64; - var R6_4: bv64; - var R6_5: bv64; - var R6_6: bv64; - var R6_7: bv64; - var R7: bv64; - var R7_1: bv64; - var R7_2: bv64; - var R7_3: bv64; - var R7_4: bv64; - var R7_5: bv64; - var R7_6: bv64; - var R7_7: bv64; - var R8_11: bv64; - var R8_12: bv64; - var R8_13: bv64; - var R8_14: bv64; - var R8_15: bv64; - var R8_2: bv64; - var R8_4: bv64; - var R8_7: bv64; - var R9: bv64; - var R9_1: bv64; - var R9_2: bv64; - var R9_3: bv64; - var R9_4: bv64; - var R9_5: bv64; - var R9_6: bv64; - var R9_7: bv64; - var R9_8: bv64; - var R9_9: bv64; + var #4: bv64; + var #7: bv64; + var Gamma_#4: bool; + var Gamma_#7: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551544bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551544bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_2, Gamma_R8_2, R9_1, Gamma_R9_1 := malloc(1bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, R2, Gamma_R2, 2100bv64, true, bvadd64(R31_in, 18446744073709551536bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, 0bv64, true, R9, Gamma_R9); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551536bv64), Gamma_R31; + #4, Gamma_#4 := bvadd64(R31, 64bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000003ba"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000003c0"} true; + R29, Gamma_R29 := bvadd64(R31, 64bv64), Gamma_R31; + R8, Gamma_R8 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%000003d3"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%000003da"} true; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2100bv64, true; + call malloc(); goto l000003e9; l000003e9: - call rely(); - assert (L(mem, bvadd64(R29_3, 18446744073709551600bv64)) ==> Gamma_R0_2); - mem, Gamma_mem := memory_store64_le(mem, bvadd64(R29_3, 18446744073709551600bv64), R0_2), gamma_store64(Gamma_mem, bvadd64(R29_3, 18446744073709551600bv64), Gamma_R0_2); - call rely(); - assert (L(mem, bvadd64(R29_3, 18446744073709551596bv64)) ==> true); - mem, Gamma_mem := memory_store32_le(mem, bvadd64(R29_3, 18446744073709551596bv64), 11bv32), gamma_store32(Gamma_mem, bvadd64(R29_3, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store64_le(stack, R31_3, 4bv64), gamma_store64(Gamma_stack, R31_3, true); - call R0_4, Gamma_R0_4, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_2, Gamma_R1_2, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, R30_5, Gamma_R30_5, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_4, Gamma_R8_4, R9_2, Gamma_R9_2 := malloc(4bv64, true, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, 2124bv64, true, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, 11bv64, true, R9_1, Gamma_R9_1); + assume {:captureState "l000003e9"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R29, 18446744073709551600bv64), R0), gamma_store64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64), Gamma_R0); + assume {:captureState "%000003ef"} true; + R8, Gamma_R8 := 11bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551596bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551596bv64), Gamma_R8); + assume {:captureState "%000003fc"} true; + R0, Gamma_R0 := 4bv64, true; + stack, Gamma_stack := memory_store64_le(stack, R31, R0), gamma_store64(Gamma_stack, R31, Gamma_R0); + assume {:captureState "%00000409"} true; + R30, Gamma_R30 := 2124bv64, true; + call malloc(); goto l00000412; l00000412: - R0_5, Gamma_R0_5 := memory_load64_le(stack, R31_4), gamma_load64(Gamma_stack, R31_4); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_4, 32bv64), R0_4), gamma_store64(Gamma_stack, bvadd64(R31_4, 32bv64), Gamma_R0_4); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_4, 28bv64), 10bv32), gamma_store32(Gamma_stack, bvadd64(R31_4, 28bv64), true); - call R0_6, Gamma_R0_6, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_3, Gamma_R1_3, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, R30_7, Gamma_R30_7, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_7, Gamma_R8_7, R9_3, Gamma_R9_3 := malloc(R0_5, Gamma_R0_5, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_2, Gamma_R1_2, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, 2148bv64, true, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, 10bv64, true, R9_2, Gamma_R9_2); + assume {:captureState "l00000412"} true; + R8, Gamma_R8 := R0, Gamma_R0; + R0, Gamma_R0 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R8); + assume {:captureState "%00000425"} true; + R8, Gamma_R8 := 10bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "%00000432"} true; + R30, Gamma_R30 := 2148bv64, true; + call malloc(); goto l0000043b; l0000043b: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_5, 16bv64), R0_6), gamma_store64(Gamma_stack, bvadd64(R31_5, 16bv64), Gamma_R0_6); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_5, 12bv64), 9bv32), gamma_store32(Gamma_stack, bvadd64(R31_5, 12bv64), true); + assume {:captureState "l0000043b"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000441"} true; + R8, Gamma_R8 := 9bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%0000044e"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); + R8, Gamma_R8 := 65bv64, true; call rely(); - R9_4, Gamma_R9_4 := memory_load64_le(mem, bvadd64(R29_5, 18446744073709551600bv64)), (gamma_load64(Gamma_mem, bvadd64(R29_5, 18446744073709551600bv64)) || L(mem, bvadd64(R29_5, 18446744073709551600bv64))); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000462"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + R8, Gamma_R8 := 42bv64, true; call rely(); - assert (L(mem, R9_4) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R9_4, 65bv8), gamma_store8(Gamma_mem, R9_4, true); - R9_5, Gamma_R9_5 := memory_load64_le(stack, bvadd64(R31_5, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 32bv64)); - call rely(); - assert (L(mem, R9_5) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_5, 42bv32), gamma_store32(Gamma_mem, R9_5, true); - call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, bvadd64(R29_5, 18446744073709551600bv64)), (gamma_load64(Gamma_mem, bvadd64(R29_5, 18446744073709551600bv64)) || L(mem, bvadd64(R29_5, 18446744073709551600bv64))); - call R29_6, Gamma_R29_6, R31_6, Gamma_R31_6 := printCharValue(R0_7, Gamma_R0_7, R29_5, Gamma_R29_5, 2192bv64, true, R31_5, Gamma_R31_5); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000476"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); + R30, Gamma_R30 := 2192bv64, true; + call printCharValue(); goto l00000504; l00000504: - R8_11, Gamma_R8_11 := memory_load64_le(stack, bvadd64(R31_6, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_6, 32bv64)); + assume {:captureState "l00000504"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); call rely(); - R1_4, Gamma_R1_4 := zero_extend32_32(memory_load32_le(mem, R8_11)), (gamma_load32(Gamma_mem, R8_11) || L(mem, R8_11)); - call R0_10, Gamma_R0_10, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_5, Gamma_R1_5, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_7, Gamma_R29_7, R2_4, Gamma_R2_4, R30_10, Gamma_R30_10, R31_7, Gamma_R31_7, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_12, Gamma_R8_12, R9_6, Gamma_R9_6 := printf(2348bv64, true, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_4, Gamma_R1_4, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_6, Gamma_R29_6, R2_3, Gamma_R2_3, 2212bv64, true, R31_6, Gamma_R31_6, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_11, Gamma_R8_11, R9_5, Gamma_R9_5); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2348bv64), Gamma_R0; + R30, Gamma_R30 := 2212bv64, true; + call printf(); goto l00000524; l00000524: - R1_6, Gamma_R1_6 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_7, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31_7, 28bv64)); - call R0_13, Gamma_R0_13, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_7, Gamma_R1_7, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_8, Gamma_R29_8, R2_5, Gamma_R2_5, R30_12, Gamma_R30_12, R31_8, Gamma_R31_8, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_13, Gamma_R8_13, R9_7, Gamma_R9_7 := printf(2364bv64, true, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_6, Gamma_R1_6, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_7, Gamma_R29_7, R2_4, Gamma_R2_4, 2228bv64, true, R31_7, Gamma_R31_7, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_12, Gamma_R8_12, R9_6, Gamma_R9_6); + assume {:captureState "l00000524"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2364bv64), Gamma_R0; + R30, Gamma_R30 := 2228bv64, true; + call printf(); goto l0000053d; l0000053d: - call rely(); - R0_14, Gamma_R0_14 := memory_load64_le(mem, bvadd64(R29_8, 18446744073709551600bv64)), (gamma_load64(Gamma_mem, bvadd64(R29_8, 18446744073709551600bv64)) || L(mem, bvadd64(R29_8, 18446744073709551600bv64))); - call R0_15, Gamma_R0_15, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_8, Gamma_R1_8, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_9, Gamma_R29_9, R2_6, Gamma_R2_6, R30_14, Gamma_R30_14, R31_9, Gamma_R31_9, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_14, Gamma_R8_14, R9_8, Gamma_R9_8 := #free(R0_14, Gamma_R0_14, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_7, Gamma_R1_7, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_8, Gamma_R29_8, R2_5, Gamma_R2_5, 2236bv64, true, R31_8, Gamma_R31_8, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_13, Gamma_R8_13, R9_7, Gamma_R9_7); + assume {:captureState "l0000053d"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); + R30, Gamma_R30 := 2236bv64, true; + call #free(); goto l0000054c; l0000054c: - R0_16, Gamma_R0_16 := memory_load64_le(stack, bvadd64(R31_9, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_9, 32bv64)); - call R0_17, Gamma_R0_17, R10_7, Gamma_R10_7, R11_7, Gamma_R11_7, R12_7, Gamma_R12_7, R13_7, Gamma_R13_7, R14_7, Gamma_R14_7, R15_7, Gamma_R15_7, R16_7, Gamma_R16_7, R17_7, Gamma_R17_7, R18_7, Gamma_R18_7, R19_7, Gamma_R19_7, R1_9, Gamma_R1_9, R20_7, Gamma_R20_7, R21_7, Gamma_R21_7, R22_7, Gamma_R22_7, R23_7, Gamma_R23_7, R24_7, Gamma_R24_7, R25_7, Gamma_R25_7, R26_7, Gamma_R26_7, R27_7, Gamma_R27_7, R28_7, Gamma_R28_7, R29_10, Gamma_R29_10, R2_7, Gamma_R2_7, R30_16, Gamma_R30_16, R31_10, Gamma_R31_10, R3_7, Gamma_R3_7, R4_7, Gamma_R4_7, R5_7, Gamma_R5_7, R6_7, Gamma_R6_7, R7_7, Gamma_R7_7, R8_15, Gamma_R8_15, R9_9, Gamma_R9_9 := #free(R0_16, Gamma_R0_16, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_8, Gamma_R1_8, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_9, Gamma_R29_9, R2_6, Gamma_R2_6, 2244bv64, true, R31_9, Gamma_R31_9, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_14, Gamma_R8_14, R9_8, Gamma_R9_8); + assume {:captureState "l0000054c"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + R30, Gamma_R30 := 2244bv64, true; + call #free(); goto l0000055a; l0000055a: - R0_18, Gamma_R0_18 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_10, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31_10, 8bv64)); - R29_11, Gamma_R29_11 := memory_load64_le(stack, bvadd64(R31_10, 64bv64)), gamma_load64(Gamma_stack, bvadd64(R31_10, 64bv64)); - R30_17, Gamma_R30_17 := memory_load64_le(stack, bvadd64(R31_10, 72bv64)), gamma_load64(Gamma_stack, bvadd64(R31_10, 72bv64)); + assume {:captureState "l0000055a"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + #7, Gamma_#7 := bvadd64(R31, 64bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, #7), gamma_load64(Gamma_stack, #7); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#7, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#7, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 80bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out, R8_out, R9_out := R0_18, R1_9, R29_11, R30_17, bvadd64(R31_10, 80bv64), R8_15, R9_9; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_18, Gamma_R1_9, Gamma_R29_11, Gamma_R30_17, Gamma_R31_10, Gamma_R8_15, Gamma_R9_9; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); @@ -841,8 +355,8 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R29_out: bv64, Gamma_R29_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure printCharValue(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free requires (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); @@ -861,6 +375,10 @@ procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29 free requires (memory_load64_le(mem, 69072bv64) == 1984bv64); free requires (memory_load64_le(mem, 69592bv64) == 2068bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free ensures (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); @@ -880,160 +398,52 @@ procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29 free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R29_out: bv64, Gamma_R29_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation printCharValue() { - var Gamma_R0_4: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30_3: bool; - var Gamma_R31_3: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var R0_4: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16: bv64; - var R16_1: bv64; - var R17: bv64; - var R17_1: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R1_2: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R2_1: bv64; - var R3: bv64; - var R30_3: bv64; - var R31_3: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R8_4: bv64; - var R9_1: bv64; - var R9_2: bv64; + var #5: bv64; + var #6: bv64; + var Gamma_#5: bool; + var Gamma_#6: bool; lprintCharValue: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R0_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R0_in); - R9_1, Gamma_R9_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "lprintCharValue"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #5, R29), gamma_store64(Gamma_stack, #5, Gamma_R29); + assume {:captureState "%00000496"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#5, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#5, 8bv64), Gamma_R30); + assume {:captureState "%0000049c"} true; + R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%000004aa"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - R8_1, Gamma_R8_1 := zero_extend56_8(memory_load8_le(mem, R9_1)), (gamma_load8(Gamma_mem, R9_1) || L(mem, R9_1)); - R8_2, Gamma_R8_2 := zero_extend32_32(bvadd32(R8_1[32:0], 1bv32)), Gamma_R8_1; + R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, R9)), (gamma_load8(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, R9_1) ==> Gamma_R8_2); - mem, Gamma_mem := memory_store8_le(mem, R9_1, R8_2[8:0]), gamma_store8(Gamma_mem, R9_1, Gamma_R8_2); - R8_3, Gamma_R8_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000004c6"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - R1_1, Gamma_R1_1 := zero_extend56_8(memory_load8_le(mem, R8_3)), (gamma_load8(Gamma_mem, R8_3) || L(mem, R8_3)); - call R0_4, Gamma_R0_4, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_2, Gamma_R1_2, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_4, Gamma_R8_4, R9_2, Gamma_R9_2 := printf(2391bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1_1, Gamma_R1_1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, R2, Gamma_R2, 2312bv64, true, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8_3, Gamma_R8_3, R9_1, Gamma_R9_1); + R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2391bv64), Gamma_R0; + R30, Gamma_R30 := 2312bv64, true; + call printf(); goto l000004e9; l000004e9: - R29_4, Gamma_R29_4 := memory_load64_le(stack, bvadd64(R31_3, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 16bv64)); + assume {:captureState "l000004e9"} true; + #6, Gamma_#6 := bvadd64(R31, 16bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, #6), gamma_load64(Gamma_stack, #6); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#6, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#6, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto printCharValue_basil_return; printCharValue_basil_return: - R29_out, R31_out := R29_4, bvadd64(R31_3, 32bv64); - Gamma_R29_out, Gamma_R31_out := Gamma_R29_4, Gamma_R31_3; + assume {:captureState "printCharValue_basil_return"} true; return; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); diff --git a/src/test/correct/malloc_with_local3/clang/malloc_with_local3_gtirb.expected b/src/test/correct/malloc_with_local3/clang/malloc_with_local3_gtirb.expected index dea4d4695..4cfaf99f2 100644 --- a/src/test/correct/malloc_with_local3/clang/malloc_with_local3_gtirb.expected +++ b/src/test/correct/malloc_with_local3/clang/malloc_with_local3_gtirb.expected @@ -1,29 +1,33 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2344bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -37,21 +41,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -65,23 +65,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free ensures (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); @@ -103,8 +103,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -117,8 +117,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6c0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free requires (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); @@ -156,143 +156,20 @@ procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6c0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6c0$__0__$me9kzk4bRj6EX~wS6RkzzQ: + assume {:captureState "$FUN_6c0$__0__$me9kzk4bRj6EX~wS6RkzzQ"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69680bv64), (gamma_load64(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69680bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 48bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 48bv64)) || L(mem, bvadd64(R16, 48bv64))); + R16, Gamma_R16 := bvadd64(R16, 48bv64), Gamma_R16; + call printf(); assume false; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69688bv64) == 0bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); free requires (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); @@ -313,6 +190,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1984bv64); free requires (memory_load64_le(mem, 69592bv64) == 2068bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free ensures (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); @@ -332,120 +213,123 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_11: bool; - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R16_7: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R17_7: bool; - var Gamma_R1_2: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R30_10: bool; - var Gamma_R31_3: bool; - var Gamma_R8_8: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var R0_11: bv64; - var R0_3: bv64; - var R0_4: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R16_7: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R17_7: bv64; - var R1_2: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R30_10: bv64; - var R31_3: bv64; - var R8_8: bv64; - var R9_1: bv64; - var R9_2: bv64; + var Cse0__5$4$1: bv64; + var Cse0__5$5$1: bv64; + var Gamma_Cse0__5$4$1: bool; + var Gamma_Cse0__5$5$1: bool; $main$__0__$nxS5BBFfTke_CNErRQFGKQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551544bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551544bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_680(R16, Gamma_R16); + assume {:captureState "$main$__0__$nxS5BBFfTke_CNErRQFGKQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551536bv64), Gamma_R31; + Cse0__5$5$1, Gamma_Cse0__5$5$1 := bvadd64(R31, 64bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$5$1, R29), gamma_store64(Gamma_stack, Cse0__5$5$1, Gamma_R29); + assume {:captureState "2072$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$5$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$5$1, 8bv64), Gamma_R30); + assume {:captureState "2072$2"} true; + R29, Gamma_R29 := bvadd64(R31, 64bv64), Gamma_R31; + R8, Gamma_R8 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "2084$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "2088$0"} true; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2100bv64, true; + call FUN_680(); goto $main$__1__$Ik7a47RJTBa1l1WDXE7X3A; $main$__1__$Ik7a47RJTBa1l1WDXE7X3A: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), 1bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551580bv64), 11bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64), true); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551536bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551536bv64), true); - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := FUN_680(R16_1, Gamma_R16_1); + assume {:captureState "$main$__1__$Ik7a47RJTBa1l1WDXE7X3A"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R29, 18446744073709551600bv64), R0), gamma_store64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64), Gamma_R0); + assume {:captureState "2100$0"} true; + R8, Gamma_R8 := 11bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551596bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551596bv64), Gamma_R8); + assume {:captureState "2108$0"} true; + R0, Gamma_R0 := 4bv64, true; + stack, Gamma_stack := memory_store64_le(stack, R31, R0), gamma_store64(Gamma_stack, R31, Gamma_R0); + assume {:captureState "2116$0"} true; + R30, Gamma_R30 := 2124bv64, true; + call FUN_680(); goto $main$__2__$4Qjclk41Sf2Jx7UaAwk5Gw; $main$__2__$4Qjclk41Sf2Jx7UaAwk5Gw: - R0_3, Gamma_R0_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551536bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551536bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551564bv64), 10bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551564bv64), true); - call R16_3, Gamma_R16_3, R17_3, Gamma_R17_3 := FUN_680(R16_2, Gamma_R16_2); + assume {:captureState "$main$__2__$4Qjclk41Sf2Jx7UaAwk5Gw"} true; + R8, Gamma_R8 := R0, Gamma_R0; + R0, Gamma_R0 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R8); + assume {:captureState "2132$0"} true; + R8, Gamma_R8 := 10bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "2140$0"} true; + R30, Gamma_R30 := 2148bv64, true; + call FUN_680(); goto $main$__3__$jJOoR~rDTuy7U_5U9rR_Gg; $main$__3__$jJOoR~rDTuy7U_5U9rR_Gg: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551552bv64), R0_3), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551552bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551548bv64), 9bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551548bv64), true); - R9_1, Gamma_R9_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); + assume {:captureState "$main$__3__$jJOoR~rDTuy7U_5U9rR_Gg"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "2148$0"} true; + R8, Gamma_R8 := 9bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "2156$0"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); + R8, Gamma_R8 := 65bv64, true; call rely(); - assert (L(mem, R9_1) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R9_1, 65bv8), gamma_store8(Gamma_mem, R9_1, true); - R9_2, Gamma_R9_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551568bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64)); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "2168$0"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + R8, Gamma_R8 := 42bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 42bv32), gamma_store32(Gamma_mem, R9_2, true); - R0_4, Gamma_R0_4 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - call R29_3, Gamma_R29_3, R31_3, Gamma_R31_3 := printCharValue(R0_4, Gamma_R0_4, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, 2192bv64, true, bvadd64(R31_in, 18446744073709551536bv64), Gamma_R31_in); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "2180$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); + R30, Gamma_R30 := 2192bv64, true; + call printCharValue(); goto $main$__4__$Pa4MGsAVS6~tzB83NfXLBg; $main$__4__$Pa4MGsAVS6~tzB83NfXLBg: - R8_8, Gamma_R8_8 := memory_load64_le(stack, bvadd64(R31_3, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 32bv64)); - call R16_4, Gamma_R16_4, R17_4, Gamma_R17_4 := FUN_6c0(R16_3, Gamma_R16_3); + assume {:captureState "$main$__4__$Pa4MGsAVS6~tzB83NfXLBg"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + call rely(); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2348bv64), Gamma_R0; + R30, Gamma_R30 := 2148bv64, true; + call FUN_6c0(); goto $main$__5__$~SkD5Pe5QqiMlkcFiJItZA; $main$__5__$~SkD5Pe5QqiMlkcFiJItZA: - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_3, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31_3, 28bv64)); - call R16_5, Gamma_R16_5, R17_5, Gamma_R17_5 := FUN_6c0(R16_4, Gamma_R16_4); + assume {:captureState "$main$__5__$~SkD5Pe5QqiMlkcFiJItZA"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2364bv64), Gamma_R0; + R30, Gamma_R30 := 2228bv64, true; + call FUN_6c0(); goto $main$__6__$hzO7zn1JRG~r_d3kLC97VQ; $main$__6__$hzO7zn1JRG~r_d3kLC97VQ: - call R16_6, Gamma_R16_6, R17_6, Gamma_R17_6 := FUN_6b0(R16_5, Gamma_R16_5); + assume {:captureState "$main$__6__$hzO7zn1JRG~r_d3kLC97VQ"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); + R30, Gamma_R30 := 2236bv64, true; + call FUN_6b0(); goto $main$__7__$uPLqBGF0TDGfPpIXh_rpzQ; $main$__7__$uPLqBGF0TDGfPpIXh_rpzQ: - call R16_7, Gamma_R16_7, R17_7, Gamma_R17_7 := FUN_6b0(R16_6, Gamma_R16_6); + assume {:captureState "$main$__7__$uPLqBGF0TDGfPpIXh_rpzQ"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); + R30, Gamma_R30 := 2244bv64, true; + call FUN_6b0(); goto $main$__8__$9Y41cbd5RxmWaVzl3hmTRA; $main$__8__$9Y41cbd5RxmWaVzl3hmTRA: - R0_11, Gamma_R0_11 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_3, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31_3, 8bv64)); - R29_4, Gamma_R29_4 := memory_load64_le(stack, bvadd64(R31_3, 64bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 64bv64)); - R30_10, Gamma_R30_10 := memory_load64_le(stack, bvadd64(R31_3, 72bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 72bv64)); + assume {:captureState "$main$__8__$9Y41cbd5RxmWaVzl3hmTRA"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + Cse0__5$4$1, Gamma_Cse0__5$4$1 := bvadd64(R31, 64bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$4$1), gamma_load64(Gamma_stack, Cse0__5$4$1); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$4$1, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$4$1, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 80bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R1_out, R29_out, R30_out, R31_out, R8_out, R9_out := R0_11, R16_7, R17_7, R1_2, R29_4, R30_10, bvadd64(R31_3, 80bv64), R8_8, R9_2; - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_11, Gamma_R16_7, Gamma_R17_7, Gamma_R1_2, Gamma_R29_4, Gamma_R30_10, Gamma_R31_3, Gamma_R8_8, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } -procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_680(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free requires (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); @@ -483,143 +367,20 @@ procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_680() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_680$__0__$q33iZ61pRiq0p_PPlVbZ1g: + assume {:captureState "$FUN_680$__0__$q33iZ61pRiq0p_PPlVbZ1g"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69648bv64), (gamma_load64(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69648bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 16bv64)) || L(mem, bvadd64(R16, 16bv64))); + R16, Gamma_R16 := bvadd64(R16, 16bv64), Gamma_R16; + call malloc(); assume false; } -procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6b0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free requires (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); @@ -657,143 +418,20 @@ procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6b0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6b0$__0__$RW4J0XkoQ6ao8Rv9r_1Z0Q: + assume {:captureState "$FUN_6b0$__0__$RW4J0XkoQ6ao8Rv9r_1Z0Q"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69672bv64), (gamma_load64(Gamma_mem, 69672bv64) || L(mem, 69672bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := #free(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69672bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 40bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 40bv64)) || L(mem, bvadd64(R16, 40bv64))); + R16, Gamma_R16 := bvadd64(R16, 40bv64), Gamma_R16; + call #free(); assume false; } -procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R29_out: bv64, Gamma_R29_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure printCharValue(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free requires (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); @@ -812,6 +450,10 @@ procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29 free requires (memory_load64_le(mem, 69072bv64) == 1984bv64); free requires (memory_load64_le(mem, 69592bv64) == 2068bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free ensures (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); @@ -831,45 +473,52 @@ procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29 free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R29_out: bv64, Gamma_R29_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation printCharValue() { - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var Gamma_R29_3: bool; - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R9_1: bool; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; - var R29_3: bv64; - var R8_1: bv64; - var R8_2: bv64; - var R9_1: bv64; + var Cse0__5$0$1: bv64; + var Cse0__5$1$0: bv64; + var Gamma_Cse0__5$0$1: bool; + var Gamma_Cse0__5$1$0: bool; $printCharValue$__0__$oLhjcPasQ0GRWJmyJMiN1Q: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R0_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R0_in); - R9_1, Gamma_R9_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "$printCharValue$__0__$oLhjcPasQ0GRWJmyJMiN1Q"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + Cse0__5$0$1, Gamma_Cse0__5$0$1 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$1, R29), gamma_store64(Gamma_stack, Cse0__5$0$1, Gamma_R29); + assume {:captureState "2264$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$1, 8bv64), Gamma_R30); + assume {:captureState "2264$2"} true; + R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "2272$0"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + call rely(); + R8, Gamma_R8 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R9))), (gamma_load8(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - R8_1, Gamma_R8_1 := zero_extend56_8(memory_load8_le(mem, R9_1)), (gamma_load8(Gamma_mem, R9_1) || L(mem, R9_1)); - R8_2, Gamma_R8_2 := zero_extend32_32(bvadd32(R8_1[32:0], 1bv32)), Gamma_R8_1; + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "2288$0"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - assert (L(mem, R9_1) ==> Gamma_R8_2); - mem, Gamma_mem := memory_store8_le(mem, R9_1, R8_2[8:0]), gamma_store8(Gamma_mem, R9_1, Gamma_R8_2); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_6c0(R16, Gamma_R16); + R1, Gamma_R1 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R8))), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2391bv64), Gamma_R0; + R30, Gamma_R30 := 2312bv64, true; + call FUN_6c0(); goto $printCharValue$__1__$tdcD~_GVQvixIy4UvVBE1Q; $printCharValue$__1__$tdcD~_GVQvixIy4UvVBE1Q: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); + assume {:captureState "$printCharValue$__1__$tdcD~_GVQvixIy4UvVBE1Q"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd64(R31, 16bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$1$0), gamma_load64(Gamma_stack, Cse0__5$1$0); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$1$0, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$1$0, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto printCharValue_basil_return; printCharValue_basil_return: - R29_out, R31_out := R29_3, R31_in; - Gamma_R29_out, Gamma_R31_out := Gamma_R29_3, Gamma_R31_in; + assume {:captureState "printCharValue_basil_return"} true; return; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free requires (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); @@ -907,7 +556,7 @@ procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); free requires (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free requires (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); @@ -945,7 +594,7 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); free requires (memory_load64_le(mem, 2344bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2352bv64) == 2322295453216173673bv64); free requires (memory_load64_le(mem, 2360bv64) == 2334386691848692773bv64); diff --git a/src/test/correct/malloc_with_local3/gcc/malloc_with_local3.expected b/src/test/correct/malloc_with_local3/gcc/malloc_with_local3.expected index 127f5e11e..24cfa9582 100644 --- a/src/test/correct/malloc_with_local3/gcc/malloc_with_local3.expected +++ b/src/test/correct/malloc_with_local3/gcc/malloc_with_local3.expected @@ -1,33 +1,29 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2328bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -41,21 +37,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -69,23 +61,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2328bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free ensures (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); @@ -109,8 +101,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -123,7 +115,7 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2328bv64) == 131073bv64); free requires (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); @@ -166,8 +158,8 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2328bv64) == 131073bv64); @@ -190,6 +182,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69000bv64) == 1984bv64); free requires (memory_load64_le(mem, 69616bv64) == 2068bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2328bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free ensures (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); @@ -211,595 +207,112 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_11: bool; - var Gamma_R0_12: bool; - var Gamma_R0_13: bool; - var Gamma_R0_14: bool; - var Gamma_R0_17: bool; - var Gamma_R0_2: bool; - var Gamma_R0_20: bool; - var Gamma_R0_21: bool; - var Gamma_R0_22: bool; - var Gamma_R0_23: bool; - var Gamma_R0_24: bool; - var Gamma_R0_5: bool; - var Gamma_R0_8: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R10_2: bool; - var Gamma_R10_3: bool; - var Gamma_R10_4: bool; - var Gamma_R10_5: bool; - var Gamma_R10_6: bool; - var Gamma_R10_7: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R11_2: bool; - var Gamma_R11_3: bool; - var Gamma_R11_4: bool; - var Gamma_R11_5: bool; - var Gamma_R11_6: bool; - var Gamma_R11_7: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R12_2: bool; - var Gamma_R12_3: bool; - var Gamma_R12_4: bool; - var Gamma_R12_5: bool; - var Gamma_R12_6: bool; - var Gamma_R12_7: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R13_2: bool; - var Gamma_R13_3: bool; - var Gamma_R13_4: bool; - var Gamma_R13_5: bool; - var Gamma_R13_6: bool; - var Gamma_R13_7: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R14_2: bool; - var Gamma_R14_3: bool; - var Gamma_R14_4: bool; - var Gamma_R14_5: bool; - var Gamma_R14_6: bool; - var Gamma_R14_7: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R15_2: bool; - var Gamma_R15_3: bool; - var Gamma_R15_4: bool; - var Gamma_R15_5: bool; - var Gamma_R15_6: bool; - var Gamma_R15_7: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R16_7: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R17_7: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R18_2: bool; - var Gamma_R18_3: bool; - var Gamma_R18_4: bool; - var Gamma_R18_5: bool; - var Gamma_R18_6: bool; - var Gamma_R18_7: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R19_2: bool; - var Gamma_R19_3: bool; - var Gamma_R19_4: bool; - var Gamma_R19_5: bool; - var Gamma_R19_6: bool; - var Gamma_R19_7: bool; - var Gamma_R1_1: bool; - var Gamma_R1_10: bool; - var Gamma_R1_11: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_6: bool; - var Gamma_R1_7: bool; - var Gamma_R1_8: bool; - var Gamma_R1_9: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R20_2: bool; - var Gamma_R20_3: bool; - var Gamma_R20_4: bool; - var Gamma_R20_5: bool; - var Gamma_R20_6: bool; - var Gamma_R20_7: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R21_2: bool; - var Gamma_R21_3: bool; - var Gamma_R21_4: bool; - var Gamma_R21_5: bool; - var Gamma_R21_6: bool; - var Gamma_R21_7: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R22_2: bool; - var Gamma_R22_3: bool; - var Gamma_R22_4: bool; - var Gamma_R22_5: bool; - var Gamma_R22_6: bool; - var Gamma_R22_7: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R23_2: bool; - var Gamma_R23_3: bool; - var Gamma_R23_4: bool; - var Gamma_R23_5: bool; - var Gamma_R23_6: bool; - var Gamma_R23_7: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R24_2: bool; - var Gamma_R24_3: bool; - var Gamma_R24_4: bool; - var Gamma_R24_5: bool; - var Gamma_R24_6: bool; - var Gamma_R24_7: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R25_2: bool; - var Gamma_R25_3: bool; - var Gamma_R25_4: bool; - var Gamma_R25_5: bool; - var Gamma_R25_6: bool; - var Gamma_R25_7: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R26_2: bool; - var Gamma_R26_3: bool; - var Gamma_R26_4: bool; - var Gamma_R26_5: bool; - var Gamma_R26_6: bool; - var Gamma_R26_7: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R27_2: bool; - var Gamma_R27_3: bool; - var Gamma_R27_4: bool; - var Gamma_R27_5: bool; - var Gamma_R27_6: bool; - var Gamma_R27_7: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R28_2: bool; - var Gamma_R28_3: bool; - var Gamma_R28_4: bool; - var Gamma_R28_5: bool; - var Gamma_R28_6: bool; - var Gamma_R28_7: bool; - var Gamma_R29_10: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R29_5: bool; - var Gamma_R29_6: bool; - var Gamma_R29_7: bool; - var Gamma_R29_8: bool; - var Gamma_R29_9: bool; - var Gamma_R2_1: bool; - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var Gamma_R2_4: bool; - var Gamma_R2_5: bool; - var Gamma_R2_6: bool; - var Gamma_R2_7: bool; - var Gamma_R3: bool; - var Gamma_R30_10: bool; - var Gamma_R30_12: bool; - var Gamma_R30_14: bool; - var Gamma_R30_16: bool; - var Gamma_R30_17: bool; - var Gamma_R30_3: bool; - var Gamma_R30_5: bool; - var Gamma_R30_7: bool; - var Gamma_R31_10: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R31_5: bool; - var Gamma_R31_6: bool; - var Gamma_R31_7: bool; - var Gamma_R31_8: bool; - var Gamma_R31_9: bool; - var Gamma_R3_1: bool; - var Gamma_R3_2: bool; - var Gamma_R3_3: bool; - var Gamma_R3_4: bool; - var Gamma_R3_5: bool; - var Gamma_R3_6: bool; - var Gamma_R3_7: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R4_2: bool; - var Gamma_R4_3: bool; - var Gamma_R4_4: bool; - var Gamma_R4_5: bool; - var Gamma_R4_6: bool; - var Gamma_R4_7: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R5_2: bool; - var Gamma_R5_3: bool; - var Gamma_R5_4: bool; - var Gamma_R5_5: bool; - var Gamma_R5_6: bool; - var Gamma_R5_7: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R6_2: bool; - var Gamma_R6_3: bool; - var Gamma_R6_4: bool; - var Gamma_R6_5: bool; - var Gamma_R6_6: bool; - var Gamma_R6_7: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R7_2: bool; - var Gamma_R7_3: bool; - var Gamma_R7_4: bool; - var Gamma_R7_5: bool; - var Gamma_R7_6: bool; - var Gamma_R7_7: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R8_5: bool; - var Gamma_R8_6: bool; - var Gamma_R8_7: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var Gamma_R9_4: bool; - var Gamma_R9_5: bool; - var Gamma_R9_6: bool; - var Gamma_R9_7: bool; - var R0_10: bv64; - var R0_11: bv64; - var R0_12: bv64; - var R0_13: bv64; - var R0_14: bv32; - var R0_17: bv64; - var R0_2: bv64; - var R0_20: bv64; - var R0_21: bv64; - var R0_22: bv64; - var R0_23: bv64; - var R0_24: bv64; - var R0_5: bv64; - var R0_8: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R10_2: bv64; - var R10_3: bv64; - var R10_4: bv64; - var R10_5: bv64; - var R10_6: bv64; - var R10_7: bv64; - var R11: bv64; - var R11_1: bv64; - var R11_2: bv64; - var R11_3: bv64; - var R11_4: bv64; - var R11_5: bv64; - var R11_6: bv64; - var R11_7: bv64; - var R12: bv64; - var R12_1: bv64; - var R12_2: bv64; - var R12_3: bv64; - var R12_4: bv64; - var R12_5: bv64; - var R12_6: bv64; - var R12_7: bv64; - var R13: bv64; - var R13_1: bv64; - var R13_2: bv64; - var R13_3: bv64; - var R13_4: bv64; - var R13_5: bv64; - var R13_6: bv64; - var R13_7: bv64; - var R14: bv64; - var R14_1: bv64; - var R14_2: bv64; - var R14_3: bv64; - var R14_4: bv64; - var R14_5: bv64; - var R14_6: bv64; - var R14_7: bv64; - var R15: bv64; - var R15_1: bv64; - var R15_2: bv64; - var R15_3: bv64; - var R15_4: bv64; - var R15_5: bv64; - var R15_6: bv64; - var R15_7: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R16_7: bv64; - var R17: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R17_7: bv64; - var R18: bv64; - var R18_1: bv64; - var R18_2: bv64; - var R18_3: bv64; - var R18_4: bv64; - var R18_5: bv64; - var R18_6: bv64; - var R18_7: bv64; - var R19: bv64; - var R19_1: bv64; - var R19_2: bv64; - var R19_3: bv64; - var R19_4: bv64; - var R19_5: bv64; - var R19_6: bv64; - var R19_7: bv64; - var R1_1: bv64; - var R1_10: bv64; - var R1_11: bv64; - var R1_2: bv64; - var R1_3: bv64; - var R1_6: bv64; - var R1_7: bv64; - var R1_8: bv64; - var R1_9: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R20_2: bv64; - var R20_3: bv64; - var R20_4: bv64; - var R20_5: bv64; - var R20_6: bv64; - var R20_7: bv64; - var R21: bv64; - var R21_1: bv64; - var R21_2: bv64; - var R21_3: bv64; - var R21_4: bv64; - var R21_5: bv64; - var R21_6: bv64; - var R21_7: bv64; - var R22: bv64; - var R22_1: bv64; - var R22_2: bv64; - var R22_3: bv64; - var R22_4: bv64; - var R22_5: bv64; - var R22_6: bv64; - var R22_7: bv64; - var R23: bv64; - var R23_1: bv64; - var R23_2: bv64; - var R23_3: bv64; - var R23_4: bv64; - var R23_5: bv64; - var R23_6: bv64; - var R23_7: bv64; - var R24: bv64; - var R24_1: bv64; - var R24_2: bv64; - var R24_3: bv64; - var R24_4: bv64; - var R24_5: bv64; - var R24_6: bv64; - var R24_7: bv64; - var R25: bv64; - var R25_1: bv64; - var R25_2: bv64; - var R25_3: bv64; - var R25_4: bv64; - var R25_5: bv64; - var R25_6: bv64; - var R25_7: bv64; - var R26: bv64; - var R26_1: bv64; - var R26_2: bv64; - var R26_3: bv64; - var R26_4: bv64; - var R26_5: bv64; - var R26_6: bv64; - var R26_7: bv64; - var R27: bv64; - var R27_1: bv64; - var R27_2: bv64; - var R27_3: bv64; - var R27_4: bv64; - var R27_5: bv64; - var R27_6: bv64; - var R27_7: bv64; - var R28: bv64; - var R28_1: bv64; - var R28_2: bv64; - var R28_3: bv64; - var R28_4: bv64; - var R28_5: bv64; - var R28_6: bv64; - var R28_7: bv64; - var R29_10: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R29_5: bv64; - var R29_6: bv64; - var R29_7: bv64; - var R29_8: bv64; - var R29_9: bv64; - var R2_1: bv64; - var R2_2: bv64; - var R2_3: bv64; - var R2_4: bv64; - var R2_5: bv64; - var R2_6: bv64; - var R2_7: bv64; - var R3: bv64; - var R30_10: bv64; - var R30_12: bv64; - var R30_14: bv64; - var R30_16: bv64; - var R30_17: bv64; - var R30_3: bv64; - var R30_5: bv64; - var R30_7: bv64; - var R31_10: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R31_5: bv64; - var R31_6: bv64; - var R31_7: bv64; - var R31_8: bv64; - var R31_9: bv64; - var R3_1: bv64; - var R3_2: bv64; - var R3_3: bv64; - var R3_4: bv64; - var R3_5: bv64; - var R3_6: bv64; - var R3_7: bv64; - var R4: bv64; - var R4_1: bv64; - var R4_2: bv64; - var R4_3: bv64; - var R4_4: bv64; - var R4_5: bv64; - var R4_6: bv64; - var R4_7: bv64; - var R5: bv64; - var R5_1: bv64; - var R5_2: bv64; - var R5_3: bv64; - var R5_4: bv64; - var R5_5: bv64; - var R5_6: bv64; - var R5_7: bv64; - var R6: bv64; - var R6_1: bv64; - var R6_2: bv64; - var R6_3: bv64; - var R6_4: bv64; - var R6_5: bv64; - var R6_6: bv64; - var R6_7: bv64; - var R7: bv64; - var R7_1: bv64; - var R7_2: bv64; - var R7_3: bv64; - var R7_4: bv64; - var R7_5: bv64; - var R7_6: bv64; - var R7_7: bv64; - var R8: bv64; - var R8_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R8_4: bv64; - var R8_5: bv64; - var R8_6: bv64; - var R8_7: bv64; - var R9: bv64; - var R9_1: bv64; - var R9_2: bv64; - var R9_3: bv64; - var R9_4: bv64; - var R9_5: bv64; - var R9_6: bv64; - var R9_7: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551552bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551552bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551560bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551560bv64), Gamma_R30_in); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(1bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551552bv64), Gamma_R31_in, R2, Gamma_R2, 2084bv64, true, bvadd64(R31_in, 18446744073709551552bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551552bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000003a4"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000003aa"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2084bv64, true; + call malloc(); goto l000003c3; l000003c3: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_3, 40bv64), R0_2), gamma_store64(Gamma_stack, bvadd64(R31_3, 40bv64), Gamma_R0_2); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_3, 28bv64), 11bv32), gamma_store32(Gamma_stack, bvadd64(R31_3, 28bv64), true); - call R0_5, Gamma_R0_5, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_2, Gamma_R1_2, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, R30_5, Gamma_R30_5, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2 := malloc(4bv64, true, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, 2104bv64, true, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1); + assume {:captureState "l000003c3"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "%000003c9"} true; + R0, Gamma_R0 := 11bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%000003d6"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2104bv64, true; + call malloc(); goto l000003e4; l000003e4: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_4, 48bv64), R0_5), gamma_store64(Gamma_stack, bvadd64(R31_4, 48bv64), Gamma_R0_5); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_4, 32bv64), 10bv32), gamma_store32(Gamma_stack, bvadd64(R31_4, 32bv64), true); - call R0_8, Gamma_R0_8, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_3, Gamma_R1_3, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, R30_7, Gamma_R30_7, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_3, Gamma_R8_3, R9_3, Gamma_R9_3 := malloc(4bv64, true, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_2, Gamma_R1_2, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, 2124bv64, true, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2); + assume {:captureState "l000003e4"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 48bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 48bv64), Gamma_R0); + assume {:captureState "%000003ea"} true; + R0, Gamma_R0 := 10bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 32bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "%000003f7"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2124bv64, true; + call malloc(); goto l00000405; l00000405: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_5, 56bv64), R0_8), gamma_store64(Gamma_stack, bvadd64(R31_5, 56bv64), Gamma_R0_8); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_5, 36bv64), 9bv32), gamma_store32(Gamma_stack, bvadd64(R31_5, 36bv64), true); - R0_10, Gamma_R0_10 := memory_load64_le(stack, bvadd64(R31_5, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 40bv64)); + assume {:captureState "l00000405"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 56bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 56bv64), Gamma_R0); + assume {:captureState "%0000040b"} true; + R0, Gamma_R0 := 9bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_R0); + assume {:captureState "%00000418"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R1, Gamma_R1 := 65bv64, true; call rely(); - assert (L(mem, R0_10) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R0_10, 65bv8), gamma_store8(Gamma_mem, R0_10, true); - R0_11, Gamma_R0_11 := memory_load64_le(stack, bvadd64(R31_5, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 48bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000042c"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); + R1, Gamma_R1 := 42bv64, true; call rely(); - assert (L(mem, R0_11) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_11, 42bv32), gamma_store32(Gamma_mem, R0_11, true); - R0_12, Gamma_R0_12 := memory_load64_le(stack, bvadd64(R31_5, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 40bv64)); - call R31_6, Gamma_R31_6 := printCharValue(R0_12, Gamma_R0_12, R29_5, Gamma_R29_5, 2168bv64, true, R31_5, Gamma_R31_5); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000440"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R30, Gamma_R30 := 2168bv64, true; + call printCharValue(); goto l000004db; l000004db: - R0_13, Gamma_R0_13 := memory_load64_le(stack, bvadd64(R31_6, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31_6, 48bv64)); + assume {:captureState "l000004db"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); call rely(); - R0_14, Gamma_R0_14 := memory_load32_le(mem, R0_13), (gamma_load32(Gamma_mem, R0_13) || L(mem, R0_13)); - R1_6, Gamma_R1_6 := zero_extend32_32(R0_14), Gamma_R0_14; - call R0_17, Gamma_R0_17, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_7, Gamma_R1_7, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, R30_10, Gamma_R30_10, R31_7, Gamma_R31_7, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_4, Gamma_R8_4, R9_4, Gamma_R9_4 := printf(2336bv64, true, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_6, Gamma_R1_6, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, 2192bv64, true, R31_6, Gamma_R31_6, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_3, Gamma_R8_3, R9_3, Gamma_R9_3); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2336bv64), Gamma_R0; + R30, Gamma_R30 := 2192bv64, true; + call printf(); goto l00000501; l00000501: - R1_8, Gamma_R1_8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_7, 32bv64))), gamma_load32(Gamma_stack, bvadd64(R31_7, 32bv64)); - call R0_20, Gamma_R0_20, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_9, Gamma_R1_9, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, R30_12, Gamma_R30_12, R31_8, Gamma_R31_8, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_5, Gamma_R8_5, R9_5, Gamma_R9_5 := printf(2352bv64, true, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_8, Gamma_R1_8, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, 2208bv64, true, R31_7, Gamma_R31_7, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_4, Gamma_R8_4, R9_4, Gamma_R9_4); + assume {:captureState "l00000501"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 32bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 32bv64)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2352bv64), Gamma_R0; + R30, Gamma_R30 := 2208bv64, true; + call printf(); goto l0000051a; l0000051a: - R0_21, Gamma_R0_21 := memory_load64_le(stack, bvadd64(R31_8, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_8, 40bv64)); - call R0_22, Gamma_R0_22, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_10, Gamma_R1_10, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_8, Gamma_R29_8, R2_6, Gamma_R2_6, R30_14, Gamma_R30_14, R31_9, Gamma_R31_9, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_6, Gamma_R8_6, R9_6, Gamma_R9_6 := #free(R0_21, Gamma_R0_21, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_9, Gamma_R1_9, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, 2216bv64, true, R31_8, Gamma_R31_8, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_5, Gamma_R8_5, R9_5, Gamma_R9_5); + assume {:captureState "l0000051a"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R30, Gamma_R30 := 2216bv64, true; + call #free(); goto l00000529; l00000529: - R0_23, Gamma_R0_23 := memory_load64_le(stack, bvadd64(R31_9, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31_9, 48bv64)); - call R0_24, Gamma_R0_24, R10_7, Gamma_R10_7, R11_7, Gamma_R11_7, R12_7, Gamma_R12_7, R13_7, Gamma_R13_7, R14_7, Gamma_R14_7, R15_7, Gamma_R15_7, R16_7, Gamma_R16_7, R17_7, Gamma_R17_7, R18_7, Gamma_R18_7, R19_7, Gamma_R19_7, R1_11, Gamma_R1_11, R20_7, Gamma_R20_7, R21_7, Gamma_R21_7, R22_7, Gamma_R22_7, R23_7, Gamma_R23_7, R24_7, Gamma_R24_7, R25_7, Gamma_R25_7, R26_7, Gamma_R26_7, R27_7, Gamma_R27_7, R28_7, Gamma_R28_7, R29_9, Gamma_R29_9, R2_7, Gamma_R2_7, R30_16, Gamma_R30_16, R31_10, Gamma_R31_10, R3_7, Gamma_R3_7, R4_7, Gamma_R4_7, R5_7, Gamma_R5_7, R6_7, Gamma_R6_7, R7_7, Gamma_R7_7, R8_7, Gamma_R8_7, R9_7, Gamma_R9_7 := #free(R0_23, Gamma_R0_23, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_10, Gamma_R1_10, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_8, Gamma_R29_8, R2_6, Gamma_R2_6, 2224bv64, true, R31_9, Gamma_R31_9, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_6, Gamma_R8_6, R9_6, Gamma_R9_6); + assume {:captureState "l00000529"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); + R30, Gamma_R30 := 2224bv64, true; + call #free(); goto l00000537; l00000537: - R29_10, Gamma_R29_10 := memory_load64_le(stack, R31_10), gamma_load64(Gamma_stack, R31_10); - R30_17, Gamma_R30_17 := memory_load64_le(stack, bvadd64(R31_10, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_10, 8bv64)); + assume {:captureState "l00000537"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 64bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_11, R29_10, R30_17, bvadd64(R31_10, 64bv64); - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_11, Gamma_R29_10, Gamma_R30_17, Gamma_R31_10; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2328bv64) == 131073bv64); free requires (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); @@ -842,8 +355,8 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure printCharValue(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 2328bv64) == 131073bv64); free requires (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free requires (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); @@ -864,6 +377,10 @@ procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29 free requires (memory_load64_le(mem, 69000bv64) == 1984bv64); free requires (memory_load64_le(mem, 69616bv64) == 2068bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2328bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free ensures (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); @@ -885,168 +402,52 @@ procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29 free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool) +implementation printCharValue() { - var Gamma_R0_10: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29_3: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30_3: bool; - var Gamma_R31_3: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0_10: bv64; - var R0_2: bv64; - var R0_3: bv64; - var R0_4: bv64; - var R0_5: bv64; - var R0_6: bv64; - var R0_7: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16: bv64; - var R16_1: bv64; - var R17: bv64; - var R17_1: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv8; - var R1_2: bv64; - var R1_3: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29_3: bv64; - var R2_1: bv64; - var R3: bv64; - var R30_3: bv64; - var R31_3: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; + var #5: bv64; + var Gamma_#5: bool; lprintCharValue: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_in); - R0_2, Gamma_R0_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "lprintCharValue"} true; + #5, Gamma_#5 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #5, R29), gamma_store64(Gamma_stack, #5, Gamma_R29); + assume {:captureState "%0000045a"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#5, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#5, 8bv64), Gamma_R30); + assume {:captureState "%00000460"} true; + R31, Gamma_R31 := #5, Gamma_#5; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000472"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); - R0_3, Gamma_R0_3 := zero_extend56_8(memory_load8_le(mem, R0_2)), (gamma_load8(Gamma_mem, R0_2) || L(mem, R0_2)); - R0_4, Gamma_R0_4 := zero_extend32_32(bvadd32(R0_3[32:0], 1bv32)), Gamma_R0_3; - R1_1, Gamma_R1_1 := R0_4[8:0], Gamma_R0_4; - R0_5, Gamma_R0_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32((0bv24 ++ R0[8:0])), Gamma_R0; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store8_le(mem, R0_5, R1_1), gamma_store8(Gamma_mem, R0_5, Gamma_R1_1); - R0_6, Gamma_R0_6 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000049b"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); - R0_7, Gamma_R0_7 := zero_extend56_8(memory_load8_le(mem, R0_6)), (gamma_load8(Gamma_mem, R0_6) || L(mem, R0_6)); - R1_2, Gamma_R1_2 := zero_extend32_32(R0_7[32:0]), Gamma_R0_7; - call R0_10, Gamma_R0_10, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_3, Gamma_R1_3, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(2384bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1_2, Gamma_R1_2, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in, R2, Gamma_R2, 2296bv64, true, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2384bv64), Gamma_R0; + R30, Gamma_R30 := 2296bv64, true; + call printf(); + goto l000004c4; + l000004c4: + assume {:captureState "l000004c4"} true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto printCharValue_basil_return; printCharValue_basil_return: - R31_out := bvadd64(R31_3, 32bv64); - Gamma_R31_out := Gamma_R31_3; + assume {:captureState "printCharValue_basil_return"} true; return; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2328bv64) == 131073bv64); free requires (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); diff --git a/src/test/correct/malloc_with_local3/gcc/malloc_with_local3_gtirb.expected b/src/test/correct/malloc_with_local3/gcc/malloc_with_local3_gtirb.expected index f64e2df90..6206c7d40 100644 --- a/src/test/correct/malloc_with_local3/gcc/malloc_with_local3_gtirb.expected +++ b/src/test/correct/malloc_with_local3/gcc/malloc_with_local3_gtirb.expected @@ -1,29 +1,29 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2328bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -37,21 +37,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -65,23 +61,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2328bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free ensures (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); @@ -105,8 +101,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -119,8 +115,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_680(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2328bv64) == 131073bv64); free requires (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free requires (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); @@ -162,143 +158,20 @@ procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_680() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_680$__0__$fmUrfOHbTziivIh1CtAkdg: + assume {:captureState "$FUN_680$__0__$fmUrfOHbTziivIh1CtAkdg"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69544bv64), (gamma_load64(Gamma_mem, 69544bv64) || L(mem, 69544bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69544bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4008bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4008bv64)) || L(mem, bvadd64(R16, 4008bv64))); + R16, Gamma_R16 := bvadd64(R16, 4008bv64), Gamma_R16; + call malloc(); assume false; } -procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure printCharValue(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 2328bv64) == 131073bv64); free requires (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free requires (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); @@ -319,6 +192,10 @@ procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29 free requires (memory_load64_le(mem, 69000bv64) == 1984bv64); free requires (memory_load64_le(mem, 69616bv64) == 2068bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2328bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free ensures (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); @@ -340,50 +217,53 @@ procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29 free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation printCharValue(R0_in: bv64, Gamma_R0_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool) +implementation printCharValue() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var Gamma_R1_1: bool; - var R0_2: bv64; - var R0_3: bv64; - var R0_4: bv64; - var R0_5: bv64; - var R0_6: bv64; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; - var R1_1: bv8; + var Cse0__5$1$0: bv64; + var Gamma_Cse0__5$1$0: bool; $printCharValue$__0__$jkKHMcI6QseLTh14pX_pkA: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_in); - R0_2, Gamma_R0_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$printCharValue$__0__$jkKHMcI6QseLTh14pX_pkA"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$0, R29), gamma_store64(Gamma_stack, Cse0__5$1$0, Gamma_R29); + assume {:captureState "2236$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$0, 8bv64), Gamma_R30); + assume {:captureState "2236$2"} true; + R31, Gamma_R31 := Cse0__5$1$0, Gamma_Cse0__5$1$0; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "2244$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + call rely(); + R0, Gamma_R0 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R0))), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32((0bv24 ++ R0[8:0])), Gamma_R0; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); - R0_3, Gamma_R0_3 := zero_extend56_8(memory_load8_le(mem, R0_2)), (gamma_load8(Gamma_mem, R0_2) || L(mem, R0_2)); - R0_4, Gamma_R0_4 := zero_extend32_32(bvadd32(R0_3[32:0], 1bv32)), Gamma_R0_3; - R1_1, Gamma_R1_1 := R0_4[8:0], Gamma_R0_4; - R0_5, Gamma_R0_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2268$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store8_le(mem, R0_5, R1_1), gamma_store8(Gamma_mem, R0_5, Gamma_R1_1); - R0_6, Gamma_R0_6 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_6c0(R16, Gamma_R16); + R0, Gamma_R0 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R0))), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2384bv64), Gamma_R0; + R30, Gamma_R30 := 2296bv64, true; + call FUN_6c0(); + goto $printCharValue$__1__$SXzrMILSR1~X131kBRFqew; + $printCharValue$__1__$SXzrMILSR1~X131kBRFqew: + assume {:captureState "$printCharValue$__1__$SXzrMILSR1~X131kBRFqew"} true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto printCharValue_basil_return; printCharValue_basil_return: - R31_out := R31_in; - Gamma_R31_out := Gamma_R31_in; + assume {:captureState "printCharValue_basil_return"} true; return; } -procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6c0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2328bv64) == 131073bv64); free requires (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free requires (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); @@ -425,143 +305,20 @@ procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6c0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6c0$__0__$1dgk8kyGRWulXZar~5y0Vg: + assume {:captureState "$FUN_6c0$__0__$1dgk8kyGRWulXZar~5y0Vg"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69576bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4040bv64)) || L(mem, bvadd64(R16, 4040bv64))); + R16, Gamma_R16 := bvadd64(R16, 4040bv64), Gamma_R16; + call printf(); assume false; } -procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6b0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2328bv64) == 131073bv64); free requires (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free requires (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); @@ -603,143 +360,20 @@ procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6b0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6b0$__0__$ro0bVXILQkORwyd0nThiUA: + assume {:captureState "$FUN_6b0$__0__$ro0bVXILQkORwyd0nThiUA"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := #free(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69568bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4032bv64)) || L(mem, bvadd64(R16, 4032bv64))); + R16, Gamma_R16 := bvadd64(R16, 4032bv64), Gamma_R16; + call #free(); assume false; } -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2328bv64) == 131073bv64); @@ -762,6 +396,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69000bv64) == 1984bv64); free requires (memory_load64_le(mem, 69616bv64) == 2068bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2328bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free ensures (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); @@ -783,108 +421,112 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R0_9: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R16_7: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R17_7: bool; - var Gamma_R1_4: bool; - var Gamma_R29_3: bool; - var Gamma_R30_10: bool; - var Gamma_R31_3: bool; - var R0_10: bv64; - var R0_7: bv64; - var R0_8: bv64; - var R0_9: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R16_7: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R17_7: bv64; - var R1_4: bv64; - var R29_3: bv64; - var R30_10: bv64; - var R31_3: bv64; + var Cse0__5$1$0: bv64; + var Gamma_Cse0__5$1$0: bool; $main$__0__$Rrgu9bwQROy_ybbFoniuZw: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551552bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551552bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551560bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551560bv64), Gamma_R30_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_680(R16, Gamma_R16); + assume {:captureState "$main$__0__$Rrgu9bwQROy_ybbFoniuZw"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd64(R31, 18446744073709551552bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$0, R29), gamma_store64(Gamma_stack, Cse0__5$1$0, Gamma_R29); + assume {:captureState "2068$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$0, 8bv64), Gamma_R30); + assume {:captureState "2068$2"} true; + R31, Gamma_R31 := Cse0__5$1$0, Gamma_Cse0__5$1$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2084bv64, true; + call FUN_680(); goto $main$__1__$~QYw5PpOTImctI5IIXThPA; $main$__1__$~QYw5PpOTImctI5IIXThPA: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), 1bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551580bv64), 11bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64), true); - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := FUN_680(R16_1, Gamma_R16_1); + assume {:captureState "$main$__1__$~QYw5PpOTImctI5IIXThPA"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "2084$0"} true; + R0, Gamma_R0 := 11bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "2092$0"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2104bv64, true; + call FUN_680(); goto $main$__2__$SxiuTMn9TQuPWr33qVC1ig; $main$__2__$SxiuTMn9TQuPWr33qVC1ig: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551584bv64), 10bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), true); - call R16_3, Gamma_R16_3, R17_3, Gamma_R17_3 := FUN_680(R16_2, Gamma_R16_2); + assume {:captureState "$main$__2__$SxiuTMn9TQuPWr33qVC1ig"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 48bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 48bv64), Gamma_R0); + assume {:captureState "2104$0"} true; + R0, Gamma_R0 := 10bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 32bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "2112$0"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2124bv64, true; + call FUN_680(); goto $main$__3__$fN0A9b3HQhuiC36Xy0_rHA; $main$__3__$fN0A9b3HQhuiC36Xy0_rHA: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551588bv64), 9bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551588bv64), true); - R0_7, Gamma_R0_7 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "$main$__3__$fN0A9b3HQhuiC36Xy0_rHA"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 56bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 56bv64), Gamma_R0); + assume {:captureState "2124$0"} true; + R0, Gamma_R0 := 9bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_R0); + assume {:captureState "2132$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R1, Gamma_R1 := 65bv64, true; call rely(); - assert (L(mem, R0_7) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R0_7, 65bv8), gamma_store8(Gamma_mem, R0_7, true); - R0_8, Gamma_R0_8 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2144$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); + R1, Gamma_R1 := 42bv64, true; call rely(); - assert (L(mem, R0_8) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_8, 42bv32), gamma_store32(Gamma_mem, R0_8, true); - R0_9, Gamma_R0_9 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); - call R31_3, Gamma_R31_3 := printCharValue(R0_9, Gamma_R0_9, bvadd64(R31_in, 18446744073709551552bv64), Gamma_R31_in, 2168bv64, true, bvadd64(R31_in, 18446744073709551552bv64), Gamma_R31_in); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2156$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R30, Gamma_R30 := 2168bv64, true; + call printCharValue(); goto $main$__4__$BE~PRGMvSjG9MvttQyQE0g; $main$__4__$BE~PRGMvSjG9MvttQyQE0g: - R0_10, Gamma_R0_10 := memory_load64_le(stack, bvadd64(R31_3, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 48bv64)); - call R16_4, Gamma_R16_4, R17_4, Gamma_R17_4 := FUN_6c0(R16_3, Gamma_R16_3); + assume {:captureState "$main$__4__$BE~PRGMvSjG9MvttQyQE0g"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); + call rely(); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2336bv64), Gamma_R0; + R30, Gamma_R30 := 2192bv64, true; + call FUN_6c0(); goto $main$__5__$D4s2Co1KQ~Ky~M5w0gLHPQ; $main$__5__$D4s2Co1KQ~Ky~M5w0gLHPQ: - R1_4, Gamma_R1_4 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_3, 32bv64))), gamma_load32(Gamma_stack, bvadd64(R31_3, 32bv64)); - call R16_5, Gamma_R16_5, R17_5, Gamma_R17_5 := FUN_6c0(R16_4, Gamma_R16_4); + assume {:captureState "$main$__5__$D4s2Co1KQ~Ky~M5w0gLHPQ"} true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 32bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 32bv64)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2352bv64), Gamma_R0; + R30, Gamma_R30 := 2208bv64, true; + call FUN_6c0(); goto $main$__6__$p5nsnxjyQKOrSPmPj~5GAQ; $main$__6__$p5nsnxjyQKOrSPmPj~5GAQ: - call R16_6, Gamma_R16_6, R17_6, Gamma_R17_6 := FUN_6b0(R16_5, Gamma_R16_5); + assume {:captureState "$main$__6__$p5nsnxjyQKOrSPmPj~5GAQ"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); + R30, Gamma_R30 := 2216bv64, true; + call FUN_6b0(); goto $main$__7__$bVpViQZjRLKY7mskQ1PnAQ; $main$__7__$bVpViQZjRLKY7mskQ1PnAQ: - call R16_7, Gamma_R16_7, R17_7, Gamma_R17_7 := FUN_6b0(R16_6, Gamma_R16_6); + assume {:captureState "$main$__7__$bVpViQZjRLKY7mskQ1PnAQ"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); + R30, Gamma_R30 := 2224bv64, true; + call FUN_6b0(); goto $main$__8__$ZGCusIYzRSyjeisM9blzeQ; $main$__8__$ZGCusIYzRSyjeisM9blzeQ: - R29_3, Gamma_R29_3 := memory_load64_le(stack, R31_3), gamma_load64(Gamma_stack, R31_3); - R30_10, Gamma_R30_10 := memory_load64_le(stack, bvadd64(R31_3, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 8bv64)); + assume {:captureState "$main$__8__$ZGCusIYzRSyjeisM9blzeQ"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 64bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R16_7, R17_7, R1_4, R29_3, R30_10, bvadd64(R31_3, 64bv64); - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R16_7, Gamma_R17_7, Gamma_R1_4, Gamma_R29_3, Gamma_R30_10, Gamma_R31_3; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); free requires (memory_load64_le(mem, 2328bv64) == 131073bv64); free requires (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free requires (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); @@ -926,7 +568,7 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load64_le(mem, 2328bv64) == 131073bv64); free requires (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free requires (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); @@ -968,7 +610,7 @@ procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); free requires (memory_load64_le(mem, 2328bv64) == 131073bv64); free requires (memory_load64_le(mem, 2336bv64) == 2338615504306268244bv64); free requires (memory_load64_le(mem, 2344bv64) == 2924860384375657bv64); diff --git a/src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3.expected b/src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3.expected index f09ee17f1..6121cf2f2 100644 --- a/src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3.expected +++ b/src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3.expected @@ -1,28 +1,35 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R19: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R19: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R3: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2264bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } @@ -32,17 +39,13 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -52,19 +55,19 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2264bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2280bv64) == 7575166128241079840bv64); @@ -84,8 +87,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -98,7 +101,7 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure __printf_chk(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure __printf_chk(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2264bv64) == 131073bv64); free requires (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); @@ -133,7 +136,7 @@ procedure __printf_chk(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_i free ensures (memory_load64_le(mem, 69616bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2264bv64) == 131073bv64); free requires (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); @@ -168,8 +171,8 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69616bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure main(R19_in: bv64, Gamma_R19_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R19, Gamma_R2, Gamma_R29, Gamma_R3, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R19, R2, R29, R3, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2264bv64) == 131073bv64); @@ -188,6 +191,12 @@ procedure main(R19_in: bv64, Gamma_R19_in: bool, R29_in: bv64, Gamma_R29_in: boo free requires (memory_load64_le(mem, 69000bv64) == 2112bv64); free requires (memory_load64_le(mem, 69616bv64) == 1792bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R19 == old(Gamma_R19)); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R19 == old(R19)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2264bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2280bv64) == 7575166128241079840bv64); @@ -205,365 +214,74 @@ procedure main(R19_in: bv64, Gamma_R19_in: bool, R29_in: bv64, Gamma_R29_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R19_in: bv64, Gamma_R19_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_9: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R10_2: bool; - var Gamma_R10_3: bool; - var Gamma_R10_4: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R11_2: bool; - var Gamma_R11_3: bool; - var Gamma_R11_4: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R12_2: bool; - var Gamma_R12_3: bool; - var Gamma_R12_4: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R13_2: bool; - var Gamma_R13_3: bool; - var Gamma_R13_4: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R14_2: bool; - var Gamma_R14_3: bool; - var Gamma_R14_4: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R15_2: bool; - var Gamma_R15_3: bool; - var Gamma_R15_4: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R18_2: bool; - var Gamma_R18_3: bool; - var Gamma_R18_4: bool; - var Gamma_R19_2: bool; - var Gamma_R19_4: bool; - var Gamma_R19_5: bool; - var Gamma_R19_6: bool; - var Gamma_R19_7: bool; - var Gamma_R1_1: bool; - var Gamma_R1_10: bool; - var Gamma_R1_3: bool; - var Gamma_R1_6: bool; - var Gamma_R1_9: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R20_2: bool; - var Gamma_R20_3: bool; - var Gamma_R20_4: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R21_2: bool; - var Gamma_R21_3: bool; - var Gamma_R21_4: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R22_2: bool; - var Gamma_R22_3: bool; - var Gamma_R22_4: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R23_2: bool; - var Gamma_R23_3: bool; - var Gamma_R23_4: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R24_2: bool; - var Gamma_R24_3: bool; - var Gamma_R24_4: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R25_2: bool; - var Gamma_R25_3: bool; - var Gamma_R25_4: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R26_2: bool; - var Gamma_R26_3: bool; - var Gamma_R26_4: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R27_2: bool; - var Gamma_R27_3: bool; - var Gamma_R27_4: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R28_2: bool; - var Gamma_R28_3: bool; - var Gamma_R28_4: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R29_5: bool; - var Gamma_R29_6: bool; - var Gamma_R29_7: bool; - var Gamma_R2_1: bool; - var Gamma_R2_2: bool; - var Gamma_R2_4: bool; - var Gamma_R2_6: bool; - var Gamma_R2_7: bool; - var Gamma_R3: bool; - var Gamma_R30_10: bool; - var Gamma_R30_11: bool; - var Gamma_R30_3: bool; - var Gamma_R30_6: bool; - var Gamma_R30_8: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R31_5: bool; - var Gamma_R31_6: bool; - var Gamma_R3_1: bool; - var Gamma_R3_2: bool; - var Gamma_R3_3: bool; - var Gamma_R3_4: bool; - var Gamma_R3_5: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R4_2: bool; - var Gamma_R4_3: bool; - var Gamma_R4_4: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R5_2: bool; - var Gamma_R5_3: bool; - var Gamma_R5_4: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R6_2: bool; - var Gamma_R6_3: bool; - var Gamma_R6_4: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R7_2: bool; - var Gamma_R7_3: bool; - var Gamma_R7_4: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var Gamma_R9_4: bool; - var R0_2: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_9: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R10_2: bv64; - var R10_3: bv64; - var R10_4: bv64; - var R11: bv64; - var R11_1: bv64; - var R11_2: bv64; - var R11_3: bv64; - var R11_4: bv64; - var R12: bv64; - var R12_1: bv64; - var R12_2: bv64; - var R12_3: bv64; - var R12_4: bv64; - var R13: bv64; - var R13_1: bv64; - var R13_2: bv64; - var R13_3: bv64; - var R13_4: bv64; - var R14: bv64; - var R14_1: bv64; - var R14_2: bv64; - var R14_3: bv64; - var R14_4: bv64; - var R15: bv64; - var R15_1: bv64; - var R15_2: bv64; - var R15_3: bv64; - var R15_4: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R17: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R18: bv64; - var R18_1: bv64; - var R18_2: bv64; - var R18_3: bv64; - var R18_4: bv64; - var R19_2: bv64; - var R19_4: bv64; - var R19_5: bv64; - var R19_6: bv64; - var R19_7: bv64; - var R1_1: bv64; - var R1_10: bv64; - var R1_3: bv64; - var R1_6: bv64; - var R1_9: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R20_2: bv64; - var R20_3: bv64; - var R20_4: bv64; - var R21: bv64; - var R21_1: bv64; - var R21_2: bv64; - var R21_3: bv64; - var R21_4: bv64; - var R22: bv64; - var R22_1: bv64; - var R22_2: bv64; - var R22_3: bv64; - var R22_4: bv64; - var R23: bv64; - var R23_1: bv64; - var R23_2: bv64; - var R23_3: bv64; - var R23_4: bv64; - var R24: bv64; - var R24_1: bv64; - var R24_2: bv64; - var R24_3: bv64; - var R24_4: bv64; - var R25: bv64; - var R25_1: bv64; - var R25_2: bv64; - var R25_3: bv64; - var R25_4: bv64; - var R26: bv64; - var R26_1: bv64; - var R26_2: bv64; - var R26_3: bv64; - var R26_4: bv64; - var R27: bv64; - var R27_1: bv64; - var R27_2: bv64; - var R27_3: bv64; - var R27_4: bv64; - var R28: bv64; - var R28_1: bv64; - var R28_2: bv64; - var R28_3: bv64; - var R28_4: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R29_5: bv64; - var R29_6: bv64; - var R29_7: bv64; - var R2_1: bv64; - var R2_2: bv64; - var R2_4: bv64; - var R2_6: bv64; - var R2_7: bv64; - var R3: bv64; - var R30_10: bv64; - var R30_11: bv64; - var R30_3: bv64; - var R30_6: bv64; - var R30_8: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R31_5: bv64; - var R31_6: bv64; - var R3_1: bv64; - var R3_2: bv64; - var R3_3: bv64; - var R3_4: bv64; - var R3_5: bv64; - var R4: bv64; - var R4_1: bv64; - var R4_2: bv64; - var R4_3: bv64; - var R4_4: bv64; - var R5: bv64; - var R5_1: bv64; - var R5_2: bv64; - var R5_3: bv64; - var R5_4: bv64; - var R6: bv64; - var R6_1: bv64; - var R6_2: bv64; - var R6_3: bv64; - var R6_4: bv64; - var R7: bv64; - var R7_1: bv64; - var R7_2: bv64; - var R7_3: bv64; - var R7_4: bv64; - var R8: bv64; - var R8_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R8_4: bv64; - var R9: bv64; - var R9_1: bv64; - var R9_2: bv64; - var R9_3: bv64; - var R9_4: bv64; + var #1: bv64; + var Gamma_#1: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R19_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R19_in); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_2, Gamma_R19_2, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(1bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19_in, Gamma_R19_in, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in, R2, Gamma_R2, 1812bv64, true, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + assume {:captureState "lmain"} true; + #1, Gamma_#1 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #1, R29), gamma_store64(Gamma_stack, #1, Gamma_R29); + assume {:captureState "%00000222"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#1, 8bv64), Gamma_R30); + assume {:captureState "%00000228"} true; + R31, Gamma_R31 := #1, Gamma_#1; + R0, Gamma_R0 := 1bv64, true; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R19), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R19); + assume {:captureState "%0000023f"} true; + R30, Gamma_R30 := 1812bv64, true; + call malloc(); goto l00000249; l00000249: + assume {:captureState "l00000249"} true; + R1, Gamma_R1 := 65bv64, true; call rely(); - assert (L(mem, R0_2) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R0_2, 65bv8), gamma_store8(Gamma_mem, R0_2, true); - call R0_3, Gamma_R0_3, R1_3, Gamma_R1_3, R2_2, Gamma_R2_2, R3_2, Gamma_R3_2 := printCharValue(R0_2, Gamma_R0_2, 65bv64, true, R2_1, Gamma_R2_1, R3_1, Gamma_R3_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000254"} true; + R19, Gamma_R19 := R0, Gamma_R0; + R30, Gamma_R30 := 1828bv64, true; + call printCharValue(); goto l0000029a; l0000029a: - call R0_5, Gamma_R0_5, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_4, Gamma_R19_4, R1_6, Gamma_R1_6, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_4, Gamma_R2_4, R30_6, Gamma_R30_6, R31_4, Gamma_R31_4, R3_3, Gamma_R3_3, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2 := __printf_chk(1bv64, true, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R0_2, Gamma_R0_2, 2296bv64, true, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, 42bv64, true, 1848bv64, true, R31_3, Gamma_R31_3, R3_2, Gamma_R3_2, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1); + assume {:captureState "l0000029a"} true; + R2, Gamma_R2 := 42bv64, true; + R1, Gamma_R1 := 0bv64, true; + R0, Gamma_R0 := 1bv64, true; + R1, Gamma_R1 := bvadd64(R1, 2296bv64), Gamma_R1; + R30, Gamma_R30 := 1848bv64, true; + call __printf_chk(); goto l000002b6; l000002b6: - call R0_7, Gamma_R0_7, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_5, Gamma_R19_5, R1_9, Gamma_R1_9, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_6, Gamma_R2_6, R30_8, Gamma_R30_8, R31_5, Gamma_R31_5, R3_4, Gamma_R3_4, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_3, Gamma_R8_3, R9_3, Gamma_R9_3 := __printf_chk(1bv64, true, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_4, Gamma_R19_4, 2312bv64, true, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, 10bv64, true, 1868bv64, true, R31_4, Gamma_R31_4, R3_3, Gamma_R3_3, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2); + assume {:captureState "l000002b6"} true; + R1, Gamma_R1 := 0bv64, true; + R1, Gamma_R1 := bvadd64(R1, 2312bv64), Gamma_R1; + R2, Gamma_R2 := 10bv64, true; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 1868bv64, true; + call __printf_chk(); goto l000002d2; l000002d2: - call R0_9, Gamma_R0_9, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_6, Gamma_R19_6, R1_10, Gamma_R1_10, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_7, Gamma_R2_7, R30_10, Gamma_R30_10, R31_6, Gamma_R31_6, R3_5, Gamma_R3_5, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_4, Gamma_R8_4, R9_4, Gamma_R9_4 := #free(R19_5, Gamma_R19_5, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_5, Gamma_R19_5, R1_9, Gamma_R1_9, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_6, Gamma_R2_6, 1876bv64, true, R31_5, Gamma_R31_5, R3_4, Gamma_R3_4, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_3, Gamma_R8_3, R9_3, Gamma_R9_3); + assume {:captureState "l000002d2"} true; + R0, Gamma_R0 := R19, Gamma_R19; + R30, Gamma_R30 := 1876bv64, true; + call #free(); goto l000002e0; l000002e0: - R19_7, Gamma_R19_7 := memory_load64_le(stack, bvadd64(R31_6, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_6, 16bv64)); - R29_7, Gamma_R29_7 := memory_load64_le(stack, R31_6), gamma_load64(Gamma_stack, R31_6); - R30_11, Gamma_R30_11 := memory_load64_le(stack, bvadd64(R31_6, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_6, 8bv64)); + assume {:captureState "l000002e0"} true; + R0, Gamma_R0 := 0bv64, true; + R19, Gamma_R19 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R19_out, R1_out, R29_out, R2_out, R30_out, R31_out := 0bv64, R19_7, R1_10, R29_7, R2_7, R30_11, bvadd64(R31_6, 32bv64); - Gamma_R0_out, Gamma_R19_out, Gamma_R1_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R19_7, Gamma_R1_10, Gamma_R29_7, Gamma_R2_7, Gamma_R30_11, Gamma_R31_6; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2264bv64) == 131073bv64); free requires (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); @@ -598,8 +316,8 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; +procedure printCharValue(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R2, Gamma_R3, Gamma_mem, R0, R1, R16, R17, R2, R3, mem; free requires (memory_load64_le(mem, 2264bv64) == 131073bv64); free requires (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2280bv64) == 7575166128241079840bv64); @@ -633,143 +351,23 @@ procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_i free ensures (memory_load64_le(mem, 69616bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation printCharValue(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool) +implementation printCharValue() { - var Gamma_R0_3: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_4: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var Gamma_R2_4: bool; - var Gamma_R2_5: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_3: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0_3: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16: bv64; - var R16_1: bv64; - var R17: bv64; - var R17_1: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_4: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_2: bv64; - var R2_3: bv64; - var R2_4: bv64; - var R2_5: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_3: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; lprintCharValue: + assume {:captureState "lprintCharValue"} true; + R3, Gamma_R3 := R0, Gamma_R0; + R0, Gamma_R0 := 1bv64, true; + R1, Gamma_R1 := 0bv64, true; + R1, Gamma_R1 := bvadd64(R1, 2272bv64), Gamma_R1; call rely(); - R2_2, Gamma_R2_2 := zero_extend56_8(memory_load8_le(mem, R0_in)), (gamma_load8(Gamma_mem, R0_in) || L(mem, R0_in)); - R2_3, Gamma_R2_3 := zero_extend32_32(bvadd32(R2_2[32:0], 1bv32)), Gamma_R2_2; - R2_4, Gamma_R2_4 := zero_extend56_8(R2_3[8:0]), Gamma_R2_3; + R2, Gamma_R2 := zero_extend56_8(memory_load8_le(mem, R3)), (gamma_load8(Gamma_mem, R3) || L(mem, R3)); + R2, Gamma_R2 := zero_extend32_32(bvadd32(R2[32:0], R0[32:0])), (Gamma_R0 && Gamma_R2); + R2, Gamma_R2 := zero_extend32_32((0bv24 ++ R2[8:0])), Gamma_R2; call rely(); - assert (L(mem, R0_in) ==> Gamma_R2_4); - mem, Gamma_mem := memory_store8_le(mem, R0_in, R2_4[8:0]), gamma_store8(Gamma_mem, R0_in, Gamma_R2_4); - call R0_3, Gamma_R0_3, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_4, Gamma_R1_4, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_5, Gamma_R2_5, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_3, Gamma_R3_3, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := __printf_chk(1bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, 2272bv64, true, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2_4, Gamma_R2_4, R30, Gamma_R30, R31, Gamma_R31, R0_in, Gamma_R0_in, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + assert (L(mem, R3) ==> Gamma_R2); + mem, Gamma_mem := memory_store8_le(mem, R3, R2[8:0]), gamma_store8(Gamma_mem, R3, Gamma_R2); + assume {:captureState "%00000293"} true; + call __printf_chk(); assume false; } diff --git a/src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3_gtirb.expected b/src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3_gtirb.expected index 24833760d..86a87c185 100644 --- a/src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3_gtirb.expected +++ b/src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3_gtirb.expected @@ -1,24 +1,35 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R19: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R19: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R3: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2264bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } @@ -28,17 +39,13 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -48,19 +55,19 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2264bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2280bv64) == 7575166128241079840bv64); @@ -80,8 +87,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -94,8 +101,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_690(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_690(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2264bv64) == 131073bv64); free requires (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2280bv64) == 7575166128241079840bv64); @@ -129,143 +136,20 @@ procedure FUN_690(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_690(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_690() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_690$__0__$mY9s1Q7ERri98AKVPtsmww: + assume {:captureState "$FUN_690$__0__$mY9s1Q7ERri98AKVPtsmww"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69544bv64), (gamma_load64(Gamma_mem, 69544bv64) || L(mem, 69544bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69544bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4008bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4008bv64)) || L(mem, bvadd64(R16, 4008bv64))); + R16, Gamma_R16 := bvadd64(R16, 4008bv64), Gamma_R16; + call malloc(); assume false; } -procedure FUN_6d0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6d0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2264bv64) == 131073bv64); free requires (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2280bv64) == 7575166128241079840bv64); @@ -299,143 +183,20 @@ procedure FUN_6d0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_6d0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6d0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6d0$__0__$TBxeE0XrQd~VB7pBlFfEjQ: + assume {:captureState "$FUN_6d0$__0__$TBxeE0XrQd~VB7pBlFfEjQ"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := #free(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69576bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4040bv64)) || L(mem, bvadd64(R16, 4040bv64))); + R16, Gamma_R16 := bvadd64(R16, 4040bv64), Gamma_R16; + call #free(); assume false; } -procedure FUN_6a0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6a0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2264bv64) == 131073bv64); free requires (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2280bv64) == 7575166128241079840bv64); @@ -469,143 +230,20 @@ procedure FUN_6a0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_6a0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6a0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6a0$__0__$O00NhqclR_SCVHbvubgdHA: + assume {:captureState "$FUN_6a0$__0__$O00NhqclR_SCVHbvubgdHA"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69552bv64), (gamma_load64(Gamma_mem, 69552bv64) || L(mem, 69552bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := __printf_chk(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69552bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4016bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4016bv64)) || L(mem, bvadd64(R16, 4016bv64))); + R16, Gamma_R16 := bvadd64(R16, 4016bv64), Gamma_R16; + call __printf_chk(); assume false; } -procedure main(R19_in: bv64, Gamma_R19_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R19, Gamma_R2, Gamma_R29, Gamma_R3, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R19, R2, R29, R3, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2264bv64) == 131073bv64); @@ -624,6 +262,12 @@ procedure main(R19_in: bv64, Gamma_R19_in: bool, R29_in: bv64, Gamma_R29_in: boo free requires (memory_load64_le(mem, 69000bv64) == 2112bv64); free requires (memory_load64_le(mem, 69616bv64) == 1792bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R19 == old(Gamma_R19)); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R19 == old(R19)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2264bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2280bv64) == 7575166128241079840bv64); @@ -641,82 +285,75 @@ procedure main(R19_in: bv64, Gamma_R19_in: bool, R29_in: bv64, Gamma_R29_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R19_in: bv64, Gamma_R19_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R19_3: bool; - var Gamma_R1_2: bool; - var Gamma_R2: bool; - var Gamma_R29_3: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30_7: bool; - var Gamma_R3_1: bool; - var R0_2: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R19_3: bv64; - var R1_2: bv64; - var R2: bv64; - var R29_3: bv64; - var R2_1: bv64; - var R3: bv64; - var R30_7: bv64; - var R3_1: bv64; + var Cse0__5$2$0: bv64; + var Gamma_Cse0__5$2$0: bool; $main$__0__$EGWpjBzGR2uGhrMJAyG~3g: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R19_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R19_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_690(R16, Gamma_R16); + assume {:captureState "$main$__0__$EGWpjBzGR2uGhrMJAyG~3g"} true; + Cse0__5$2$0, Gamma_Cse0__5$2$0 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$2$0, R29), gamma_store64(Gamma_stack, Cse0__5$2$0, Gamma_R29); + assume {:captureState "1792$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$2$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$2$0, 8bv64), Gamma_R30); + assume {:captureState "1792$2"} true; + R31, Gamma_R31 := Cse0__5$2$0, Gamma_Cse0__5$2$0; + R0, Gamma_R0 := 1bv64, true; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R19), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R19); + assume {:captureState "1804$0"} true; + R30, Gamma_R30 := 1812bv64, true; + call FUN_690(); goto $main$__1__$1G3_7a3~SsmqJyDUhqAFGg; $main$__1__$1G3_7a3~SsmqJyDUhqAFGg: + assume {:captureState "$main$__1__$1G3_7a3~SsmqJyDUhqAFGg"} true; + R1, Gamma_R1 := 65bv64, true; call rely(); - assert (L(mem, 1bv64) ==> true); - mem, Gamma_mem := memory_store8_le(mem, 1bv64, 65bv8), gamma_store8(Gamma_mem, 1bv64, true); - call R0_2, Gamma_R0_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R1_2, Gamma_R1_2, R2_1, Gamma_R2_1, R3_1, Gamma_R3_1 := printCharValue(1bv64, true, R16_1, Gamma_R16_1, 65bv64, true, R2, Gamma_R2, R3, Gamma_R3); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1816$0"} true; + R19, Gamma_R19 := R0, Gamma_R0; + R30, Gamma_R30 := 1828bv64, true; + call printCharValue(); goto $main$__2__$rV0qH7AUTYCipfKaroPpAw; $main$__2__$rV0qH7AUTYCipfKaroPpAw: - call R16_3, Gamma_R16_3, R17_3, Gamma_R17_3 := FUN_6a0(R16_2, Gamma_R16_2); + assume {:captureState "$main$__2__$rV0qH7AUTYCipfKaroPpAw"} true; + R2, Gamma_R2 := 42bv64, true; + R1, Gamma_R1 := 0bv64, true; + R0, Gamma_R0 := 1bv64, true; + R1, Gamma_R1 := bvadd64(R1, 2296bv64), Gamma_R1; + R30, Gamma_R30 := 1848bv64, true; + call FUN_6a0(); goto $main$__3__$IxBBXD6FTfupEp7ajNK8uA; $main$__3__$IxBBXD6FTfupEp7ajNK8uA: - call R16_4, Gamma_R16_4, R17_4, Gamma_R17_4 := FUN_6a0(R16_3, Gamma_R16_3); + assume {:captureState "$main$__3__$IxBBXD6FTfupEp7ajNK8uA"} true; + R1, Gamma_R1 := 0bv64, true; + R1, Gamma_R1 := bvadd64(R1, 2312bv64), Gamma_R1; + R2, Gamma_R2 := 10bv64, true; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 1868bv64, true; + call FUN_6a0(); goto $main$__4__$aEiQ_BI9RcCTTmScF~6KKw; $main$__4__$aEiQ_BI9RcCTTmScF~6KKw: - call R16_5, Gamma_R16_5, R17_5, Gamma_R17_5 := FUN_6d0(R16_4, Gamma_R16_4); + assume {:captureState "$main$__4__$aEiQ_BI9RcCTTmScF~6KKw"} true; + R0, Gamma_R0 := R19, Gamma_R19; + R30, Gamma_R30 := 1812bv64, true; + call FUN_6d0(); goto $main$__5__$WNzpebfFQGeh7VGQ52Mh0w; $main$__5__$WNzpebfFQGeh7VGQ52Mh0w: - R19_3, Gamma_R19_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - R30_7, Gamma_R30_7 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "$main$__5__$WNzpebfFQGeh7VGQ52Mh0w"} true; + R0, Gamma_R0 := 0bv64, true; + R19, Gamma_R19 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R19_out, R1_out, R29_out, R2_out, R30_out, R31_out := 0bv64, R16_5, R17_5, R19_3, 2312bv64, R29_3, 10bv64, R30_7, R31_in; - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R19_out, Gamma_R1_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R16_5, Gamma_R17_5, Gamma_R19_3, true, Gamma_R29_3, true, Gamma_R30_7, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } -procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R16_in: bv64, Gamma_R16_in: bool, R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool); - modifies Gamma_mem, mem; +procedure printCharValue(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R2, Gamma_R3, Gamma_mem, R0, R1, R16, R17, R2, R3, mem; free requires (memory_load64_le(mem, 2264bv64) == 131073bv64); free requires (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2280bv64) == 7575166128241079840bv64); @@ -750,31 +387,27 @@ procedure printCharValue(R0_in: bv64, Gamma_R0_in: bool, R16_in: bv64, Gamma_R16 free ensures (memory_load64_le(mem, 69616bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation printCharValue(R0_in: bv64, Gamma_R0_in: bool, R16_in: bv64, Gamma_R16_in: bool, R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool) +implementation printCharValue() { - var Gamma_R16_2: bool; - var Gamma_R17_1: bool; - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var Gamma_R2_4: bool; - var R16_2: bv64; - var R17_1: bv64; - var R2_2: bv64; - var R2_3: bv64; - var R2_4: bv8; $printCharValue$__0__$PI~q8_8oRjGuRvGwgENEcw: + assume {:captureState "$printCharValue$__0__$PI~q8_8oRjGuRvGwgENEcw"} true; + R3, Gamma_R3 := R0, Gamma_R0; + R0, Gamma_R0 := 1bv64, true; + R1, Gamma_R1 := 0bv64, true; + R1, Gamma_R1 := bvadd64(R1, 2272bv64), Gamma_R1; call rely(); - R2_2, Gamma_R2_2 := zero_extend56_8(memory_load8_le(mem, R0_in)), (gamma_load8(Gamma_mem, R0_in) || L(mem, R0_in)); - R2_3, Gamma_R2_3 := zero_extend32_32(bvadd32(R2_2[32:0], 1bv32)), Gamma_R2_2; - R2_4, Gamma_R2_4 := R2_3[8:0], Gamma_R2_3; + R2, Gamma_R2 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R3))), (gamma_load8(Gamma_mem, R3) || L(mem, R3)); + R2, Gamma_R2 := zero_extend32_32(bvadd32(R2[32:0], R0[32:0])), (Gamma_R0 && Gamma_R2); + R2, Gamma_R2 := zero_extend32_32((0bv24 ++ R2[8:0])), Gamma_R2; call rely(); - assert (L(mem, R0_in) ==> Gamma_R2_4); - mem, Gamma_mem := memory_store8_le(mem, R0_in, R2_4), gamma_store8(Gamma_mem, R0_in, Gamma_R2_4); - call R16_2, Gamma_R16_2, R17_1, Gamma_R17_1 := FUN_6a0(R16_in, Gamma_R16_in); + assert (L(mem, R3) ==> Gamma_R2); + mem, Gamma_mem := memory_store8_le(mem, R3, R2[8:0]), gamma_store8(Gamma_mem, R3, Gamma_R2); + assume {:captureState "2236$0"} true; + call FUN_6a0(); assume false; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); free requires (memory_load64_le(mem, 2264bv64) == 131073bv64); free requires (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2280bv64) == 7575166128241079840bv64); @@ -808,7 +441,7 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); free requires (memory_load64_le(mem, 2264bv64) == 131073bv64); free requires (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2280bv64) == 7575166128241079840bv64); @@ -842,7 +475,7 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69616bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure __printf_chk(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure __printf_chk(); free requires (memory_load64_le(mem, 2264bv64) == 131073bv64); free requires (memory_load64_le(mem, 2272bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2280bv64) == 7575166128241079840bv64); diff --git a/src/test/correct/multi_malloc/clang/multi_malloc.expected b/src/test/correct/multi_malloc/clang/multi_malloc.expected index d5548b6e8..8d34e535f 100644 --- a/src/test/correct/multi_malloc/clang/multi_malloc.expected +++ b/src/test/correct/multi_malloc/clang/multi_malloc.expected @@ -1,32 +1,32 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2232bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -40,21 +40,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -68,23 +64,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2240bv64) == 4211825664600402019bv64); free ensures (memory_load64_le(mem, 2248bv64) == 7307182754559632672bv64); @@ -101,8 +97,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -115,7 +111,7 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2240bv64) == 4211825664600402019bv64); @@ -144,8 +140,8 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69688bv64) == 0bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); free requires (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); @@ -161,6 +157,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1984bv64); free requires (memory_load64_le(mem, 69592bv64) == 2068bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2240bv64) == 4211825664600402019bv64); free ensures (memory_load64_le(mem, 2248bv64) == 7307182754559632672bv64); @@ -175,520 +175,98 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_11: bool; - var Gamma_R0_12: bool; - var Gamma_R0_13: bool; - var Gamma_R0_14: bool; - var Gamma_R0_15: bool; - var Gamma_R0_2: bool; - var Gamma_R0_4: bool; - var Gamma_R0_7: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R10_2: bool; - var Gamma_R10_3: bool; - var Gamma_R10_4: bool; - var Gamma_R10_5: bool; - var Gamma_R10_6: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R11_2: bool; - var Gamma_R11_3: bool; - var Gamma_R11_4: bool; - var Gamma_R11_5: bool; - var Gamma_R11_6: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R12_2: bool; - var Gamma_R12_3: bool; - var Gamma_R12_4: bool; - var Gamma_R12_5: bool; - var Gamma_R12_6: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R13_2: bool; - var Gamma_R13_3: bool; - var Gamma_R13_4: bool; - var Gamma_R13_5: bool; - var Gamma_R13_6: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R14_2: bool; - var Gamma_R14_3: bool; - var Gamma_R14_4: bool; - var Gamma_R14_5: bool; - var Gamma_R14_6: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R15_2: bool; - var Gamma_R15_3: bool; - var Gamma_R15_4: bool; - var Gamma_R15_5: bool; - var Gamma_R15_6: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R18_2: bool; - var Gamma_R18_3: bool; - var Gamma_R18_4: bool; - var Gamma_R18_5: bool; - var Gamma_R18_6: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R19_2: bool; - var Gamma_R19_3: bool; - var Gamma_R19_4: bool; - var Gamma_R19_5: bool; - var Gamma_R19_6: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var Gamma_R1_6: bool; - var Gamma_R1_7: bool; - var Gamma_R1_8: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R20_2: bool; - var Gamma_R20_3: bool; - var Gamma_R20_4: bool; - var Gamma_R20_5: bool; - var Gamma_R20_6: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R21_2: bool; - var Gamma_R21_3: bool; - var Gamma_R21_4: bool; - var Gamma_R21_5: bool; - var Gamma_R21_6: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R22_2: bool; - var Gamma_R22_3: bool; - var Gamma_R22_4: bool; - var Gamma_R22_5: bool; - var Gamma_R22_6: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R23_2: bool; - var Gamma_R23_3: bool; - var Gamma_R23_4: bool; - var Gamma_R23_5: bool; - var Gamma_R23_6: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R24_2: bool; - var Gamma_R24_3: bool; - var Gamma_R24_4: bool; - var Gamma_R24_5: bool; - var Gamma_R24_6: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R25_2: bool; - var Gamma_R25_3: bool; - var Gamma_R25_4: bool; - var Gamma_R25_5: bool; - var Gamma_R25_6: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R26_2: bool; - var Gamma_R26_3: bool; - var Gamma_R26_4: bool; - var Gamma_R26_5: bool; - var Gamma_R26_6: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R27_2: bool; - var Gamma_R27_3: bool; - var Gamma_R27_4: bool; - var Gamma_R27_5: bool; - var Gamma_R27_6: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R28_2: bool; - var Gamma_R28_3: bool; - var Gamma_R28_4: bool; - var Gamma_R28_5: bool; - var Gamma_R28_6: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R29_5: bool; - var Gamma_R29_6: bool; - var Gamma_R29_7: bool; - var Gamma_R29_8: bool; - var Gamma_R29_9: bool; - var Gamma_R2_1: bool; - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var Gamma_R2_4: bool; - var Gamma_R2_5: bool; - var Gamma_R2_6: bool; - var Gamma_R3: bool; - var Gamma_R30_11: bool; - var Gamma_R30_13: bool; - var Gamma_R30_14: bool; - var Gamma_R30_3: bool; - var Gamma_R30_5: bool; - var Gamma_R30_7: bool; - var Gamma_R30_9: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R31_5: bool; - var Gamma_R31_6: bool; - var Gamma_R31_7: bool; - var Gamma_R31_8: bool; - var Gamma_R3_1: bool; - var Gamma_R3_2: bool; - var Gamma_R3_3: bool; - var Gamma_R3_4: bool; - var Gamma_R3_5: bool; - var Gamma_R3_6: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R4_2: bool; - var Gamma_R4_3: bool; - var Gamma_R4_4: bool; - var Gamma_R4_5: bool; - var Gamma_R4_6: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R5_2: bool; - var Gamma_R5_3: bool; - var Gamma_R5_4: bool; - var Gamma_R5_5: bool; - var Gamma_R5_6: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R6_2: bool; - var Gamma_R6_3: bool; - var Gamma_R6_4: bool; - var Gamma_R6_5: bool; - var Gamma_R6_6: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R7_2: bool; - var Gamma_R7_3: bool; - var Gamma_R7_4: bool; - var Gamma_R7_5: bool; - var Gamma_R7_6: bool; - var Gamma_R8_10: bool; - var Gamma_R8_11: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_6: bool; - var Gamma_R8_7: bool; - var Gamma_R8_8: bool; - var Gamma_R8_9: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var Gamma_R9_4: bool; - var Gamma_R9_5: bool; - var Gamma_R9_6: bool; - var Gamma_R9_7: bool; - var Gamma_R9_8: bool; - var R0_10: bv64; - var R0_11: bv64; - var R0_12: bv64; - var R0_13: bv64; - var R0_14: bv64; - var R0_15: bv64; - var R0_2: bv64; - var R0_4: bv64; - var R0_7: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R10_2: bv64; - var R10_3: bv64; - var R10_4: bv64; - var R10_5: bv64; - var R10_6: bv64; - var R11: bv64; - var R11_1: bv64; - var R11_2: bv64; - var R11_3: bv64; - var R11_4: bv64; - var R11_5: bv64; - var R11_6: bv64; - var R12: bv64; - var R12_1: bv64; - var R12_2: bv64; - var R12_3: bv64; - var R12_4: bv64; - var R12_5: bv64; - var R12_6: bv64; - var R13: bv64; - var R13_1: bv64; - var R13_2: bv64; - var R13_3: bv64; - var R13_4: bv64; - var R13_5: bv64; - var R13_6: bv64; - var R14: bv64; - var R14_1: bv64; - var R14_2: bv64; - var R14_3: bv64; - var R14_4: bv64; - var R14_5: bv64; - var R14_6: bv64; - var R15: bv64; - var R15_1: bv64; - var R15_2: bv64; - var R15_3: bv64; - var R15_4: bv64; - var R15_5: bv64; - var R15_6: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R17: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R18: bv64; - var R18_1: bv64; - var R18_2: bv64; - var R18_3: bv64; - var R18_4: bv64; - var R18_5: bv64; - var R18_6: bv64; - var R19: bv64; - var R19_1: bv64; - var R19_2: bv64; - var R19_3: bv64; - var R19_4: bv64; - var R19_5: bv64; - var R19_6: bv64; - var R1_1: bv64; - var R1_2: bv64; - var R1_3: bv64; - var R1_4: bv64; - var R1_5: bv64; - var R1_6: bv64; - var R1_7: bv64; - var R1_8: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R20_2: bv64; - var R20_3: bv64; - var R20_4: bv64; - var R20_5: bv64; - var R20_6: bv64; - var R21: bv64; - var R21_1: bv64; - var R21_2: bv64; - var R21_3: bv64; - var R21_4: bv64; - var R21_5: bv64; - var R21_6: bv64; - var R22: bv64; - var R22_1: bv64; - var R22_2: bv64; - var R22_3: bv64; - var R22_4: bv64; - var R22_5: bv64; - var R22_6: bv64; - var R23: bv64; - var R23_1: bv64; - var R23_2: bv64; - var R23_3: bv64; - var R23_4: bv64; - var R23_5: bv64; - var R23_6: bv64; - var R24: bv64; - var R24_1: bv64; - var R24_2: bv64; - var R24_3: bv64; - var R24_4: bv64; - var R24_5: bv64; - var R24_6: bv64; - var R25: bv64; - var R25_1: bv64; - var R25_2: bv64; - var R25_3: bv64; - var R25_4: bv64; - var R25_5: bv64; - var R25_6: bv64; - var R26: bv64; - var R26_1: bv64; - var R26_2: bv64; - var R26_3: bv64; - var R26_4: bv64; - var R26_5: bv64; - var R26_6: bv64; - var R27: bv64; - var R27_1: bv64; - var R27_2: bv64; - var R27_3: bv64; - var R27_4: bv64; - var R27_5: bv64; - var R27_6: bv64; - var R28: bv64; - var R28_1: bv64; - var R28_2: bv64; - var R28_3: bv64; - var R28_4: bv64; - var R28_5: bv64; - var R28_6: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R29_5: bv64; - var R29_6: bv64; - var R29_7: bv64; - var R29_8: bv64; - var R29_9: bv64; - var R2_1: bv64; - var R2_2: bv64; - var R2_3: bv64; - var R2_4: bv64; - var R2_5: bv64; - var R2_6: bv64; - var R3: bv64; - var R30_11: bv64; - var R30_13: bv64; - var R30_14: bv64; - var R30_3: bv64; - var R30_5: bv64; - var R30_7: bv64; - var R30_9: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R31_5: bv64; - var R31_6: bv64; - var R31_7: bv64; - var R31_8: bv64; - var R3_1: bv64; - var R3_2: bv64; - var R3_3: bv64; - var R3_4: bv64; - var R3_5: bv64; - var R3_6: bv64; - var R4: bv64; - var R4_1: bv64; - var R4_2: bv64; - var R4_3: bv64; - var R4_4: bv64; - var R4_5: bv64; - var R4_6: bv64; - var R5: bv64; - var R5_1: bv64; - var R5_2: bv64; - var R5_3: bv64; - var R5_4: bv64; - var R5_5: bv64; - var R5_6: bv64; - var R6: bv64; - var R6_1: bv64; - var R6_2: bv64; - var R6_3: bv64; - var R6_4: bv64; - var R6_5: bv64; - var R6_6: bv64; - var R7: bv64; - var R7_1: bv64; - var R7_2: bv64; - var R7_3: bv64; - var R7_4: bv64; - var R7_5: bv64; - var R7_6: bv64; - var R8_10: bv64; - var R8_11: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R8_6: bv64; - var R8_7: bv64; - var R8_8: bv64; - var R8_9: bv64; - var R9: bv64; - var R9_1: bv64; - var R9_2: bv64; - var R9_3: bv64; - var R9_4: bv64; - var R9_5: bv64; - var R9_6: bv64; - var R9_7: bv64; - var R9_8: bv64; + var #4: bv64; + var #5: bv64; + var Gamma_#4: bool; + var Gamma_#5: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551572bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551572bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_2, Gamma_R8_2, R9_1, Gamma_R9_1 := malloc(1bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, R2, Gamma_R2, 2100bv64, true, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, 0bv64, true, R9, Gamma_R9); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + #4, Gamma_#4 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000034a"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000350"} true; + R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; + R8, Gamma_R8 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000363"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%0000036a"} true; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2100bv64, true; + call malloc(); goto l00000379; l00000379: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_3, 16bv64), R0_2), gamma_store64(Gamma_stack, bvadd64(R31_3, 16bv64), Gamma_R0_2); - call R0_4, Gamma_R0_4, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_2, Gamma_R1_2, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, R30_5, Gamma_R30_5, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_3, Gamma_R8_3, R9_2, Gamma_R9_2 := malloc(4bv64, true, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, 2112bv64, true, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_2, Gamma_R8_2, R9_1, Gamma_R9_1); + assume {:captureState "l00000379"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%0000037f"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2112bv64, true; + call malloc(); goto l0000038d; l0000038d: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_4, 8bv64), R0_4), gamma_store64(Gamma_stack, bvadd64(R31_4, 8bv64), Gamma_R0_4); - R9_3, Gamma_R9_3 := memory_load64_le(stack, bvadd64(R31_4, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 16bv64)); + assume {:captureState "l0000038d"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000393"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R8, Gamma_R8 := 65bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R9_3, 65bv8), gamma_store8(Gamma_mem, R9_3, true); - R9_4, Gamma_R9_4 := memory_load64_le(stack, bvadd64(R31_4, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 8bv64)); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000003a7"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R8, Gamma_R8 := 42bv64, true; call rely(); - assert (L(mem, R9_4) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_4, 42bv32), gamma_store32(Gamma_mem, R9_4, true); - R8_6, Gamma_R8_6 := memory_load64_le(stack, bvadd64(R31_4, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 16bv64)); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000003bb"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); call rely(); - R1_3, Gamma_R1_3 := zero_extend56_8(memory_load8_le(mem, R8_6)), (gamma_load8(Gamma_mem, R8_6) || L(mem, R8_6)); - call R0_7, Gamma_R0_7, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_4, Gamma_R1_4, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, R30_7, Gamma_R30_7, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_7, Gamma_R8_7, R9_5, Gamma_R9_5 := printf(2236bv64, true, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_3, Gamma_R1_3, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, 2160bv64, true, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_6, Gamma_R8_6, R9_4, Gamma_R9_4); + R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2236bv64), Gamma_R0; + R30, Gamma_R30 := 2160bv64, true; + call printf(); goto l000003de; l000003de: - R8_8, Gamma_R8_8 := memory_load64_le(stack, bvadd64(R31_5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 8bv64)); + assume {:captureState "l000003de"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - R1_5, Gamma_R1_5 := zero_extend32_32(memory_load32_le(mem, R8_8)), (gamma_load32(Gamma_mem, R8_8) || L(mem, R8_8)); - call R0_10, Gamma_R0_10, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_6, Gamma_R1_6, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, R30_9, Gamma_R30_9, R31_6, Gamma_R31_6, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_9, Gamma_R8_9, R9_6, Gamma_R9_6 := printf(2253bv64, true, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_5, Gamma_R1_5, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, 2180bv64, true, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_8, Gamma_R8_8, R9_5, Gamma_R9_5); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2253bv64), Gamma_R0; + R30, Gamma_R30 := 2180bv64, true; + call printf(); goto l000003fe; l000003fe: - R0_11, Gamma_R0_11 := memory_load64_le(stack, bvadd64(R31_6, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_6, 16bv64)); - call R0_12, Gamma_R0_12, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_7, Gamma_R1_7, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, R30_11, Gamma_R30_11, R31_7, Gamma_R31_7, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_10, Gamma_R8_10, R9_7, Gamma_R9_7 := #free(R0_11, Gamma_R0_11, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_6, Gamma_R1_6, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, 2188bv64, true, R31_6, Gamma_R31_6, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_9, Gamma_R8_9, R9_6, Gamma_R9_6); + assume {:captureState "l000003fe"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R30, Gamma_R30 := 2188bv64, true; + call #free(); goto l0000040d; l0000040d: - R0_13, Gamma_R0_13 := memory_load64_le(stack, bvadd64(R31_7, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_7, 8bv64)); - call R0_14, Gamma_R0_14, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_8, Gamma_R1_8, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_8, Gamma_R29_8, R2_6, Gamma_R2_6, R30_13, Gamma_R30_13, R31_8, Gamma_R31_8, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_11, Gamma_R8_11, R9_8, Gamma_R9_8 := #free(R0_13, Gamma_R0_13, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_7, Gamma_R1_7, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, 2196bv64, true, R31_7, Gamma_R31_7, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_10, Gamma_R8_10, R9_7, Gamma_R9_7); + assume {:captureState "l0000040d"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R30, Gamma_R30 := 2196bv64, true; + call #free(); goto l0000041b; l0000041b: - R0_15, Gamma_R0_15 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_8, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31_8, 4bv64)); - R29_9, Gamma_R29_9 := memory_load64_le(stack, bvadd64(R31_8, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_8, 32bv64)); - R30_14, Gamma_R30_14 := memory_load64_le(stack, bvadd64(R31_8, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_8, 40bv64)); + assume {:captureState "l0000041b"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); + #5, Gamma_#5 := bvadd64(R31, 32bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#5, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out, R8_out, R9_out := R0_15, R1_8, R29_9, R30_14, bvadd64(R31_8, 48bv64), R8_11, R9_8; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_15, Gamma_R1_8, Gamma_R29_9, Gamma_R30_14, Gamma_R31_8, Gamma_R8_11, Gamma_R9_8; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2240bv64) == 4211825664600402019bv64); @@ -717,7 +295,7 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2240bv64) == 4211825664600402019bv64); diff --git a/src/test/correct/multi_malloc/clang/multi_malloc_gtirb.expected b/src/test/correct/multi_malloc/clang/multi_malloc_gtirb.expected index 3604ae671..7481729ca 100644 --- a/src/test/correct/multi_malloc/clang/multi_malloc_gtirb.expected +++ b/src/test/correct/multi_malloc/clang/multi_malloc_gtirb.expected @@ -1,28 +1,32 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2232bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -31,22 +35,22 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { + gammaMap[index] +} + function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -60,22 +64,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2240bv64) == 4211825664600402019bv64); free ensures (memory_load64_le(mem, 2248bv64) == 7307182754559632672bv64); @@ -92,8 +97,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -106,8 +111,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69688bv64) == 0bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); free requires (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); @@ -123,6 +128,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69072bv64) == 1984bv64); free requires (memory_load64_le(mem, 69592bv64) == 2068bv64); free requires (memory_load64_le(mem, 69696bv64) == 69696bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); free ensures (memory_load64_le(mem, 2240bv64) == 4211825664600402019bv64); free ensures (memory_load64_le(mem, 2248bv64) == 7307182754559632672bv64); @@ -137,96 +146,99 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_9: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R1_2: bool; - var Gamma_R29_3: bool; - var Gamma_R30_8: bool; - var Gamma_R8_5: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var R0_9: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R1_2: bv64; - var R29_3: bv64; - var R30_8: bv64; - var R8_5: bv64; - var R9_1: bv64; - var R9_2: bv64; + var Cse0__5$3$1: bv64; + var Cse0__5$5$1: bv64; + var Gamma_Cse0__5$3$1: bool; + var Gamma_Cse0__5$5$1: bool; $main$__0__$rJrwEHH7Q82yFH8R8ikgag: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551572bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551572bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_680(R16, Gamma_R16); + assume {:captureState "$main$__0__$rJrwEHH7Q82yFH8R8ikgag"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + Cse0__5$3$1, Gamma_Cse0__5$3$1 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$3$1, R29), gamma_store64(Gamma_stack, Cse0__5$3$1, Gamma_R29); + assume {:captureState "2072$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$3$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$3$1, 8bv64), Gamma_R30); + assume {:captureState "2072$2"} true; + R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; + R8, Gamma_R8 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "2084$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "2088$0"} true; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2100bv64, true; + call FUN_680(); goto $main$__1__$tUCvozcRRoOvSNkfyBzGow; $main$__1__$tUCvozcRRoOvSNkfyBzGow: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), 1bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), true); - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := FUN_680(R16_1, Gamma_R16_1); + assume {:captureState "$main$__1__$tUCvozcRRoOvSNkfyBzGow"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "2100$0"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2112bv64, true; + call FUN_680(); goto $main$__2__$~rbIOEybSQ2ZVy7pglbk3Q; $main$__2__$~rbIOEybSQ2ZVy7pglbk3Q: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551576bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64), true); - R9_1, Gamma_R9_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); + assume {:captureState "$main$__2__$~rbIOEybSQ2ZVy7pglbk3Q"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "2112$0"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R8, Gamma_R8 := 65bv64, true; call rely(); - assert (L(mem, R9_1) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R9_1, 65bv8), gamma_store8(Gamma_mem, R9_1, true); - R9_2, Gamma_R9_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551576bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64)); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "2124$0"} true; + R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R8, Gamma_R8 := 42bv64, true; call rely(); - assert (L(mem, R9_2) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R9_2, 42bv32), gamma_store32(Gamma_mem, R9_2, true); - call R16_3, Gamma_R16_3, R17_3, Gamma_R17_3 := FUN_6c0(R16_2, Gamma_R16_2); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "2136$0"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + call rely(); + R1, Gamma_R1 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R8))), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2236bv64), Gamma_R0; + R30, Gamma_R30 := 2160bv64, true; + call FUN_6c0(); goto $main$__3__$ioncN2xEQpKeAoUViDvFEQ; $main$__3__$ioncN2xEQpKeAoUViDvFEQ: - R8_5, Gamma_R8_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551576bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64)); + assume {:captureState "$main$__3__$ioncN2xEQpKeAoUViDvFEQ"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(mem, R8_5)), (gamma_load32(Gamma_mem, R8_5) || L(mem, R8_5)); - call R16_4, Gamma_R16_4, R17_4, Gamma_R17_4 := FUN_6c0(R16_3, Gamma_R16_3); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2253bv64), Gamma_R0; + R30, Gamma_R30 := 2180bv64, true; + call FUN_6c0(); goto $main$__4__$RDsizvM6Rs2uP1PoNQRqUw; $main$__4__$RDsizvM6Rs2uP1PoNQRqUw: - call R16_5, Gamma_R16_5, R17_5, Gamma_R17_5 := FUN_6b0(R16_4, Gamma_R16_4); + assume {:captureState "$main$__4__$RDsizvM6Rs2uP1PoNQRqUw"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R30, Gamma_R30 := 2188bv64, true; + call FUN_6b0(); goto $main$__5__$XLbDejiVSoaQEuwh3~~Wuw; $main$__5__$XLbDejiVSoaQEuwh3~~Wuw: - call R16_6, Gamma_R16_6, R17_6, Gamma_R17_6 := FUN_6b0(R16_5, Gamma_R16_5); + assume {:captureState "$main$__5__$XLbDejiVSoaQEuwh3~~Wuw"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R30, Gamma_R30 := 2196bv64, true; + call FUN_6b0(); goto $main$__6__$_atEl4xoTOCpT5EUBgYVEg; $main$__6__$_atEl4xoTOCpT5EUBgYVEg: - R0_9, Gamma_R0_9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551572bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551572bv64)); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_8, Gamma_R30_8 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__6__$_atEl4xoTOCpT5EUBgYVEg"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); + Cse0__5$5$1, Gamma_Cse0__5$5$1 := bvadd64(R31, 32bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$5$1), gamma_load64(Gamma_stack, Cse0__5$5$1); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$5$1, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$5$1, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out, R8_out, R9_out := R0_9, R1_2, R29_3, R30_8, R31_in, R8_5, R9_2; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_9, Gamma_R1_2, Gamma_R29_3, Gamma_R30_8, Gamma_R31_in, Gamma_R8_5, Gamma_R9_2; + assume {:captureState "main_basil_return"} true; return; } -procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6b0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2240bv64) == 4211825664600402019bv64); free requires (memory_load64_le(mem, 2248bv64) == 7307182754559632672bv64); @@ -254,143 +266,20 @@ procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6b0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6b0$__0__$anzTk9j8RqWD4tIwhKfzRQ: + assume {:captureState "$FUN_6b0$__0__$anzTk9j8RqWD4tIwhKfzRQ"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69672bv64), (gamma_load64(Gamma_mem, 69672bv64) || L(mem, 69672bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := #free(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69672bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 40bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 40bv64)) || L(mem, bvadd64(R16, 40bv64))); + R16, Gamma_R16 := bvadd64(R16, 40bv64), Gamma_R16; + call #free(); assume false; } -procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_680(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2240bv64) == 4211825664600402019bv64); free requires (memory_load64_le(mem, 2248bv64) == 7307182754559632672bv64); @@ -418,143 +307,20 @@ procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_680() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_680$__0__$tdGxah9RStWBBxOs4YOZUA: + assume {:captureState "$FUN_680$__0__$tdGxah9RStWBBxOs4YOZUA"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69648bv64), (gamma_load64(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69648bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 16bv64)) || L(mem, bvadd64(R16, 16bv64))); + R16, Gamma_R16 := bvadd64(R16, 16bv64), Gamma_R16; + call malloc(); assume false; } -procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6c0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2240bv64) == 4211825664600402019bv64); free requires (memory_load64_le(mem, 2248bv64) == 7307182754559632672bv64); @@ -582,142 +348,19 @@ procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -implementation FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6c0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6c0$__0__$Buk7BXt9RGSvhsDcbjEctg: + assume {:captureState "$FUN_6c0$__0__$Buk7BXt9RGSvhsDcbjEctg"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69680bv64), (gamma_load64(Gamma_mem, 69680bv64) || L(mem, 69680bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69680bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 48bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 48bv64)) || L(mem, bvadd64(R16, 48bv64))); + R16, Gamma_R16 := bvadd64(R16, 48bv64), Gamma_R16; + call printf(); assume false; } -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); free requires (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2240bv64) == 4211825664600402019bv64); free requires (memory_load64_le(mem, 2248bv64) == 7307182754559632672bv64); @@ -745,7 +388,7 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); free requires (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2240bv64) == 4211825664600402019bv64); free requires (memory_load64_le(mem, 2248bv64) == 7307182754559632672bv64); @@ -773,7 +416,7 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69592bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69696bv64) == 69696bv64); -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load64_le(mem, 2232bv64) == 2334386691848142849bv64); free requires (memory_load64_le(mem, 2240bv64) == 4211825664600402019bv64); free requires (memory_load64_le(mem, 2248bv64) == 7307182754559632672bv64); diff --git a/src/test/correct/multi_malloc/gcc/multi_malloc.expected b/src/test/correct/multi_malloc/gcc/multi_malloc.expected index e9733441e..509eb4da3 100644 --- a/src/test/correct/multi_malloc/gcc/multi_malloc.expected +++ b/src/test/correct/multi_malloc/gcc/multi_malloc.expected @@ -1,32 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2224bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -40,21 +36,17 @@ function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -68,23 +60,23 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2224bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2232bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2240bv64) == 748482783423457568bv64); @@ -98,8 +90,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -112,7 +104,7 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2224bv64) == 131073bv64); free requires (memory_load64_le(mem, 2232bv64) == 8241983568019286100bv64); @@ -135,8 +127,8 @@ procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_mem, Gamma_stack, R16, R17, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2224bv64) == 131073bv64); @@ -149,6 +141,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69000bv64) == 1984bv64); free requires (memory_load64_le(mem, 69616bv64) == 2068bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2224bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2232bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2240bv64) == 748482783423457568bv64); @@ -160,523 +156,92 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_11: bool; - var Gamma_R0_12: bool; - var Gamma_R0_13: bool; - var Gamma_R0_16: bool; - var Gamma_R0_17: bool; - var Gamma_R0_18: bool; - var Gamma_R0_19: bool; - var Gamma_R0_2: bool; - var Gamma_R0_20: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R10_2: bool; - var Gamma_R10_3: bool; - var Gamma_R10_4: bool; - var Gamma_R10_5: bool; - var Gamma_R10_6: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R11_2: bool; - var Gamma_R11_3: bool; - var Gamma_R11_4: bool; - var Gamma_R11_5: bool; - var Gamma_R11_6: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R12_2: bool; - var Gamma_R12_3: bool; - var Gamma_R12_4: bool; - var Gamma_R12_5: bool; - var Gamma_R12_6: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R13_2: bool; - var Gamma_R13_3: bool; - var Gamma_R13_4: bool; - var Gamma_R13_5: bool; - var Gamma_R13_6: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R14_2: bool; - var Gamma_R14_3: bool; - var Gamma_R14_4: bool; - var Gamma_R14_5: bool; - var Gamma_R14_6: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R15_2: bool; - var Gamma_R15_3: bool; - var Gamma_R15_4: bool; - var Gamma_R15_5: bool; - var Gamma_R15_6: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R18_2: bool; - var Gamma_R18_3: bool; - var Gamma_R18_4: bool; - var Gamma_R18_5: bool; - var Gamma_R18_6: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R19_2: bool; - var Gamma_R19_3: bool; - var Gamma_R19_4: bool; - var Gamma_R19_5: bool; - var Gamma_R19_6: bool; - var Gamma_R1_1: bool; - var Gamma_R1_10: bool; - var Gamma_R1_2: bool; - var Gamma_R1_5: bool; - var Gamma_R1_6: bool; - var Gamma_R1_7: bool; - var Gamma_R1_8: bool; - var Gamma_R1_9: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R20_2: bool; - var Gamma_R20_3: bool; - var Gamma_R20_4: bool; - var Gamma_R20_5: bool; - var Gamma_R20_6: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R21_2: bool; - var Gamma_R21_3: bool; - var Gamma_R21_4: bool; - var Gamma_R21_5: bool; - var Gamma_R21_6: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R22_2: bool; - var Gamma_R22_3: bool; - var Gamma_R22_4: bool; - var Gamma_R22_5: bool; - var Gamma_R22_6: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R23_2: bool; - var Gamma_R23_3: bool; - var Gamma_R23_4: bool; - var Gamma_R23_5: bool; - var Gamma_R23_6: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R24_2: bool; - var Gamma_R24_3: bool; - var Gamma_R24_4: bool; - var Gamma_R24_5: bool; - var Gamma_R24_6: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R25_2: bool; - var Gamma_R25_3: bool; - var Gamma_R25_4: bool; - var Gamma_R25_5: bool; - var Gamma_R25_6: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R26_2: bool; - var Gamma_R26_3: bool; - var Gamma_R26_4: bool; - var Gamma_R26_5: bool; - var Gamma_R26_6: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R27_2: bool; - var Gamma_R27_3: bool; - var Gamma_R27_4: bool; - var Gamma_R27_5: bool; - var Gamma_R27_6: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R28_2: bool; - var Gamma_R28_3: bool; - var Gamma_R28_4: bool; - var Gamma_R28_5: bool; - var Gamma_R28_6: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R29_5: bool; - var Gamma_R29_6: bool; - var Gamma_R29_7: bool; - var Gamma_R29_8: bool; - var Gamma_R29_9: bool; - var Gamma_R2_1: bool; - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var Gamma_R2_4: bool; - var Gamma_R2_5: bool; - var Gamma_R2_6: bool; - var Gamma_R3: bool; - var Gamma_R30_11: bool; - var Gamma_R30_13: bool; - var Gamma_R30_14: bool; - var Gamma_R30_3: bool; - var Gamma_R30_5: bool; - var Gamma_R30_7: bool; - var Gamma_R30_9: bool; - var Gamma_R31_3: bool; - var Gamma_R31_4: bool; - var Gamma_R31_5: bool; - var Gamma_R31_6: bool; - var Gamma_R31_7: bool; - var Gamma_R31_8: bool; - var Gamma_R3_1: bool; - var Gamma_R3_2: bool; - var Gamma_R3_3: bool; - var Gamma_R3_4: bool; - var Gamma_R3_5: bool; - var Gamma_R3_6: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R4_2: bool; - var Gamma_R4_3: bool; - var Gamma_R4_4: bool; - var Gamma_R4_5: bool; - var Gamma_R4_6: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R5_2: bool; - var Gamma_R5_3: bool; - var Gamma_R5_4: bool; - var Gamma_R5_5: bool; - var Gamma_R5_6: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R6_2: bool; - var Gamma_R6_3: bool; - var Gamma_R6_4: bool; - var Gamma_R6_5: bool; - var Gamma_R6_6: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R7_2: bool; - var Gamma_R7_3: bool; - var Gamma_R7_4: bool; - var Gamma_R7_5: bool; - var Gamma_R7_6: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R8_5: bool; - var Gamma_R8_6: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var Gamma_R9_2: bool; - var Gamma_R9_3: bool; - var Gamma_R9_4: bool; - var Gamma_R9_5: bool; - var Gamma_R9_6: bool; - var R0_11: bv64; - var R0_12: bv64; - var R0_13: bv32; - var R0_16: bv64; - var R0_17: bv64; - var R0_18: bv64; - var R0_19: bv64; - var R0_2: bv64; - var R0_20: bv64; - var R0_4: bv64; - var R0_5: bv64; - var R0_6: bv64; - var R0_7: bv64; - var R0_8: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R10_2: bv64; - var R10_3: bv64; - var R10_4: bv64; - var R10_5: bv64; - var R10_6: bv64; - var R11: bv64; - var R11_1: bv64; - var R11_2: bv64; - var R11_3: bv64; - var R11_4: bv64; - var R11_5: bv64; - var R11_6: bv64; - var R12: bv64; - var R12_1: bv64; - var R12_2: bv64; - var R12_3: bv64; - var R12_4: bv64; - var R12_5: bv64; - var R12_6: bv64; - var R13: bv64; - var R13_1: bv64; - var R13_2: bv64; - var R13_3: bv64; - var R13_4: bv64; - var R13_5: bv64; - var R13_6: bv64; - var R14: bv64; - var R14_1: bv64; - var R14_2: bv64; - var R14_3: bv64; - var R14_4: bv64; - var R14_5: bv64; - var R14_6: bv64; - var R15: bv64; - var R15_1: bv64; - var R15_2: bv64; - var R15_3: bv64; - var R15_4: bv64; - var R15_5: bv64; - var R15_6: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R17: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R18: bv64; - var R18_1: bv64; - var R18_2: bv64; - var R18_3: bv64; - var R18_4: bv64; - var R18_5: bv64; - var R18_6: bv64; - var R19: bv64; - var R19_1: bv64; - var R19_2: bv64; - var R19_3: bv64; - var R19_4: bv64; - var R19_5: bv64; - var R19_6: bv64; - var R1_1: bv64; - var R1_10: bv64; - var R1_2: bv64; - var R1_5: bv64; - var R1_6: bv64; - var R1_7: bv64; - var R1_8: bv64; - var R1_9: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R20_2: bv64; - var R20_3: bv64; - var R20_4: bv64; - var R20_5: bv64; - var R20_6: bv64; - var R21: bv64; - var R21_1: bv64; - var R21_2: bv64; - var R21_3: bv64; - var R21_4: bv64; - var R21_5: bv64; - var R21_6: bv64; - var R22: bv64; - var R22_1: bv64; - var R22_2: bv64; - var R22_3: bv64; - var R22_4: bv64; - var R22_5: bv64; - var R22_6: bv64; - var R23: bv64; - var R23_1: bv64; - var R23_2: bv64; - var R23_3: bv64; - var R23_4: bv64; - var R23_5: bv64; - var R23_6: bv64; - var R24: bv64; - var R24_1: bv64; - var R24_2: bv64; - var R24_3: bv64; - var R24_4: bv64; - var R24_5: bv64; - var R24_6: bv64; - var R25: bv64; - var R25_1: bv64; - var R25_2: bv64; - var R25_3: bv64; - var R25_4: bv64; - var R25_5: bv64; - var R25_6: bv64; - var R26: bv64; - var R26_1: bv64; - var R26_2: bv64; - var R26_3: bv64; - var R26_4: bv64; - var R26_5: bv64; - var R26_6: bv64; - var R27: bv64; - var R27_1: bv64; - var R27_2: bv64; - var R27_3: bv64; - var R27_4: bv64; - var R27_5: bv64; - var R27_6: bv64; - var R28: bv64; - var R28_1: bv64; - var R28_2: bv64; - var R28_3: bv64; - var R28_4: bv64; - var R28_5: bv64; - var R28_6: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R29_5: bv64; - var R29_6: bv64; - var R29_7: bv64; - var R29_8: bv64; - var R29_9: bv64; - var R2_1: bv64; - var R2_2: bv64; - var R2_3: bv64; - var R2_4: bv64; - var R2_5: bv64; - var R2_6: bv64; - var R3: bv64; - var R30_11: bv64; - var R30_13: bv64; - var R30_14: bv64; - var R30_3: bv64; - var R30_5: bv64; - var R30_7: bv64; - var R30_9: bv64; - var R31_3: bv64; - var R31_4: bv64; - var R31_5: bv64; - var R31_6: bv64; - var R31_7: bv64; - var R31_8: bv64; - var R3_1: bv64; - var R3_2: bv64; - var R3_3: bv64; - var R3_4: bv64; - var R3_5: bv64; - var R3_6: bv64; - var R4: bv64; - var R4_1: bv64; - var R4_2: bv64; - var R4_3: bv64; - var R4_4: bv64; - var R4_5: bv64; - var R4_6: bv64; - var R5: bv64; - var R5_1: bv64; - var R5_2: bv64; - var R5_3: bv64; - var R5_4: bv64; - var R5_5: bv64; - var R5_6: bv64; - var R6: bv64; - var R6_1: bv64; - var R6_2: bv64; - var R6_3: bv64; - var R6_4: bv64; - var R6_5: bv64; - var R6_6: bv64; - var R7: bv64; - var R7_1: bv64; - var R7_2: bv64; - var R7_3: bv64; - var R7_4: bv64; - var R7_5: bv64; - var R7_6: bv64; - var R8: bv64; - var R8_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R8_4: bv64; - var R8_5: bv64; - var R8_6: bv64; - var R9: bv64; - var R9_1: bv64; - var R9_2: bv64; - var R9_3: bv64; - var R9_4: bv64; - var R9_5: bv64; - var R9_6: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(1bv64, true, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in, R2, Gamma_R2, 2084bv64, true, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000338"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000033e"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2084bv64, true; + call malloc(); goto l00000357; l00000357: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_3, 16bv64), R0_2), gamma_store64(Gamma_stack, bvadd64(R31_3, 16bv64), Gamma_R0_2); - call R0_4, Gamma_R0_4, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_2, Gamma_R1_2, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, R30_5, Gamma_R30_5, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2 := malloc(4bv64, true, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, 2096bv64, true, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1); + assume {:captureState "l00000357"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%0000035d"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2096bv64, true; + call malloc(); goto l0000036b; l0000036b: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_4, 24bv64), R0_4), gamma_store64(Gamma_stack, bvadd64(R31_4, 24bv64), Gamma_R0_4); - R0_5, Gamma_R0_5 := memory_load64_le(stack, bvadd64(R31_4, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 16bv64)); + assume {:captureState "l0000036b"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000371"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R1, Gamma_R1 := 65bv64, true; call rely(); - assert (L(mem, R0_5) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R0_5, 65bv8), gamma_store8(Gamma_mem, R0_5, true); - R0_6, Gamma_R0_6 := memory_load64_le(stack, bvadd64(R31_4, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 24bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000385"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + R1, Gamma_R1 := 42bv64, true; call rely(); - assert (L(mem, R0_6) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_6, 42bv32), gamma_store32(Gamma_mem, R0_6, true); - R0_7, Gamma_R0_7 := memory_load64_le(stack, bvadd64(R31_4, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_4, 16bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000399"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); call rely(); - R0_8, Gamma_R0_8 := zero_extend56_8(memory_load8_le(mem, R0_7)), (gamma_load8(Gamma_mem, R0_7) || L(mem, R0_7)); - R1_5, Gamma_R1_5 := zero_extend32_32(R0_8[32:0]), Gamma_R0_8; - call R0_11, Gamma_R0_11, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_6, Gamma_R1_6, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, R30_7, Gamma_R30_7, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_3, Gamma_R8_3, R9_3, Gamma_R9_3 := printf(2232bv64, true, R10_2, Gamma_R10_2, R11_2, Gamma_R11_2, R12_2, Gamma_R12_2, R13_2, Gamma_R13_2, R14_2, Gamma_R14_2, R15_2, Gamma_R15_2, R16_2, Gamma_R16_2, R17_2, Gamma_R17_2, R18_2, Gamma_R18_2, R19_2, Gamma_R19_2, R1_5, Gamma_R1_5, R20_2, Gamma_R20_2, R21_2, Gamma_R21_2, R22_2, Gamma_R22_2, R23_2, Gamma_R23_2, R24_2, Gamma_R24_2, R25_2, Gamma_R25_2, R26_2, Gamma_R26_2, R27_2, Gamma_R27_2, R28_2, Gamma_R28_2, R29_4, Gamma_R29_4, R2_2, Gamma_R2_2, 2148bv64, true, R31_4, Gamma_R31_4, R3_2, Gamma_R3_2, R4_2, Gamma_R4_2, R5_2, Gamma_R5_2, R6_2, Gamma_R6_2, R7_2, Gamma_R7_2, R8_2, Gamma_R8_2, R9_2, Gamma_R9_2); + R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2232bv64), Gamma_R0; + R30, Gamma_R30 := 2148bv64, true; + call printf(); goto l000003c2; l000003c2: - R0_12, Gamma_R0_12 := memory_load64_le(stack, bvadd64(R31_5, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31_5, 24bv64)); + assume {:captureState "l000003c2"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); - R0_13, Gamma_R0_13 := memory_load32_le(mem, R0_12), (gamma_load32(Gamma_mem, R0_12) || L(mem, R0_12)); - R1_7, Gamma_R1_7 := zero_extend32_32(R0_13), Gamma_R0_13; - call R0_16, Gamma_R0_16, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_8, Gamma_R1_8, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, R30_9, Gamma_R30_9, R31_6, Gamma_R31_6, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_4, Gamma_R8_4, R9_4, Gamma_R9_4 := printf(2256bv64, true, R10_3, Gamma_R10_3, R11_3, Gamma_R11_3, R12_3, Gamma_R12_3, R13_3, Gamma_R13_3, R14_3, Gamma_R14_3, R15_3, Gamma_R15_3, R16_3, Gamma_R16_3, R17_3, Gamma_R17_3, R18_3, Gamma_R18_3, R19_3, Gamma_R19_3, R1_7, Gamma_R1_7, R20_3, Gamma_R20_3, R21_3, Gamma_R21_3, R22_3, Gamma_R22_3, R23_3, Gamma_R23_3, R24_3, Gamma_R24_3, R25_3, Gamma_R25_3, R26_3, Gamma_R26_3, R27_3, Gamma_R27_3, R28_3, Gamma_R28_3, R29_5, Gamma_R29_5, R2_3, Gamma_R2_3, 2172bv64, true, R31_5, Gamma_R31_5, R3_3, Gamma_R3_3, R4_3, Gamma_R4_3, R5_3, Gamma_R5_3, R6_3, Gamma_R6_3, R7_3, Gamma_R7_3, R8_3, Gamma_R8_3, R9_3, Gamma_R9_3); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2256bv64), Gamma_R0; + R30, Gamma_R30 := 2172bv64, true; + call printf(); goto l000003e8; l000003e8: - R0_17, Gamma_R0_17 := memory_load64_le(stack, bvadd64(R31_6, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31_6, 16bv64)); - call R0_18, Gamma_R0_18, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_9, Gamma_R1_9, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, R30_11, Gamma_R30_11, R31_7, Gamma_R31_7, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_5, Gamma_R8_5, R9_5, Gamma_R9_5 := #free(R0_17, Gamma_R0_17, R10_4, Gamma_R10_4, R11_4, Gamma_R11_4, R12_4, Gamma_R12_4, R13_4, Gamma_R13_4, R14_4, Gamma_R14_4, R15_4, Gamma_R15_4, R16_4, Gamma_R16_4, R17_4, Gamma_R17_4, R18_4, Gamma_R18_4, R19_4, Gamma_R19_4, R1_8, Gamma_R1_8, R20_4, Gamma_R20_4, R21_4, Gamma_R21_4, R22_4, Gamma_R22_4, R23_4, Gamma_R23_4, R24_4, Gamma_R24_4, R25_4, Gamma_R25_4, R26_4, Gamma_R26_4, R27_4, Gamma_R27_4, R28_4, Gamma_R28_4, R29_6, Gamma_R29_6, R2_4, Gamma_R2_4, 2180bv64, true, R31_6, Gamma_R31_6, R3_4, Gamma_R3_4, R4_4, Gamma_R4_4, R5_4, Gamma_R5_4, R6_4, Gamma_R6_4, R7_4, Gamma_R7_4, R8_4, Gamma_R8_4, R9_4, Gamma_R9_4); + assume {:captureState "l000003e8"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R30, Gamma_R30 := 2180bv64, true; + call #free(); goto l000003f7; l000003f7: - R0_19, Gamma_R0_19 := memory_load64_le(stack, bvadd64(R31_7, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31_7, 24bv64)); - call R0_20, Gamma_R0_20, R10_6, Gamma_R10_6, R11_6, Gamma_R11_6, R12_6, Gamma_R12_6, R13_6, Gamma_R13_6, R14_6, Gamma_R14_6, R15_6, Gamma_R15_6, R16_6, Gamma_R16_6, R17_6, Gamma_R17_6, R18_6, Gamma_R18_6, R19_6, Gamma_R19_6, R1_10, Gamma_R1_10, R20_6, Gamma_R20_6, R21_6, Gamma_R21_6, R22_6, Gamma_R22_6, R23_6, Gamma_R23_6, R24_6, Gamma_R24_6, R25_6, Gamma_R25_6, R26_6, Gamma_R26_6, R27_6, Gamma_R27_6, R28_6, Gamma_R28_6, R29_8, Gamma_R29_8, R2_6, Gamma_R2_6, R30_13, Gamma_R30_13, R31_8, Gamma_R31_8, R3_6, Gamma_R3_6, R4_6, Gamma_R4_6, R5_6, Gamma_R5_6, R6_6, Gamma_R6_6, R7_6, Gamma_R7_6, R8_6, Gamma_R8_6, R9_6, Gamma_R9_6 := #free(R0_19, Gamma_R0_19, R10_5, Gamma_R10_5, R11_5, Gamma_R11_5, R12_5, Gamma_R12_5, R13_5, Gamma_R13_5, R14_5, Gamma_R14_5, R15_5, Gamma_R15_5, R16_5, Gamma_R16_5, R17_5, Gamma_R17_5, R18_5, Gamma_R18_5, R19_5, Gamma_R19_5, R1_9, Gamma_R1_9, R20_5, Gamma_R20_5, R21_5, Gamma_R21_5, R22_5, Gamma_R22_5, R23_5, Gamma_R23_5, R24_5, Gamma_R24_5, R25_5, Gamma_R25_5, R26_5, Gamma_R26_5, R27_5, Gamma_R27_5, R28_5, Gamma_R28_5, R29_7, Gamma_R29_7, R2_5, Gamma_R2_5, 2188bv64, true, R31_7, Gamma_R31_7, R3_5, Gamma_R3_5, R4_5, Gamma_R4_5, R5_5, Gamma_R5_5, R6_5, Gamma_R6_5, R7_5, Gamma_R7_5, R8_5, Gamma_R8_5, R9_5, Gamma_R9_5); + assume {:captureState "l000003f7"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + R30, Gamma_R30 := 2188bv64, true; + call #free(); goto l00000405; l00000405: - R29_9, Gamma_R29_9 := memory_load64_le(stack, R31_8), gamma_load64(Gamma_stack, R31_8); - R30_14, Gamma_R30_14 := memory_load64_le(stack, bvadd64(R31_8, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_8, 8bv64)); + assume {:captureState "l00000405"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_10, R29_9, R30_14, bvadd64(R31_8, 32bv64); - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_10, Gamma_R29_9, Gamma_R30_14, Gamma_R31_8; + assume {:captureState "main_basil_return"} true; return; } -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2224bv64) == 131073bv64); free requires (memory_load64_le(mem, 2232bv64) == 8241983568019286100bv64); @@ -699,7 +264,7 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 2224bv64) == 131073bv64); free requires (memory_load64_le(mem, 2232bv64) == 8241983568019286100bv64); diff --git a/src/test/correct/multi_malloc/gcc/multi_malloc_gtirb.expected b/src/test/correct/multi_malloc/gcc/multi_malloc_gtirb.expected index 87b910b8e..72a908f31 100644 --- a/src/test/correct/multi_malloc/gcc/multi_malloc_gtirb.expected +++ b/src/test/correct/multi_malloc/gcc/multi_malloc_gtirb.expected @@ -1,28 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2224bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -31,22 +31,22 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { + gammaMap[index] +} + function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) -} - function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } @@ -55,23 +55,28 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { + memory[index] +} + function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); free ensures (memory_load64_le(mem, 2224bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2232bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2240bv64) == 748482783423457568bv64); @@ -85,8 +90,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -99,8 +104,8 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 2224bv64) == 131073bv64); @@ -113,6 +118,10 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free requires (memory_load64_le(mem, 69000bv64) == 1984bv64); free requires (memory_load64_le(mem, 69616bv64) == 2068bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); free ensures (memory_load64_le(mem, 2224bv64) == 131073bv64); free ensures (memory_load64_le(mem, 2232bv64) == 8241983568019286100bv64); free ensures (memory_load64_le(mem, 2240bv64) == 748482783423457568bv64); @@ -124,97 +133,93 @@ procedure main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_5: bool; - var Gamma_R0_9: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R16_2: bool; - var Gamma_R16_3: bool; - var Gamma_R16_4: bool; - var Gamma_R16_5: bool; - var Gamma_R16_6: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R17_3: bool; - var Gamma_R17_4: bool; - var Gamma_R17_5: bool; - var Gamma_R17_6: bool; - var Gamma_R1_4: bool; - var Gamma_R29_3: bool; - var Gamma_R30_8: bool; - var R0_10: bv32; - var R0_3: bv64; - var R0_4: bv64; - var R0_5: bv64; - var R0_9: bv64; - var R16: bv64; - var R16_1: bv64; - var R16_2: bv64; - var R16_3: bv64; - var R16_4: bv64; - var R16_5: bv64; - var R16_6: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R17_3: bv64; - var R17_4: bv64; - var R17_5: bv64; - var R17_6: bv64; - var R1_4: bv64; - var R29_3: bv64; - var R30_8: bv64; + var Cse0__5$1$0: bv64; + var Gamma_Cse0__5$1$0: bool; $main$__0__$dwzLCyR~Qf6ppIpcnfBeyw: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R30_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_680(R16, Gamma_R16); + assume {:captureState "$main$__0__$dwzLCyR~Qf6ppIpcnfBeyw"} true; + Cse0__5$1$0, Gamma_Cse0__5$1$0 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$1$0, R29), gamma_store64(Gamma_stack, Cse0__5$1$0, Gamma_R29); + assume {:captureState "2068$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$1$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$1$0, 8bv64), Gamma_R30); + assume {:captureState "2068$2"} true; + R31, Gamma_R31 := Cse0__5$1$0, Gamma_Cse0__5$1$0; + R29, Gamma_R29 := R31, Gamma_R31; + R0, Gamma_R0 := 1bv64, true; + R30, Gamma_R30 := 2084bv64, true; + call FUN_680(); goto $main$__1__$qq0fnVWHRfSzM76qEY54cg; $main$__1__$qq0fnVWHRfSzM76qEY54cg: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), 1bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), true); - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := FUN_680(R16_1, Gamma_R16_1); + assume {:captureState "$main$__1__$qq0fnVWHRfSzM76qEY54cg"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "2084$0"} true; + R0, Gamma_R0 := 4bv64, true; + R30, Gamma_R30 := 2096bv64, true; + call FUN_680(); goto $main$__2__$OIRkzI73QCm6jl9JBTWOFw; $main$__2__$OIRkzI73QCm6jl9JBTWOFw: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 4bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R0_3, Gamma_R0_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); + assume {:captureState "$main$__2__$OIRkzI73QCm6jl9JBTWOFw"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "2096$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R1, Gamma_R1 := 65bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); - mem, Gamma_mem := memory_store8_le(mem, R0_3, 65bv8), gamma_store8(Gamma_mem, R0_3, true); - R0_4, Gamma_R0_4 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2108$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + R1, Gamma_R1 := 42bv64, true; call rely(); - assert (L(mem, R0_4) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_4, 42bv32), gamma_store32(Gamma_mem, R0_4, true); - R0_5, Gamma_R0_5 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - call R16_3, Gamma_R16_3, R17_3, Gamma_R17_3 := FUN_6c0(R16_2, Gamma_R16_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "2120$0"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + call rely(); + R0, Gamma_R0 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R0))), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2232bv64), Gamma_R0; + R30, Gamma_R30 := 2084bv64, true; + call FUN_6c0(); goto $main$__3__$DLqleMKWShKLuDEFd2d5wA; $main$__3__$DLqleMKWShKLuDEFd2d5wA: - R0_9, Gamma_R0_9 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__3__$DLqleMKWShKLuDEFd2d5wA"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); - R0_10, Gamma_R0_10 := memory_load32_le(mem, R0_9), (gamma_load32(Gamma_mem, R0_9) || L(mem, R0_9)); - R1_4, Gamma_R1_4 := zero_extend32_32(R0_10), Gamma_R0_10; - call R16_4, Gamma_R16_4, R17_4, Gamma_R17_4 := FUN_6c0(R16_3, Gamma_R16_3); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; + R0, Gamma_R0 := 0bv64, true; + R0, Gamma_R0 := bvadd64(R0, 2256bv64), Gamma_R0; + R30, Gamma_R30 := 2172bv64, true; + call FUN_6c0(); goto $main$__4__$VxlFjKprQLyiMLIhbUhZNw; $main$__4__$VxlFjKprQLyiMLIhbUhZNw: - call R16_5, Gamma_R16_5, R17_5, Gamma_R17_5 := FUN_6b0(R16_4, Gamma_R16_4); + assume {:captureState "$main$__4__$VxlFjKprQLyiMLIhbUhZNw"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); + R30, Gamma_R30 := 2180bv64, true; + call FUN_6b0(); goto $main$__5__$lPC5PztFQmelpi1yHg437g; $main$__5__$lPC5PztFQmelpi1yHg437g: - call R16_6, Gamma_R16_6, R17_6, Gamma_R17_6 := FUN_6b0(R16_5, Gamma_R16_5); + assume {:captureState "$main$__5__$lPC5PztFQmelpi1yHg437g"} true; + R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); + R30, Gamma_R30 := 2188bv64, true; + call FUN_6b0(); goto $main$__6__$mc7RYY6OQ9i3XnFy_bGwqA; $main$__6__$mc7RYY6OQ9i3XnFy_bGwqA: - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551584bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64)); - R30_8, Gamma_R30_8 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "$main$__6__$mc7RYY6OQ9i3XnFy_bGwqA"} true; + R0, Gamma_R0 := 0bv64, true; + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R29_out, R30_out, R31_out := 0bv64, R1_4, R29_3, R30_8, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := true, Gamma_R1_4, Gamma_R29_3, Gamma_R30_8, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } -procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6c0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2224bv64) == 131073bv64); free requires (memory_load64_le(mem, 2232bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2240bv64) == 748482783423457568bv64); @@ -236,143 +241,20 @@ procedure FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_6c0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6c0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6c0$__0__$krJLwhrcTQ2f7LDo~OEQzg: + assume {:captureState "$FUN_6c0$__0__$krJLwhrcTQ2f7LDo~OEQzg"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := printf(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69576bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4040bv64)) || L(mem, bvadd64(R16, 4040bv64))); + R16, Gamma_R16 := bvadd64(R16, 4040bv64), Gamma_R16; + call printf(); assume false; } -procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_680(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2224bv64) == 131073bv64); free requires (memory_load64_le(mem, 2232bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2240bv64) == 748482783423457568bv64); @@ -394,143 +276,20 @@ procedure FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_680(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_680() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_680$__0__$Wajo05XJRzmPtHyIXXM3SA: + assume {:captureState "$FUN_680$__0__$Wajo05XJRzmPtHyIXXM3SA"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69544bv64), (gamma_load64(Gamma_mem, 69544bv64) || L(mem, 69544bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := malloc(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69544bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4008bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4008bv64)) || L(mem, bvadd64(R16, 4008bv64))); + R16, Gamma_R16 := bvadd64(R16, 4008bv64), Gamma_R16; + call malloc(); assume false; } -procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; +procedure FUN_6b0(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 2224bv64) == 131073bv64); free requires (memory_load64_le(mem, 2232bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2240bv64) == 748482783423457568bv64); @@ -552,142 +311,19 @@ procedure FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamm free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_6b0(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_6b0() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_6b0$__0__$f179eReyRKeTLiqzJB4ZdQ: + assume {:captureState "$FUN_6b0$__0__$f179eReyRKeTLiqzJB4ZdQ"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := #free(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69568bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4032bv64)) || L(mem, bvadd64(R16, 4032bv64))); + R16, Gamma_R16 := bvadd64(R16, 4032bv64), Gamma_R16; + call #free(); assume false; } -procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure printf(); free requires (memory_load64_le(mem, 2224bv64) == 131073bv64); free requires (memory_load64_le(mem, 2232bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2240bv64) == 748482783423457568bv64); @@ -709,7 +345,7 @@ procedure printf(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure malloc(); free requires (memory_load64_le(mem, 2224bv64) == 131073bv64); free requires (memory_load64_le(mem, 2232bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2240bv64) == 748482783423457568bv64); @@ -731,7 +367,7 @@ procedure malloc(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: boo free ensures (memory_load64_le(mem, 69616bv64) == 2068bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure #free(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure #free(); free requires (memory_load64_le(mem, 2224bv64) == 131073bv64); free requires (memory_load64_le(mem, 2232bv64) == 8241983568019286100bv64); free requires (memory_load64_le(mem, 2240bv64) == 748482783423457568bv64); diff --git a/src/test/correct/no_interference_update_x/clang/no_interference_update_x.expected b/src/test/correct/no_interference_update_x/clang/no_interference_update_x.expected index fc87837fa..489874491 100644 --- a/src/test/correct/no_interference_update_x/clang/no_interference_update_x.expected +++ b/src/test/correct/no_interference_update_x/clang/no_interference_update_x.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -80,41 +66,39 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (memory_load32_le(mem, $x_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var y_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); y_old := memory_load32_le(mem, $y_addr); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "%000002ce"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 1bv64, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_x/clang/no_interference_update_x_gtirb.expected b/src/test/correct/no_interference_update_x/clang/no_interference_update_x_gtirb.expected index af6683c3a..cae7dacd2 100644 --- a/src/test/correct/no_interference_update_x/clang/no_interference_update_x_gtirb.expected +++ b/src/test/correct/no_interference_update_x/clang/no_interference_update_x_gtirb.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -80,41 +66,39 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (memory_load32_le(mem, $x_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var y_old: bv32; $main$__0__$QAlkNCjET2GXdH1~AtPR1g: + assume {:captureState "$main$__0__$QAlkNCjET2GXdH1~AtPR1g"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); y_old := memory_load32_le(mem, $y_addr); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "1820$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 1bv64, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x.expected b/src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x.expected index 48c5f8431..39c2b88dd 100644 --- a/src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x.expected +++ b/src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,27 +31,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -85,47 +71,43 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (memory_load32_le(mem, $x_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R9_3: bool; - var R9_3: bv64; var y_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> Gamma_R8); y_old := memory_load32_le(mem, $y_addr); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 1bv32), gamma_store32(Gamma_mem, R9_3, true); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "%000002d9"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 1bv64, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x_gtirb.expected b/src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x_gtirb.expected index cc3d6ba3f..937fa0e13 100644 --- a/src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x_gtirb.expected +++ b/src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x_gtirb.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,27 +31,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -85,47 +71,43 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (memory_load32_le(mem, $x_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R9_3: bool; - var R9_3: bv64; var y_old: bv32; $main$__0__$uD5wQok2QlKmkwPvtjvpMQ: + assume {:captureState "$main$__0__$uD5wQok2QlKmkwPvtjvpMQ"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> Gamma_R8); y_old := memory_load32_le(mem, $y_addr); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 1bv32), gamma_store32(Gamma_mem, R9_3, true); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "1888$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 1bv64, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_x/gcc/no_interference_update_x.expected b/src/test/correct/no_interference_update_x/gcc/no_interference_update_x.expected index 307aba5d9..e88a5a93e 100644 --- a/src/test/correct/no_interference_update_x/gcc/no_interference_update_x.expected +++ b/src/test/correct/no_interference_update_x/gcc/no_interference_update_x.expected @@ -1,29 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +25,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -80,41 +64,40 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $x_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { var y_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); y_old := memory_load32_le(mem, $y_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "%000002d8"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_x/gcc/no_interference_update_x_gtirb.expected b/src/test/correct/no_interference_update_x/gcc/no_interference_update_x_gtirb.expected index 8857a974d..a0f5daea6 100644 --- a/src/test/correct/no_interference_update_x/gcc/no_interference_update_x_gtirb.expected +++ b/src/test/correct/no_interference_update_x/gcc/no_interference_update_x_gtirb.expected @@ -1,29 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +25,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -80,41 +64,40 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $x_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { var y_old: bv32; $main$__0__$nl5V_SraR2KNW_76ZHI0eQ: + assume {:captureState "$main$__0__$nl5V_SraR2KNW_76ZHI0eQ"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); y_old := memory_load32_le(mem, $y_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_x/gcc_O2/no_interference_update_x.expected b/src/test/correct/no_interference_update_x/gcc_O2/no_interference_update_x.expected index 5fd1eb3ea..4979c392b 100644 --- a/src/test/correct/no_interference_update_x/gcc_O2/no_interference_update_x.expected +++ b/src/test/correct/no_interference_update_x/gcc_O2/no_interference_update_x.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -80,41 +66,39 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $x_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { var y_old: bv32; lmain: + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := 1bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); y_old := memory_load32_le(mem, $y_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "%000001bd"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_x/gcc_O2/no_interference_update_x_gtirb.expected b/src/test/correct/no_interference_update_x/gcc_O2/no_interference_update_x_gtirb.expected index aa3762b54..e53c49059 100644 --- a/src/test/correct/no_interference_update_x/gcc_O2/no_interference_update_x_gtirb.expected +++ b/src/test/correct/no_interference_update_x/gcc_O2/no_interference_update_x_gtirb.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -80,41 +66,39 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $x_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { var y_old: bv32; $main$__0__$RLJgOu_IRpaLPAvA5PJYnQ: + assume {:captureState "$main$__0__$RLJgOu_IRpaLPAvA5PJYnQ"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := 1bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); y_old := memory_load32_le(mem, $y_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "1548$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_x/gcc_pic/no_interference_update_x.expected b/src/test/correct/no_interference_update_x/gcc_pic/no_interference_update_x.expected index 66944afd1..fbd858afc 100644 --- a/src/test/correct/no_interference_update_x/gcc_pic/no_interference_update_x.expected +++ b/src/test/correct/no_interference_update_x/gcc_pic/no_interference_update_x.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,27 +29,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -85,47 +69,43 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $x_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var R0_3: bv64; var y_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> Gamma_R1); y_old := memory_load32_le(mem, $y_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "%000002d9"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_x/gcc_pic/no_interference_update_x_gtirb.expected b/src/test/correct/no_interference_update_x/gcc_pic/no_interference_update_x_gtirb.expected index 75af6762f..49ac0244c 100644 --- a/src/test/correct/no_interference_update_x/gcc_pic/no_interference_update_x_gtirb.expected +++ b/src/test/correct/no_interference_update_x/gcc_pic/no_interference_update_x_gtirb.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,27 +29,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -85,47 +69,43 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $x_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var R0_3: bv64; var y_old: bv32; $main$__0__$jTPw4UUhRdSFa8LhwZUbcQ: + assume {:captureState "$main$__0__$jTPw4UUhRdSFa8LhwZUbcQ"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> Gamma_R1); y_old := memory_load32_le(mem, $y_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "1888$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_y/clang/no_interference_update_y.expected b/src/test/correct/no_interference_update_y/clang/no_interference_update_y.expected index 63a781cee..c730fada4 100644 --- a/src/test/correct/no_interference_update_y/clang/no_interference_update_y.expected +++ b/src/test/correct/no_interference_update_y/clang/no_interference_update_y.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -80,41 +66,39 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (memory_load32_le(mem, $y_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "%000002ce"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 1bv64, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_y/clang/no_interference_update_y_gtirb.expected b/src/test/correct/no_interference_update_y/clang/no_interference_update_y_gtirb.expected index 4360454f5..8bf937d63 100644 --- a/src/test/correct/no_interference_update_y/clang/no_interference_update_y_gtirb.expected +++ b/src/test/correct/no_interference_update_y/clang/no_interference_update_y_gtirb.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -80,41 +66,39 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (memory_load32_le(mem, $y_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var x_old: bv32; $main$__0__$g7pcuBFbQH~Jw8saI~uAQA: + assume {:captureState "$main$__0__$g7pcuBFbQH~Jw8saI~uAQA"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "1820$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 1bv64, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y.expected b/src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y.expected index 4db59f759..01bd7a9e8 100644 --- a/src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y.expected +++ b/src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,27 +31,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -85,47 +71,43 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (memory_load32_le(mem, $y_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R9_3: bool; - var R9_3: bv64; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4048bv64)) || L(mem, bvadd64(R9, 4048bv64))); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 1bv32), gamma_store32(Gamma_mem, R9_3, true); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "%000002d9"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 1bv64, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y_gtirb.expected b/src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y_gtirb.expected index e22b786c3..9d3394cc3 100644 --- a/src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y_gtirb.expected +++ b/src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y_gtirb.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,27 +31,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -85,47 +71,43 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); ensures (memory_load32_le(mem, $y_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R9_3: bool; - var R9_3: bv64; var x_old: bv32; $main$__0__$G8iEx~cVQd2oIfccjCjY1g: + assume {:captureState "$main$__0__$G8iEx~cVQd2oIfccjCjY1g"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4048bv64)) || L(mem, bvadd64(R9, 4048bv64))); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 1bv32), gamma_store32(Gamma_mem, R9_3, true); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "1888$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 1bv64, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_y/gcc/no_interference_update_y.expected b/src/test/correct/no_interference_update_y/gcc/no_interference_update_y.expected index cb973389d..707922203 100644 --- a/src/test/correct/no_interference_update_y/gcc/no_interference_update_y.expected +++ b/src/test/correct/no_interference_update_y/gcc/no_interference_update_y.expected @@ -1,29 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +25,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -80,41 +64,40 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $y_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 1bv32), gamma_store32(Gamma_mem, 69656bv64, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "%000002d8"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_y/gcc/no_interference_update_y_gtirb.expected b/src/test/correct/no_interference_update_y/gcc/no_interference_update_y_gtirb.expected index 456c32ced..046da73bd 100644 --- a/src/test/correct/no_interference_update_y/gcc/no_interference_update_y_gtirb.expected +++ b/src/test/correct/no_interference_update_y/gcc/no_interference_update_y_gtirb.expected @@ -1,29 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +25,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -80,41 +64,40 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $y_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { var x_old: bv32; $main$__0__$Wy8teY__S~m6dNMhY03xKA: + assume {:captureState "$main$__0__$Wy8teY__S~m6dNMhY03xKA"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 1bv32), gamma_store32(Gamma_mem, 69656bv64, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_y/gcc_O2/no_interference_update_y.expected b/src/test/correct/no_interference_update_y/gcc_O2/no_interference_update_y.expected index f9caa736d..2985f6029 100644 --- a/src/test/correct/no_interference_update_y/gcc_O2/no_interference_update_y.expected +++ b/src/test/correct/no_interference_update_y/gcc_O2/no_interference_update_y.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -80,41 +66,39 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $y_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := 1bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "%000001bd"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_y/gcc_O2/no_interference_update_y_gtirb.expected b/src/test/correct/no_interference_update_y/gcc_O2/no_interference_update_y_gtirb.expected index aab841220..1b0e1ce61 100644 --- a/src/test/correct/no_interference_update_y/gcc_O2/no_interference_update_y_gtirb.expected +++ b/src/test/correct/no_interference_update_y/gcc_O2/no_interference_update_y_gtirb.expected @@ -1,29 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +27,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -80,41 +66,39 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $y_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { var x_old: bv32; $main$__0__$jEeH_W1PQjO_BGqBl3CzIA: + assume {:captureState "$main$__0__$jEeH_W1PQjO_BGqBl3CzIA"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := 1bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "1548$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_y/gcc_pic/no_interference_update_y.expected b/src/test/correct/no_interference_update_y/gcc_pic/no_interference_update_y.expected index 54cf16376..72fb704a7 100644 --- a/src/test/correct/no_interference_update_y/gcc_pic/no_interference_update_y.expected +++ b/src/test/correct/no_interference_update_y/gcc_pic/no_interference_update_y.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,27 +29,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -85,47 +69,43 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $y_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var R0_3: bv64; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "%000002d9"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/no_interference_update_y/gcc_pic/no_interference_update_y_gtirb.expected b/src/test/correct/no_interference_update_y/gcc_pic/no_interference_update_y_gtirb.expected index 1755a22ad..2dc3bd3bb 100644 --- a/src/test/correct/no_interference_update_y/gcc_pic/no_interference_update_y_gtirb.expected +++ b/src/test/correct/no_interference_update_y/gcc_pic/no_interference_update_y_gtirb.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,27 +29,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -85,47 +69,43 @@ implementation {:extern} guarantee_reflexive() assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); ensures (memory_load32_le(mem, $y_addr) == 1bv32); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var R0_3: bv64; var x_old: bv32; $main$__0__$5FgihppzTHuH09MtdD5bbg: + assume {:captureState "$main$__0__$5FgihppzTHuH09MtdD5bbg"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> Gamma_R1); x_old := memory_load32_le(mem, $x_addr); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "1888$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/secret_write/clang/secret_write.expected b/src/test/correct/secret_write/clang/secret_write.expected index 0752422e5..ff731a250 100644 --- a/src/test/correct/secret_write/clang/secret_write.expected +++ b/src/test/correct/secret_write/clang/secret_write.expected @@ -1,4 +1,12 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); @@ -6,33 +14,20 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(mem$in, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -43,12 +38,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,10 +48,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -93,93 +81,86 @@ implementation {:extern} guarantee_reflexive() assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); } -procedure main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R8, R9, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $z_addr) == true); requires (gamma_load32(Gamma_mem, $secret_addr) == false); requires (memory_load32_le(mem, $z_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1892bv64) == 1bv8); - free requires (memory_load8_le(mem, 1893bv64) == 0bv8); - free requires (memory_load8_le(mem, 1894bv64) == 2bv8); - free requires (memory_load8_le(mem, 1895bv64) == 0bv8); + free requires (memory_load32_le(mem, 1892bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_2: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_6: bool; - var Gamma_R8_7: bool; var Gamma_x_old: bool; - var R10_2: bv64; - var R8_2: bv32; - var R8_3: bv32; - var R8_6: bv32; - var R8_7: bv64; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 0bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), true); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000002f5"} true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - R8_3, Gamma_R8_3 := bvadd32(R8_2, 1bv32), Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R8_3); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, R8_3), gamma_store32(Gamma_mem, 69684bv64, Gamma_R8_3); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000030a"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R10_2, Gamma_R10_2 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69692bv64) ==> Gamma_R10_2); + assert (L(mem, bvadd64(R8, 60bv64)) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, R10_2[32:0]), gamma_store32(Gamma_mem, 69692bv64, Gamma_R10_2); - assert ((69692bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), Gamma_R10); + assert ((bvadd64(R8, 60bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000323"} true; call rely(); - assert (L(mem, 69692bv64) ==> true); + assert (L(mem, bvadd64(R8, 60bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, 0bv32), gamma_store32(Gamma_mem, 69692bv64, true); - assert ((69692bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), true); + assert ((bvadd64(R8, 60bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000032a"} true; call rely(); - R8_6, Gamma_R8_6 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - R8_7, Gamma_R8_7 := zero_extend32_32(bvadd32(R8_6, 1bv32)), Gamma_R8_6; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R8_7); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, R8_7[32:0]), gamma_store32(Gamma_mem, 69684bv64, Gamma_R8_7); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000033f"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R8_out, R9_out := 0bv64, R10_2, R8_7, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_2, Gamma_R8_7, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/secret_write/clang/secret_write_gtirb.expected b/src/test/correct/secret_write/clang/secret_write_gtirb.expected index 5b5193970..e9d02dcdd 100644 --- a/src/test/correct/secret_write/clang/secret_write_gtirb.expected +++ b/src/test/correct/secret_write/clang/secret_write_gtirb.expected @@ -1,4 +1,12 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); @@ -6,33 +14,20 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(mem$in, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -43,12 +38,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,10 +48,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -93,93 +81,86 @@ implementation {:extern} guarantee_reflexive() assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); } -procedure main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R8, R9, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $z_addr) == true); requires (gamma_load32(Gamma_mem, $secret_addr) == false); requires (memory_load32_le(mem, $z_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1892bv64) == 1bv8); - free requires (memory_load8_le(mem, 1893bv64) == 0bv8); - free requires (memory_load8_le(mem, 1894bv64) == 2bv8); - free requires (memory_load8_le(mem, 1895bv64) == 0bv8); + free requires (memory_load32_le(mem, 1892bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_2: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_6: bool; - var Gamma_R8_7: bool; var Gamma_x_old: bool; - var R10_2: bv64; - var R8_2: bv32; - var R8_3: bv32; - var R8_6: bv32; - var R8_7: bv64; var z_old: bv32; $main$__0__$xS~orUUNTR22OV8RB7tSjw: + assume {:captureState "$main$__0__$xS~orUUNTR22OV8RB7tSjw"} true; + R9, Gamma_R9 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 0bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), true); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1820$0"} true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - R8_3, Gamma_R8_3 := bvadd32(R8_2, 1bv32), Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R8_3); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, R8_3), gamma_store32(Gamma_mem, 69684bv64, Gamma_R8_3); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1832$0"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R10_2, Gamma_R10_2 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69692bv64) ==> Gamma_R10_2); + assert (L(mem, bvadd64(R8, 60bv64)) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, R10_2[32:0]), gamma_store32(Gamma_mem, 69692bv64, Gamma_R10_2); - assert ((69692bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), Gamma_R10); + assert ((bvadd64(R8, 60bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1848$0"} true; call rely(); - assert (L(mem, 69692bv64) ==> true); + assert (L(mem, bvadd64(R8, 60bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, 0bv32), gamma_store32(Gamma_mem, 69692bv64, true); - assert ((69692bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), true); + assert ((bvadd64(R8, 60bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1852$0"} true; call rely(); - R8_6, Gamma_R8_6 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - R8_7, Gamma_R8_7 := zero_extend32_32(bvadd32(R8_6, 1bv32)), Gamma_R8_6; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R8_7); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, R8_7[32:0]), gamma_store32(Gamma_mem, 69684bv64, Gamma_R8_7); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1864$0"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R8_out, R9_out := 0bv64, R10_2, R8_7, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_2, Gamma_R8_7, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/secret_write/clang_O2/secret_write.expected b/src/test/correct/secret_write/clang_O2/secret_write.expected index 3ca9f26ea..48a428eaa 100644 --- a/src/test/correct/secret_write/clang_O2/secret_write.expected +++ b/src/test/correct/secret_write/clang_O2/secret_write.expected @@ -1,4 +1,12 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); @@ -6,32 +14,19 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(mem$in, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); @@ -55,10 +46,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -91,54 +79,54 @@ implementation {:extern} guarantee_reflexive() assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); } -procedure main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R8, R9, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $z_addr) == true); requires (gamma_load32(Gamma_mem, $secret_addr) == false); requires (memory_load32_le(mem, $z_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 0bv64, true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R10, Gamma_R10 := 2bv64, true; call rely(); - assert (L(mem, 69692bv64) ==> true); + assert (L(mem, bvadd64(R8, 60bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, 0bv32), gamma_store32(Gamma_mem, 69692bv64, true); - assert ((69692bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), true); + assert ((bvadd64(R8, 60bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000002df"} true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 2bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R10); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000002e7"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R8_out, R9_out := 0bv64, 2bv64, 69632bv64, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R8_out, Gamma_R9_out := true, true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/secret_write/clang_O2/secret_write_gtirb.expected b/src/test/correct/secret_write/clang_O2/secret_write_gtirb.expected index ccd821416..289dadb93 100644 --- a/src/test/correct/secret_write/clang_O2/secret_write_gtirb.expected +++ b/src/test/correct/secret_write/clang_O2/secret_write_gtirb.expected @@ -1,4 +1,12 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); @@ -6,32 +14,19 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(mem$in, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); @@ -55,10 +46,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -91,54 +79,54 @@ implementation {:extern} guarantee_reflexive() assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); } -procedure main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R8, R9, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $z_addr) == true); requires (gamma_load32(Gamma_mem, $secret_addr) == false); requires (memory_load32_le(mem, $z_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1860bv64) == 1bv8); - free requires (memory_load8_le(mem, 1861bv64) == 0bv8); - free requires (memory_load8_le(mem, 1862bv64) == 2bv8); - free requires (memory_load8_le(mem, 1863bv64) == 0bv8); + free requires (memory_load32_le(mem, 1860bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1860bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1861bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1862bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1863bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1860bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var Gamma_x_old: bool; var z_old: bv32; $main$__0__$aSiaHsE5TDyirZoC~C78XA: + assume {:captureState "$main$__0__$aSiaHsE5TDyirZoC~C78XA"} true; + R0, Gamma_R0 := 0bv64, true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R10, Gamma_R10 := 2bv64, true; call rely(); - assert (L(mem, 69692bv64) ==> true); + assert (L(mem, bvadd64(R8, 60bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, 0bv32), gamma_store32(Gamma_mem, 69692bv64, true); - assert ((69692bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), true); + assert ((bvadd64(R8, 60bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1828$0"} true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 2bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R10); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1832$0"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R8_out, R9_out := 0bv64, 2bv64, 69632bv64, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R8_out, Gamma_R9_out := true, true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/secret_write/clang_pic/secret_write.expected b/src/test/correct/secret_write/clang_pic/secret_write.expected index d659c8c19..c6a6d5878 100644 --- a/src/test/correct/secret_write/clang_pic/secret_write.expected +++ b/src/test/correct/secret_write/clang_pic/secret_write.expected @@ -1,4 +1,12 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); @@ -6,23 +14,14 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(mem$in, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -32,11 +31,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -47,12 +42,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -61,17 +52,14 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69040bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69560bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69692bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69560bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -100,111 +88,98 @@ implementation {:extern} guarantee_reflexive() assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); } -procedure main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R8, R9, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $z_addr) == true); requires (gamma_load32(Gamma_mem, $secret_addr) == false); requires (memory_load32_le(mem, $z_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1968bv64) == 1bv8); - free requires (memory_load8_le(mem, 1969bv64) == 0bv8); - free requires (memory_load8_le(mem, 1970bv64) == 2bv8); - free requires (memory_load8_le(mem, 1971bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); - free requires (memory_load64_le(mem, 69048bv64) == 1792bv64); + free requires (memory_load32_le(mem, 1968bv64) == 131073bv32); free requires (memory_load64_le(mem, 69040bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69048bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69560bv64) == 69684bv64); free requires (memory_load64_le(mem, 69568bv64) == 69692bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69560bv64) == 69684bv64); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69040bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69560bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69692bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69560bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_2: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_5: bool; - var Gamma_R8_7: bool; - var Gamma_R8_8: bool; - var Gamma_R8_9: bool; - var Gamma_R9_3: bool; var Gamma_x_old: bool; - var R10_2: bv64; - var R8_2: bv32; - var R8_3: bv32; - var R8_5: bv64; - var R8_7: bv64; - var R8_8: bv32; - var R8_9: bv64; - var R9_3: bv64; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69560bv64), (gamma_load64(Gamma_mem, 69560bv64) || L(mem, 69560bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4024bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4024bv64)) || L(mem, bvadd64(R9, 4024bv64))); + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 0bv32), gamma_store32(Gamma_mem, R9_3, true); - assert ((R9_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, 0bv32), gamma_store32(Gamma_mem, R9, true); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000308"} true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, R9_3), (gamma_load32(Gamma_mem, R9_3) || L(mem, R9_3)); - R8_3, Gamma_R8_3 := bvadd32(R8_2, 1bv32), Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_3); + assert (L(mem, R9) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R8_3), gamma_store32(Gamma_mem, R9_3, Gamma_R8_3); - assert ((R9_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000031d"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_5, Gamma_R8_5 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - R10_2, Gamma_R10_2 := zero_extend32_32(memory_load32_le(mem, R8_5)), (gamma_load32(Gamma_mem, R8_5) || L(mem, R8_5)); + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_7, Gamma_R8_7 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - assert (L(mem, R8_7) ==> Gamma_R10_2); + assert (L(mem, R8) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_7, R10_2[32:0]), gamma_store32(Gamma_mem, R8_7, Gamma_R10_2); - assert ((R8_7 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, R10[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R10); + assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000344"} true; call rely(); - assert (L(mem, R8_7) ==> true); + assert (L(mem, R8) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_7, 0bv32), gamma_store32(Gamma_mem, R8_7, true); - assert ((R8_7 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); + assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000034b"} true; call rely(); - R8_8, Gamma_R8_8 := memory_load32_le(mem, R9_3), (gamma_load32(Gamma_mem, R9_3) || L(mem, R9_3)); - R8_9, Gamma_R8_9 := zero_extend32_32(bvadd32(R8_8, 1bv32)), Gamma_R8_8; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_9); + assert (L(mem, R9) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R8_9[32:0]), gamma_store32(Gamma_mem, R9_3, Gamma_R8_9); - assert ((R9_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000360"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R8_out, R9_out := 0bv64, R10_2, R8_9, R9_3; - Gamma_R0_out, Gamma_R10_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_2, Gamma_R8_9, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/secret_write/clang_pic/secret_write_gtirb.expected b/src/test/correct/secret_write/clang_pic/secret_write_gtirb.expected index 85f3c78bd..5d1c612d0 100644 --- a/src/test/correct/secret_write/clang_pic/secret_write_gtirb.expected +++ b/src/test/correct/secret_write/clang_pic/secret_write_gtirb.expected @@ -1,4 +1,12 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); @@ -6,23 +14,14 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(mem$in, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -32,11 +31,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -47,12 +42,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -61,17 +52,14 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69040bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69560bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69692bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69560bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -100,111 +88,98 @@ implementation {:extern} guarantee_reflexive() assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); } -procedure main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R8, R9, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $z_addr) == true); requires (gamma_load32(Gamma_mem, $secret_addr) == false); requires (memory_load32_le(mem, $z_addr) == 0bv32); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1968bv64) == 1bv8); - free requires (memory_load8_le(mem, 1969bv64) == 0bv8); - free requires (memory_load8_le(mem, 1970bv64) == 2bv8); - free requires (memory_load8_le(mem, 1971bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); - free requires (memory_load64_le(mem, 69048bv64) == 1792bv64); + free requires (memory_load32_le(mem, 1968bv64) == 131073bv32); free requires (memory_load64_le(mem, 69040bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69048bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69560bv64) == 69684bv64); free requires (memory_load64_le(mem, 69568bv64) == 69692bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69560bv64) == 69684bv64); - free ensures (memory_load8_le(mem, 1968bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1969bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1970bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1971bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); - free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1968bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69040bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69560bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69692bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69560bv64) == 69684bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_2: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_5: bool; - var Gamma_R8_7: bool; - var Gamma_R8_8: bool; - var Gamma_R8_9: bool; - var Gamma_R9_3: bool; var Gamma_x_old: bool; - var R10_2: bv64; - var R8_2: bv32; - var R8_3: bv32; - var R8_5: bv64; - var R8_7: bv64; - var R8_8: bv32; - var R8_9: bv64; - var R9_3: bv64; var z_old: bv32; $main$__0__$OCJPxV7kTAqIa7P9NrZAQg: + assume {:captureState "$main$__0__$OCJPxV7kTAqIa7P9NrZAQg"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69560bv64), (gamma_load64(Gamma_mem, 69560bv64) || L(mem, 69560bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4024bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4024bv64)) || L(mem, bvadd64(R9, 4024bv64))); + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 0bv32), gamma_store32(Gamma_mem, R9_3, true); - assert ((R9_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, 0bv32), gamma_store32(Gamma_mem, R9, true); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1888$0"} true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, R9_3), (gamma_load32(Gamma_mem, R9_3) || L(mem, R9_3)); - R8_3, Gamma_R8_3 := bvadd32(R8_2, 1bv32), Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_3); + assert (L(mem, R9) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R8_3), gamma_store32(Gamma_mem, R9_3, Gamma_R8_3); - assert ((R9_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1900$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_5, Gamma_R8_5 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - R10_2, Gamma_R10_2 := zero_extend32_32(memory_load32_le(mem, R8_5)), (gamma_load32(Gamma_mem, R8_5) || L(mem, R8_5)); + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_7, Gamma_R8_7 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - assert (L(mem, R8_7) ==> Gamma_R10_2); + assert (L(mem, R8) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_7, R10_2[32:0]), gamma_store32(Gamma_mem, R8_7, Gamma_R10_2); - assert ((R8_7 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, R10[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R10); + assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1924$0"} true; call rely(); - assert (L(mem, R8_7) ==> true); + assert (L(mem, R8) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R8_7, 0bv32), gamma_store32(Gamma_mem, R8_7, true); - assert ((R8_7 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); + assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1928$0"} true; call rely(); - R8_8, Gamma_R8_8 := memory_load32_le(mem, R9_3), (gamma_load32(Gamma_mem, R9_3) || L(mem, R9_3)); - R8_9, Gamma_R8_9 := zero_extend32_32(bvadd32(R8_8, 1bv32)), Gamma_R8_8; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); + R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_9); + assert (L(mem, R9) ==> Gamma_R8); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R8_9[32:0]), gamma_store32(Gamma_mem, R9_3, Gamma_R8_9); - assert ((R9_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1940$0"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R8_out, R9_out := 0bv64, R10_2, R8_9, R9_3; - Gamma_R0_out, Gamma_R10_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_2, Gamma_R8_9, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/secret_write/gcc/secret_write.expected b/src/test/correct/secret_write/gcc/secret_write.expected index 7fbb182dd..af58dd477 100644 --- a/src/test/correct/secret_write/gcc/secret_write.expected +++ b/src/test/correct/secret_write/gcc/secret_write.expected @@ -1,4 +1,8 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); @@ -6,33 +10,20 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(mem$in, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -43,12 +34,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,10 +44,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1944bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1945bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1946bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1947bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1944bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -93,93 +77,99 @@ implementation {:extern} guarantee_reflexive() assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $z_addr) == true); requires (gamma_load32(Gamma_mem, $secret_addr) == false); requires (memory_load32_le(mem, $z_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1944bv64) == 1bv8); - free requires (memory_load8_le(mem, 1945bv64) == 0bv8); - free requires (memory_load8_le(mem, 1946bv64) == 2bv8); - free requires (memory_load8_le(mem, 1947bv64) == 0bv8); + free requires (memory_load32_le(mem, 1944bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1944bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1945bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1946bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1947bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1944bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_17: bool; - var Gamma_R0_6: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; var Gamma_x_old: bool; - var R0_17: bv32; - var R0_6: bv32; - var R1_2: bv32; - var R1_3: bv32; - var R1_4: bv64; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 0bv32), gamma_store32(Gamma_mem, 69652bv64, true); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000032a"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - R1_2, Gamma_R1_2 := bvadd32(R0_6, 1bv32), Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_2), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_2); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000355"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 28bv64), Gamma_R0; call rely(); - R1_3, Gamma_R1_3 := memory_load32_le(mem, 69660bv64), (gamma_load32(Gamma_mem, 69660bv64) || L(mem, 69660bv64)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R1_3); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, R1_3), gamma_store32(Gamma_mem, 69656bv64, Gamma_R1_3); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000037a"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 0bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000038c"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_17, Gamma_R0_17 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - R1_4, Gamma_R1_4 := zero_extend32_32(bvadd32(R0_17, 1bv32)), Gamma_R0_17; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_4); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_4[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_4); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000003b7"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_4; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_4; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/secret_write/gcc/secret_write_gtirb.expected b/src/test/correct/secret_write/gcc/secret_write_gtirb.expected index f88123e1d..29dca0c16 100644 --- a/src/test/correct/secret_write/gcc/secret_write_gtirb.expected +++ b/src/test/correct/secret_write/gcc/secret_write_gtirb.expected @@ -1,4 +1,8 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); @@ -6,33 +10,20 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(mem$in, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -43,12 +34,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,10 +44,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1944bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1945bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1946bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1947bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1944bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -93,93 +77,99 @@ implementation {:extern} guarantee_reflexive() assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $z_addr) == true); requires (gamma_load32(Gamma_mem, $secret_addr) == false); requires (memory_load32_le(mem, $z_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1944bv64) == 1bv8); - free requires (memory_load8_le(mem, 1945bv64) == 0bv8); - free requires (memory_load8_le(mem, 1946bv64) == 2bv8); - free requires (memory_load8_le(mem, 1947bv64) == 0bv8); + free requires (memory_load32_le(mem, 1944bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1944bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1945bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1946bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1947bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1944bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_17: bool; - var Gamma_R0_6: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; var Gamma_x_old: bool; - var R0_17: bv32; - var R0_6: bv32; - var R1_2: bv32; - var R1_3: bv32; - var R1_4: bv64; var z_old: bv32; $main$__0__$KpvN4unOQSe6fvbZnP4O3Q: + assume {:captureState "$main$__0__$KpvN4unOQSe6fvbZnP4O3Q"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 0bv32), gamma_store32(Gamma_mem, 69652bv64, true); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1820$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - R1_2, Gamma_R1_2 := bvadd32(R0_6, 1bv32), Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_2), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_2); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1848$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 28bv64), Gamma_R0; call rely(); - R1_3, Gamma_R1_3 := memory_load32_le(mem, 69660bv64), (gamma_load32(Gamma_mem, 69660bv64) || L(mem, 69660bv64)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R1_3); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, R1_3), gamma_store32(Gamma_mem, 69656bv64, Gamma_R1_3); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1872$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 0bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1884$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_17, Gamma_R0_17 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - R1_4, Gamma_R1_4 := zero_extend32_32(bvadd32(R0_17, 1bv32)), Gamma_R0_17; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_4); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_4[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_4); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1912$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_4; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_4; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/secret_write/gcc_O2/secret_write.expected b/src/test/correct/secret_write/gcc_O2/secret_write.expected index 92feb36ea..543cf34f9 100644 --- a/src/test/correct/secret_write/gcc_O2/secret_write.expected +++ b/src/test/correct/secret_write/gcc_O2/secret_write.expected @@ -1,4 +1,12 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); @@ -6,32 +14,19 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(mem$in, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); @@ -55,10 +46,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -91,54 +79,54 @@ implementation {:extern} guarantee_reflexive() assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_R3, Gamma_mem, R0, R1, R2, R3, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $z_addr) == true); requires (gamma_load32(Gamma_mem, $secret_addr) == false); requires (memory_load32_le(mem, $z_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool) +implementation main() { var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R3, Gamma_R3 := 2bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 0bv32), gamma_store32(Gamma_mem, 69652bv64, true); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), true); + assert ((bvadd64(R1, 20bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000001c2"} true; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, bvadd64(R2, 4bv64)) ==> Gamma_R3); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 2bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 4bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R2, 4bv64), Gamma_R3); + assert ((bvadd64(R2, 4bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000001ca"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out, R3_out := 0bv64, 69632bv64, 69652bv64, 2bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out, Gamma_R3_out := true, true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/secret_write/gcc_O2/secret_write_gtirb.expected b/src/test/correct/secret_write/gcc_O2/secret_write_gtirb.expected index 9fbb05f3f..84db56744 100644 --- a/src/test/correct/secret_write/gcc_O2/secret_write_gtirb.expected +++ b/src/test/correct/secret_write/gcc_O2/secret_write_gtirb.expected @@ -1,4 +1,12 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); @@ -6,32 +14,19 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(mem$in, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); @@ -55,10 +46,7 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -91,54 +79,54 @@ implementation {:extern} guarantee_reflexive() assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_R3, Gamma_mem, R0, R1, R2, R3, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $z_addr) == true); requires (gamma_load32(Gamma_mem, $secret_addr) == false); requires (memory_load32_le(mem, $z_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool, R3_in: bv64, Gamma_R3_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool, R3_out: bv64, Gamma_R3_out: bool) +implementation main() { var Gamma_x_old: bool; var z_old: bv32; $main$__0__$1CqTVg9ZT1uFZwqE_OAzfA: + assume {:captureState "$main$__0__$1CqTVg9ZT1uFZwqE_OAzfA"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R3, Gamma_R3 := 2bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 0bv32), gamma_store32(Gamma_mem, 69652bv64, true); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), true); + assert ((bvadd64(R1, 20bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1552$0"} true; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, bvadd64(R2, 4bv64)) ==> Gamma_R3); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 2bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 4bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R2, 4bv64), Gamma_R3); + assert ((bvadd64(R2, 4bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1556$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out, R3_out := 0bv64, 69632bv64, 69652bv64, 2bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out, Gamma_R3_out := true, true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/secret_write/gcc_pic/secret_write.expected b/src/test/correct/secret_write/gcc_pic/secret_write.expected index de569d993..1b1aa27ca 100644 --- a/src/test/correct/secret_write/gcc_pic/secret_write.expected +++ b/src/test/correct/secret_write/gcc_pic/secret_write.expected @@ -1,4 +1,8 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); @@ -6,23 +10,14 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(mem$in, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -32,11 +27,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -47,12 +38,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -61,17 +48,14 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 2008bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2009bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2010bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2011bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 2008bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69652bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -100,131 +84,113 @@ implementation {:extern} guarantee_reflexive() assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $z_addr) == true); requires (gamma_load32(Gamma_mem, $secret_addr) == false); requires (memory_load32_le(mem, $z_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 2008bv64) == 1bv8); - free requires (memory_load8_le(mem, 2009bv64) == 0bv8); - free requires (memory_load8_le(mem, 2010bv64) == 2bv8); - free requires (memory_load8_le(mem, 2011bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69660bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 2008bv64) == 131073bv32); + free requires (memory_load64_le(mem, 68992bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69000bv64) == 1792bv64); free requires (memory_load64_le(mem, 69584bv64) == 69652bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1792bv64); - free requires (memory_load64_le(mem, 68992bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 2008bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2009bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2010bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2011bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69660bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 2008bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69652bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_12: bool; - var Gamma_R0_14: bool; - var Gamma_R0_16: bool; - var Gamma_R0_17: bool; - var Gamma_R0_19: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_8: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; var Gamma_x_old: bool; - var R0_10: bv64; - var R0_12: bv64; - var R0_14: bv64; - var R0_16: bv64; - var R0_17: bv32; - var R0_19: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_6: bv32; - var R0_8: bv64; - var R1_2: bv32; - var R1_3: bv32; - var R1_4: bv64; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 0bv32), gamma_store32(Gamma_mem, R0_3, true); - assert ((R0_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000032b"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, R0_5), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); - R1_2, Gamma_R1_2 := bvadd32(R0_6, 1bv32), Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_8, Gamma_R0_8 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - assert (L(mem, R0_8) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_8, R1_2), gamma_store32(Gamma_mem, R0_8, Gamma_R1_2); - assert ((R0_8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000358"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_10, Gamma_R0_10 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R1_3, Gamma_R1_3 := memory_load32_le(mem, R0_10), (gamma_load32(Gamma_mem, R0_10) || L(mem, R0_10)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_12, Gamma_R0_12 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_12) ==> Gamma_R1_3); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_12, R1_3), gamma_store32(Gamma_mem, R0_12, Gamma_R1_3); - assert ((R0_12 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000037f"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_14, Gamma_R0_14 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_14) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_14, 0bv32), gamma_store32(Gamma_mem, R0_14, true); - assert ((R0_14 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000392"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_16, Gamma_R0_16 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - R0_17, Gamma_R0_17 := memory_load32_le(mem, R0_16), (gamma_load32(Gamma_mem, R0_16) || L(mem, R0_16)); - R1_4, Gamma_R1_4 := zero_extend32_32(bvadd32(R0_17, 1bv32)), Gamma_R0_17; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_19, Gamma_R0_19 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - assert (L(mem, R0_19) ==> Gamma_R1_4); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_19, R1_4[32:0]), gamma_store32(Gamma_mem, R0_19, Gamma_R1_4); - assert ((R0_19 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000003bf"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_4; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_4; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/secret_write/gcc_pic/secret_write_gtirb.expected b/src/test/correct/secret_write/gcc_pic/secret_write_gtirb.expected index baef06084..9ad582f9c 100644 --- a/src/test/correct/secret_write/gcc_pic/secret_write_gtirb.expected +++ b/src/test/correct/secret_write/gcc_pic/secret_write_gtirb.expected @@ -1,4 +1,8 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); @@ -6,23 +10,14 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(mem$in, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -32,11 +27,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -47,12 +38,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -61,17 +48,14 @@ procedure {:extern} rely(); ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 2008bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2009bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2010bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2011bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 2008bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69652bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -100,131 +84,113 @@ implementation {:extern} guarantee_reflexive() assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); requires (gamma_load32(Gamma_mem, $z_addr) == true); requires (gamma_load32(Gamma_mem, $secret_addr) == false); requires (memory_load32_le(mem, $z_addr) == 0bv32); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 2008bv64) == 1bv8); - free requires (memory_load8_le(mem, 2009bv64) == 0bv8); - free requires (memory_load8_le(mem, 2010bv64) == 2bv8); - free requires (memory_load8_le(mem, 2011bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69660bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 2008bv64) == 131073bv32); + free requires (memory_load64_le(mem, 68992bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69000bv64) == 1792bv64); free requires (memory_load64_le(mem, 69584bv64) == 69652bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1792bv64); - free requires (memory_load64_le(mem, 68992bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 2008bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2009bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2010bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2011bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69660bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 2008bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69652bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_12: bool; - var Gamma_R0_14: bool; - var Gamma_R0_16: bool; - var Gamma_R0_17: bool; - var Gamma_R0_19: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_8: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; var Gamma_x_old: bool; - var R0_10: bv64; - var R0_12: bv64; - var R0_14: bv64; - var R0_16: bv64; - var R0_17: bv32; - var R0_19: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_6: bv32; - var R0_8: bv64; - var R1_2: bv32; - var R1_3: bv32; - var R1_4: bv64; var z_old: bv32; $main$__0__$sQQ_g_3GSW~3KrITchatdg: + assume {:captureState "$main$__0__$sQQ_g_3GSW~3KrITchatdg"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 0bv32), gamma_store32(Gamma_mem, R0_3, true); - assert ((R0_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1884$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, R0_5), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); - R1_2, Gamma_R1_2 := bvadd32(R0_6, 1bv32), Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_8, Gamma_R0_8 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - assert (L(mem, R0_8) ==> Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_8, R1_2), gamma_store32(Gamma_mem, R0_8, Gamma_R1_2); - assert ((R0_8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1912$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_10, Gamma_R0_10 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R1_3, Gamma_R1_3 := memory_load32_le(mem, R0_10), (gamma_load32(Gamma_mem, R0_10) || L(mem, R0_10)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_12, Gamma_R0_12 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_12) ==> Gamma_R1_3); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_12, R1_3), gamma_store32(Gamma_mem, R0_12, Gamma_R1_3); - assert ((R0_12 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1936$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_14, Gamma_R0_14 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_14) ==> true); + assert (L(mem, R0) ==> true); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_14, 0bv32), gamma_store32(Gamma_mem, R0_14, true); - assert ((R0_14 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1948$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_16, Gamma_R0_16 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - R0_17, Gamma_R0_17 := memory_load32_le(mem, R0_16), (gamma_load32(Gamma_mem, R0_16) || L(mem, R0_16)); - R1_4, Gamma_R1_4 := zero_extend32_32(bvadd32(R0_17, 1bv32)), Gamma_R0_17; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R1, Gamma_R1 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_19, Gamma_R0_19 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - assert (L(mem, R0_19) ==> Gamma_R1_4); + assert (L(mem, R0) ==> Gamma_R1); z_old := memory_load32_le(mem, $z_addr); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_19, R1_4[32:0]), gamma_store32(Gamma_mem, R0_19, Gamma_R1_4); - assert ((R0_19 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "1976$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_4; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_4; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/switch/clang/switch.expected b/src/test/correct/switch/clang/switch.expected index f580c26f2..71ad0b07a 100644 --- a/src/test/correct/switch/clang/switch.expected +++ b/src/test/correct/switch/clang/switch.expected @@ -1,29 +1,34 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1936bv64); +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +39,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1936bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1937bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1938bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1939bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1936bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -57,8 +58,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -71,94 +72,145 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R31, R8, VF, ZF, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1936bv64) == 1bv8); - free requires (memory_load8_le(mem, 1937bv64) == 0bv8); - free requires (memory_load8_le(mem, 1938bv64) == 2bv8); - free requires (memory_load8_le(mem, 1939bv64) == 0bv8); + free requires (memory_load32_le(mem, 1936bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1936bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1937bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1938bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1939bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1936bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R8_13: bool; - var Gamma_R8_18: bool; - var Gamma_R8_2: bool; - var Gamma_R8_7: bool; - var Gamma_R8_8: bool; - var R8_13: bv64; - var R8_18: bv64; - var R8_2: bv32; - var R8_7: bv64; - var R8_8: bv32; + var #4: bv32; + var #5: bv32; + var Gamma_#4: bool; + var Gamma_#5: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R8_2, Gamma_R8_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), R8_2), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), Gamma_R8_2); - assert Gamma_R8_2; + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000323"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%0000032a"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000339"} true; + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967294bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967295bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l0000035a, lmain_goto_l0000035d; - lmain_goto_l0000035d: - assume (R8_2 == 1bv32); - R8_7, Gamma_R8_7 := 1bv64, true; + l0000035d: + assume {:captureState "l0000035d"} true; + R8, Gamma_R8 := 1bv64, true; goto l00000360; - lmain_goto_l0000035a: - assume (!(R8_2 == 1bv32)); - R8_7, Gamma_R8_7 := 0bv64, true; + l0000035a: + assume {:captureState "l0000035a"} true; + R8, Gamma_R8 := 0bv64, true; goto l00000360; l00000360: - assert Gamma_R8_7; + assume {:captureState "l00000360"} true; + assert Gamma_R8; goto l00000360_goto_l00000368, l00000360_goto_l0000039a; - l00000360_goto_l0000039a: - assume (!(R8_7[1:0] == 1bv1)); - R8_8, Gamma_R8_8 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - assert Gamma_R8_8; + l0000039a: + assume {:captureState "l0000039a"} true; + goto l0000039b; + l0000039b: + assume {:captureState "l0000039b"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); + #5, Gamma_#5 := bvadd32(R8[32:0], 4294967292bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934589bv33))), (Gamma_R8 && Gamma_#5); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#5, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967293bv33))), (Gamma_R8 && Gamma_#5); + ZF, Gamma_ZF := bvcomp32(bvadd32(#5, 1bv32), 0bv32), Gamma_#5; + NF, Gamma_NF := bvadd32(#5, 1bv32)[32:31], Gamma_#5; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#5, 1bv32)), Gamma_#5; + assert Gamma_ZF; goto l0000039b_goto_l000003c4, l0000039b_goto_l000003c7; - l0000039b_goto_l000003c7: - assume (!(R8_8 == 3bv32)); - R8_13, Gamma_R8_13 := 1bv64, true; + l000003c7: + assume {:captureState "l000003c7"} true; + R8, Gamma_R8 := 1bv64, true; goto l000003ca; - l0000039b_goto_l000003c4: - assume (R8_8 == 3bv32); - R8_13, Gamma_R8_13 := 0bv64, true; + l000003c4: + assume {:captureState "l000003c4"} true; + R8, Gamma_R8 := 0bv64, true; goto l000003ca; l000003ca: - assert Gamma_R8_13; + assume {:captureState "l000003ca"} true; + assert Gamma_R8; goto l000003ca_goto_l00000389, l000003ca_goto_l000003d7; - l000003ca_goto_l000003d7: - assume (!(R8_13[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - goto l00000368; - l000003ca_goto_l00000389: - assume (R8_13[1:0] == 1bv1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 5bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R8_18, Gamma_R8_18 := 5bv64, true; + l00000389: + assume {:captureState "l00000389"} true; + R8, Gamma_R8 := 5bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000394"} true; goto l0000037b; - l00000360_goto_l00000368: - assume (R8_7[1:0] == 1bv1); + l000003d7: + assume {:captureState "l000003d7"} true; + goto l000003d8; + l000003d8: + assume {:captureState "l000003d8"} true; + R8, Gamma_R8 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%000003e6"} true; goto l00000368; l00000368: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R8_18, Gamma_R8_18 := 1bv64, true; + assume {:captureState "l00000368"} true; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000378"} true; goto l0000037b; l0000037b: + assume {:captureState "l0000037b"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l0000035a: + assume {:captureState "lmain_goto_l0000035a"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l0000035a; + lmain_goto_l0000035d: + assume {:captureState "lmain_goto_l0000035d"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l0000035d; + l00000360_goto_l00000368: + assume {:captureState "l00000360_goto_l00000368"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l00000368; + l00000360_goto_l0000039a: + assume {:captureState "l00000360_goto_l0000039a"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l0000039a; + l0000039b_goto_l000003c4: + assume {:captureState "l0000039b_goto_l000003c4"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l000003c4; + l0000039b_goto_l000003c7: + assume {:captureState "l0000039b_goto_l000003c7"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l000003c7; + l000003ca_goto_l00000389: + assume {:captureState "l000003ca_goto_l00000389"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l00000389; + l000003ca_goto_l000003d7: + assume {:captureState "l000003ca_goto_l000003d7"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l000003d7; main_basil_return: - R31_out, R8_out := R31_in, R8_18; - Gamma_R31_out, Gamma_R8_out := Gamma_R31_in, Gamma_R8_18; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/switch/clang/switch_gtirb.expected b/src/test/correct/switch/clang/switch_gtirb.expected index 4b0a44f01..9a0c4ad46 100644 --- a/src/test/correct/switch/clang/switch_gtirb.expected +++ b/src/test/correct/switch/clang/switch_gtirb.expected @@ -1,29 +1,33 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1936bv64); +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +38,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1936bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1937bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1938bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1939bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1936bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -57,8 +57,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -71,120 +71,129 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R31, R8, VF, ZF, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1936bv64) == 1bv8); - free requires (memory_load8_le(mem, 1937bv64) == 0bv8); - free requires (memory_load8_le(mem, 1938bv64) == 2bv8); - free requires (memory_load8_le(mem, 1939bv64) == 0bv8); + free requires (memory_load32_le(mem, 1936bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1936bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1937bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1938bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1939bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1936bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R8_15: bool; - var Gamma_R8_17: bool; - var Gamma_R8_2: bool; - var Gamma_R8_20: bool; - var Gamma_R8_22: bool; - var Gamma_R8_8: bool; - var Gamma_R8_9: bool; - var R8_15: bv64; - var R8_17: bv64; - var R8_2: bv32; - var R8_20: bv64; - var R8_22: bv64; - var R8_8: bv64; - var R8_9: bv32; + var Cse0__5$2$1: bv32; + var Cse0__5$3$6: bv32; + var Gamma_Cse0__5$2$1: bool; + var Gamma_Cse0__5$3$6: bool; $main$__0__$3GlaOF1MR7aaQai1pc2v2g: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R8_2, Gamma_R8_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), R8_2), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), Gamma_R8_2); - assert Gamma_R8_2; + assume {:captureState "$main$__0__$3GlaOF1MR7aaQai1pc2v2g"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1820$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "1824$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "1832$0"} true; + Cse0__5$3$6, Gamma_Cse0__5$3$6 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$3$6), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_Cse0__5$3$6); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$6), bvadd33(zero_extend1_32(R8[32:0]), 4294967295bv33))), (Gamma_R8 && Gamma_Cse0__5$3$6); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$6, 0bv32), Gamma_Cse0__5$3$6; + NF, Gamma_NF := Cse0__5$3$6[32:31], Gamma_Cse0__5$3$6; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$3$6), Gamma_Cse0__5$3$6; + assert Gamma_ZF; goto $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__0, $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__1; - $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__1: - assume (R8_2 == 1bv32); - goto $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__1_phi_$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__5__$24PniileSwWTb~gBPRo3qQ_phi_back_$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__5__$24PniileSwWTb~gBPRo3qQ, $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__1_phi_$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__1__$4x~lmTLbT2auzSCUAlHDag_phi_back_$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__1__$4x~lmTLbT2auzSCUAlHDag; - $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__1_phi_$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__1__$4x~lmTLbT2auzSCUAlHDag_phi_back_$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__1__$4x~lmTLbT2auzSCUAlHDag: - R8_8, Gamma_R8_8 := 1bv64, true; - assert Gamma_R8_8; - goto $main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__1__$4x~lmTLbT2auzSCUAlHDag; - $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__1_phi_$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__5__$24PniileSwWTb~gBPRo3qQ_phi_back_$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__5__$24PniileSwWTb~gBPRo3qQ: - R8_20, Gamma_R8_20 := 1bv64, true; - assert Gamma_R8_20; - goto $main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__5__$24PniileSwWTb~gBPRo3qQ; - $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__0: - assume (!(R8_2 == 1bv32)); - goto $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__0_phi_back_$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__1__$4x~lmTLbT2auzSCUAlHDag, $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__0_phi_back_$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__5__$24PniileSwWTb~gBPRo3qQ; - $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__0_phi_back_$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__5__$24PniileSwWTb~gBPRo3qQ: - R8_20, Gamma_R8_20 := 0bv64, true; - assert Gamma_R8_20; - goto $main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__5__$24PniileSwWTb~gBPRo3qQ; - $main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__5__$24PniileSwWTb~gBPRo3qQ: - assume (R8_20[1:0] == 1bv1); - goto $main$__5__$24PniileSwWTb~gBPRo3qQ; - $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__0_phi_back_$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__1__$4x~lmTLbT2auzSCUAlHDag: - R8_8, Gamma_R8_8 := 0bv64, true; - assert Gamma_R8_8; - goto $main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__1__$4x~lmTLbT2auzSCUAlHDag; - $main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__1__$4x~lmTLbT2auzSCUAlHDag: - assume (!(R8_8[1:0] == 1bv1)); - R8_9, Gamma_R8_9 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - assert Gamma_R8_9; + $main$__1__$4x~lmTLbT2auzSCUAlHDag: + assume {:captureState "$main$__1__$4x~lmTLbT2auzSCUAlHDag"} true; + goto $main$__2__$jyrJQYSIS2Ws80LCkGPZrA; + $main$__2__$jyrJQYSIS2Ws80LCkGPZrA: + assume {:captureState "$main$__2__$jyrJQYSIS2Ws80LCkGPZrA"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); + Cse0__5$2$1, Gamma_Cse0__5$2$1 := bvadd32(R8[32:0], 4294967293bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$2$1), bvadd33(sign_extend1_32(R8[32:0]), 8589934589bv33))), (Gamma_R8 && Gamma_Cse0__5$2$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$2$1), bvadd33(zero_extend1_32(R8[32:0]), 4294967293bv33))), (Gamma_R8 && Gamma_Cse0__5$2$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$2$1, 0bv32), Gamma_Cse0__5$2$1; + NF, Gamma_NF := Cse0__5$2$1[32:31], Gamma_Cse0__5$2$1; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$2$1), Gamma_Cse0__5$2$1; + assert Gamma_ZF; goto $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__0, $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__1; - $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__1: - assume (!(R8_9 == 3bv32)); - goto $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__1_phi_$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__6__$M0Alxdx8S_6NyJoZnSXkvw_phi_back_$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__6__$M0Alxdx8S_6NyJoZnSXkvw, $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__1_phi_$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__3__$XW5NfPfUQ4KyEikucDTunQ_phi_back_$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__3__$XW5NfPfUQ4KyEikucDTunQ; - $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__1_phi_$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__3__$XW5NfPfUQ4KyEikucDTunQ_phi_back_$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__3__$XW5NfPfUQ4KyEikucDTunQ: - R8_15, Gamma_R8_15 := 1bv64, true; - assert Gamma_R8_15; - goto $main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__3__$XW5NfPfUQ4KyEikucDTunQ; - $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__1_phi_$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__6__$M0Alxdx8S_6NyJoZnSXkvw_phi_back_$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__6__$M0Alxdx8S_6NyJoZnSXkvw: - R8_17, Gamma_R8_17 := 1bv64, true; - assert Gamma_R8_17; - goto $main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__6__$M0Alxdx8S_6NyJoZnSXkvw; - $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__0: - assume (R8_9 == 3bv32); - goto $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__0_phi_back_$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__3__$XW5NfPfUQ4KyEikucDTunQ, $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__0_phi_back_$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__6__$M0Alxdx8S_6NyJoZnSXkvw; - $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__0_phi_back_$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__6__$M0Alxdx8S_6NyJoZnSXkvw: - R8_17, Gamma_R8_17 := 0bv64, true; - assert Gamma_R8_17; - goto $main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__6__$M0Alxdx8S_6NyJoZnSXkvw; - $main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__6__$M0Alxdx8S_6NyJoZnSXkvw: - assume (R8_17[1:0] == 1bv1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 5bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R8_22, Gamma_R8_22 := 5bv64, true; - goto $main$__7__$Imv7ODlKQ3y~H7OMiSSR_w; - $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__0_phi_back_$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__3__$XW5NfPfUQ4KyEikucDTunQ: - R8_15, Gamma_R8_15 := 0bv64, true; - assert Gamma_R8_15; - goto $main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__3__$XW5NfPfUQ4KyEikucDTunQ; - $main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__3__$XW5NfPfUQ4KyEikucDTunQ: - assume (!(R8_15[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + $main$__3__$XW5NfPfUQ4KyEikucDTunQ: + assume {:captureState "$main$__3__$XW5NfPfUQ4KyEikucDTunQ"} true; + goto $main$__4__$gwXdF75eT4Ou~FTT7cThmQ; + $main$__4__$gwXdF75eT4Ou~FTT7cThmQ: + assume {:captureState "$main$__4__$gwXdF75eT4Ou~FTT7cThmQ"} true; + R8, Gamma_R8 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1876$0"} true; goto $main$__5__$24PniileSwWTb~gBPRo3qQ; $main$__5__$24PniileSwWTb~gBPRo3qQ: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R8_22, Gamma_R8_22 := 1bv64, true; + assume {:captureState "$main$__5__$24PniileSwWTb~gBPRo3qQ"} true; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1888$0"} true; + goto $main$__7__$Imv7ODlKQ3y~H7OMiSSR_w; + $main$__6__$M0Alxdx8S_6NyJoZnSXkvw: + assume {:captureState "$main$__6__$M0Alxdx8S_6NyJoZnSXkvw"} true; + R8, Gamma_R8 := 5bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1900$0"} true; goto $main$__7__$Imv7ODlKQ3y~H7OMiSSR_w; $main$__7__$Imv7ODlKQ3y~H7OMiSSR_w: + assume {:captureState "$main$__7__$Imv7ODlKQ3y~H7OMiSSR_w"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__6__$M0Alxdx8S_6NyJoZnSXkvw: + assume {:captureState "$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__6__$M0Alxdx8S_6NyJoZnSXkvw"} true; + assume (R8[1:0] == 1bv1); + goto $main$__6__$M0Alxdx8S_6NyJoZnSXkvw; + $main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__3__$XW5NfPfUQ4KyEikucDTunQ: + assume {:captureState "$main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__3__$XW5NfPfUQ4KyEikucDTunQ"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__3__$XW5NfPfUQ4KyEikucDTunQ; + $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__0: + assume {:captureState "$main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__6__$M0Alxdx8S_6NyJoZnSXkvw, $main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__3__$XW5NfPfUQ4KyEikucDTunQ; + $main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__1: + assume {:captureState "$main$__2__$jyrJQYSIS2Ws80LCkGPZrA$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__6__$M0Alxdx8S_6NyJoZnSXkvw, $main$__2__$jyrJQYSIS2Ws80LCkGPZrA_goto_$main$__3__$XW5NfPfUQ4KyEikucDTunQ; + $main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__5__$24PniileSwWTb~gBPRo3qQ: + assume {:captureState "$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__5__$24PniileSwWTb~gBPRo3qQ"} true; + assume (R8[1:0] == 1bv1); + goto $main$__5__$24PniileSwWTb~gBPRo3qQ; + $main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__1__$4x~lmTLbT2auzSCUAlHDag: + assume {:captureState "$main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__1__$4x~lmTLbT2auzSCUAlHDag"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$4x~lmTLbT2auzSCUAlHDag; + $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__0: + assume {:captureState "$main$__0__$3GlaOF1MR7aaQai1pc2v2g$__0"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__5__$24PniileSwWTb~gBPRo3qQ, $main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__1__$4x~lmTLbT2auzSCUAlHDag; + $main$__0__$3GlaOF1MR7aaQai1pc2v2g$__1: + assume {:captureState "$main$__0__$3GlaOF1MR7aaQai1pc2v2g$__1"} true; + assume (!(!(ZF == 1bv1))); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__5__$24PniileSwWTb~gBPRo3qQ, $main$__0__$3GlaOF1MR7aaQai1pc2v2g_goto_$main$__1__$4x~lmTLbT2auzSCUAlHDag; main_basil_return: - R31_out, R8_out := R31_in, R8_22; - Gamma_R31_out, Gamma_R8_out := Gamma_R31_in, Gamma_R8_22; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/switch/clang_O2/switch.expected b/src/test/correct/switch/clang_O2/switch.expected index 4202ee31f..63ab24607 100644 --- a/src/test/correct/switch/clang_O2/switch.expected +++ b/src/test/correct/switch/clang_O2/switch.expected @@ -3,22 +3,19 @@ var {:extern} mem: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1836bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { - (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { + (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1836bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1837bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1838bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1839bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1836bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -26,8 +23,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -40,33 +37,27 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure main(); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1836bv64) == 1bv8); - free requires (memory_load8_le(mem, 1837bv64) == 0bv8); - free requires (memory_load8_le(mem, 1838bv64) == 2bv8); - free requires (memory_load8_le(mem, 1839bv64) == 0bv8); + free requires (memory_load32_le(mem, 1836bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1836bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1837bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1838bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1839bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1836bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { lmain: + assume {:captureState "lmain"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R12_out, R13_out, R14_out, R15_out, R16_out, R17_out, R18_out, R19_out, R1_out, R20_out, R21_out, R22_out, R23_out, R24_out, R25_out, R26_out, R27_out, R28_out, R29_out, R2_out, R30_out, R31_out, R3_out, R4_out, R5_out, R6_out, R7_out, R8_out, R9_out := R0_in, R10_in, R11_in, R12_in, R13_in, R14_in, R15_in, R16_in, R17_in, R18_in, R19_in, R1_in, R20_in, R21_in, R22_in, R23_in, R24_in, R25_in, R26_in, R27_in, R28_in, R29_in, R2_in, R30_in, R31_in, R3_in, R4_in, R5_in, R6_in, R7_in, R8_in, R9_in; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R12_out, Gamma_R13_out, Gamma_R14_out, Gamma_R15_out, Gamma_R16_out, Gamma_R17_out, Gamma_R18_out, Gamma_R19_out, Gamma_R1_out, Gamma_R20_out, Gamma_R21_out, Gamma_R22_out, Gamma_R23_out, Gamma_R24_out, Gamma_R25_out, Gamma_R26_out, Gamma_R27_out, Gamma_R28_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out, Gamma_R3_out, Gamma_R4_out, Gamma_R5_out, Gamma_R6_out, Gamma_R7_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_in, Gamma_R10_in, Gamma_R11_in, Gamma_R12_in, Gamma_R13_in, Gamma_R14_in, Gamma_R15_in, Gamma_R16_in, Gamma_R17_in, Gamma_R18_in, Gamma_R19_in, Gamma_R1_in, Gamma_R20_in, Gamma_R21_in, Gamma_R22_in, Gamma_R23_in, Gamma_R24_in, Gamma_R25_in, Gamma_R26_in, Gamma_R27_in, Gamma_R28_in, Gamma_R29_in, Gamma_R2_in, Gamma_R30_in, Gamma_R31_in, Gamma_R3_in, Gamma_R4_in, Gamma_R5_in, Gamma_R6_in, Gamma_R7_in, Gamma_R8_in, Gamma_R9_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/switch/clang_O2/switch_gtirb.expected b/src/test/correct/switch/clang_O2/switch_gtirb.expected index 87d33b382..6197b5d11 100644 --- a/src/test/correct/switch/clang_O2/switch_gtirb.expected +++ b/src/test/correct/switch/clang_O2/switch_gtirb.expected @@ -3,22 +3,19 @@ var {:extern} mem: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1836bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { - (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { + (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1836bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1837bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1838bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1839bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1836bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -26,8 +23,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -40,33 +37,27 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure main(); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1836bv64) == 1bv8); - free requires (memory_load8_le(mem, 1837bv64) == 0bv8); - free requires (memory_load8_le(mem, 1838bv64) == 2bv8); - free requires (memory_load8_le(mem, 1839bv64) == 0bv8); + free requires (memory_load32_le(mem, 1836bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1836bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1837bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1838bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1839bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1836bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { $main$__0__$qfp8WI3CQQKrYS27mbga8Q: + assume {:captureState "$main$__0__$qfp8WI3CQQKrYS27mbga8Q"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R12_out, R13_out, R14_out, R15_out, R16_out, R17_out, R18_out, R19_out, R1_out, R20_out, R21_out, R22_out, R23_out, R24_out, R25_out, R26_out, R27_out, R28_out, R29_out, R2_out, R30_out, R31_out, R3_out, R4_out, R5_out, R6_out, R7_out, R8_out, R9_out := R0_in, R10_in, R11_in, R12_in, R13_in, R14_in, R15_in, R16_in, R17_in, R18_in, R19_in, R1_in, R20_in, R21_in, R22_in, R23_in, R24_in, R25_in, R26_in, R27_in, R28_in, R29_in, R2_in, R30_in, R31_in, R3_in, R4_in, R5_in, R6_in, R7_in, R8_in, R9_in; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R12_out, Gamma_R13_out, Gamma_R14_out, Gamma_R15_out, Gamma_R16_out, Gamma_R17_out, Gamma_R18_out, Gamma_R19_out, Gamma_R1_out, Gamma_R20_out, Gamma_R21_out, Gamma_R22_out, Gamma_R23_out, Gamma_R24_out, Gamma_R25_out, Gamma_R26_out, Gamma_R27_out, Gamma_R28_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out, Gamma_R3_out, Gamma_R4_out, Gamma_R5_out, Gamma_R6_out, Gamma_R7_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_in, Gamma_R10_in, Gamma_R11_in, Gamma_R12_in, Gamma_R13_in, Gamma_R14_in, Gamma_R15_in, Gamma_R16_in, Gamma_R17_in, Gamma_R18_in, Gamma_R19_in, Gamma_R1_in, Gamma_R20_in, Gamma_R21_in, Gamma_R22_in, Gamma_R23_in, Gamma_R24_in, Gamma_R25_in, Gamma_R26_in, Gamma_R27_in, Gamma_R28_in, Gamma_R29_in, Gamma_R2_in, Gamma_R30_in, Gamma_R31_in, Gamma_R3_in, Gamma_R4_in, Gamma_R5_in, Gamma_R6_in, Gamma_R7_in, Gamma_R8_in, Gamma_R9_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/switch/gcc/switch.expected b/src/test/correct/switch/gcc/switch.expected index a42a938b9..b13f88a63 100644 --- a/src/test/correct/switch/gcc/switch.expected +++ b/src/test/correct/switch/gcc/switch.expected @@ -1,29 +1,34 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1916bv64); +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +39,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -57,8 +58,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -71,67 +72,95 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R0, R31, VF, ZF, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1916bv64) == 1bv8); - free requires (memory_load8_le(mem, 1917bv64) == 0bv8); - free requires (memory_load8_le(mem, 1918bv64) == 2bv8); - free requires (memory_load8_le(mem, 1919bv64) == 0bv8); + free requires (memory_load32_le(mem, 1916bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_8: bool; - var R0_2: bv32; - var R0_3: bv32; - var R0_8: bv64; + var #4: bv32; + var #5: bv32; + var Gamma_#4: bool; + var Gamma_#5: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R0_2, Gamma_R0_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - assert Gamma_R0_2; + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000030f"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000316"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967295bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000339, lmain_goto_l0000036b; - lmain_goto_l0000036b: - assume (!(R0_2 == 1bv32)); - R0_3, Gamma_R0_3 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - assert Gamma_R0_3; + l0000036b: + assume {:captureState "l0000036b"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + #5, Gamma_#5 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#5); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#5, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967293bv33))), (Gamma_R0 && Gamma_#5); + ZF, Gamma_ZF := bvcomp32(bvadd32(#5, 1bv32), 0bv32), Gamma_#5; + NF, Gamma_NF := bvadd32(#5, 1bv32)[32:31], Gamma_#5; + assert Gamma_ZF; goto l0000036b_goto_l0000035c, l0000036b_goto_l00000391; - l0000036b_goto_l00000391: - assume (R0_3 == 3bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - goto l00000339; - l0000036b_goto_l0000035c: - assume (!(R0_3 == 3bv32)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 5bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R0_8, Gamma_R0_8 := 5bv64, true; + l0000035c: + assume {:captureState "l0000035c"} true; + R0, Gamma_R0 := 5bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000367"} true; goto l0000034c; - lmain_goto_l00000339: - assume (R0_2 == 1bv32); + l00000391: + assume {:captureState "l00000391"} true; + R0, Gamma_R0 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000039c"} true; goto l00000339; l00000339: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R0_8, Gamma_R0_8 := 1bv64, true; + assume {:captureState "l00000339"} true; + R0, Gamma_R0 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000349"} true; goto l0000034c; l0000034c: + assume {:captureState "l0000034c"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000339: + assume {:captureState "lmain_goto_l00000339"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l00000339; + lmain_goto_l0000036b: + assume {:captureState "lmain_goto_l0000036b"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l0000036b; + l0000036b_goto_l0000035c: + assume {:captureState "l0000036b_goto_l0000035c"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l0000035c; + l0000036b_goto_l00000391: + assume {:captureState "l0000036b_goto_l00000391"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000391; main_basil_return: - R0_out, R31_out := R0_8, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_8, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/switch/gcc/switch_gtirb.expected b/src/test/correct/switch/gcc/switch_gtirb.expected index 6d313c5f6..2d439a7c9 100644 --- a/src/test/correct/switch/gcc/switch_gtirb.expected +++ b/src/test/correct/switch/gcc/switch_gtirb.expected @@ -1,29 +1,33 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1916bv64); +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -34,22 +38,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -57,8 +57,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -71,67 +71,95 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R0, R31, VF, ZF, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1916bv64) == 1bv8); - free requires (memory_load8_le(mem, 1917bv64) == 0bv8); - free requires (memory_load8_le(mem, 1918bv64) == 2bv8); - free requires (memory_load8_le(mem, 1919bv64) == 0bv8); + free requires (memory_load32_le(mem, 1916bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_8: bool; - var R0_2: bv32; - var R0_3: bv32; - var R0_8: bv64; + var Cse0__5$1$5: bv32; + var Cse0__5$5$1: bv32; + var Gamma_Cse0__5$1$5: bool; + var Gamma_Cse0__5$5$1: bool; $main$__0__$fTP6a10DRkW0uClOUn3VYg: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R0_2, Gamma_R0_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - assert Gamma_R0_2; + assume {:captureState "$main$__0__$fTP6a10DRkW0uClOUn3VYg"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "1820$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + Cse0__5$1$5, Gamma_Cse0__5$1$5 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$1$5), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_Cse0__5$1$5); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$1$5), bvadd33(zero_extend1_32(R0[32:0]), 4294967295bv33))), (Gamma_R0 && Gamma_Cse0__5$1$5); + ZF, Gamma_ZF := bvcomp32(Cse0__5$1$5, 0bv32), Gamma_Cse0__5$1$5; + NF, Gamma_NF := Cse0__5$1$5[32:31], Gamma_Cse0__5$1$5; + assert Gamma_ZF; goto $main$__0__$fTP6a10DRkW0uClOUn3VYg_goto_$main$__3__$K4NVIb_2TLqhdwKQk4e4yQ, $main$__0__$fTP6a10DRkW0uClOUn3VYg_goto_$main$__1__$qKMMRobvQhOFWJ6vLsAXWw; - $main$__0__$fTP6a10DRkW0uClOUn3VYg_goto_$main$__1__$qKMMRobvQhOFWJ6vLsAXWw: - assume (!(R0_2 == 1bv32)); - R0_3, Gamma_R0_3 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - assert Gamma_R0_3; + $main$__1__$qKMMRobvQhOFWJ6vLsAXWw: + assume {:captureState "$main$__1__$qKMMRobvQhOFWJ6vLsAXWw"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + Cse0__5$5$1, Gamma_Cse0__5$5$1 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$5$1), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_Cse0__5$5$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$5$1), bvadd33(zero_extend1_32(R0[32:0]), 4294967293bv33))), (Gamma_R0 && Gamma_Cse0__5$5$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$5$1, 0bv32), Gamma_Cse0__5$5$1; + NF, Gamma_NF := Cse0__5$5$1[32:31], Gamma_Cse0__5$5$1; + assert Gamma_ZF; goto $main$__1__$qKMMRobvQhOFWJ6vLsAXWw_goto_$main$__4__$DonY551VSjGOjsGSDV0czQ, $main$__1__$qKMMRobvQhOFWJ6vLsAXWw_goto_$main$__2__$0NcRUSBiRJiPUYrDF8NHDQ; - $main$__1__$qKMMRobvQhOFWJ6vLsAXWw_goto_$main$__2__$0NcRUSBiRJiPUYrDF8NHDQ: - assume (R0_3 == 3bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - goto $main$__3__$K4NVIb_2TLqhdwKQk4e4yQ; - $main$__1__$qKMMRobvQhOFWJ6vLsAXWw_goto_$main$__4__$DonY551VSjGOjsGSDV0czQ: - assume (!(R0_3 == 3bv32)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 5bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R0_8, Gamma_R0_8 := 5bv64, true; - goto $main$__5__$9WeRIM9VQHukMzVZYtgvQA; - $main$__0__$fTP6a10DRkW0uClOUn3VYg_goto_$main$__3__$K4NVIb_2TLqhdwKQk4e4yQ: - assume (R0_2 == 1bv32); + $main$__2__$0NcRUSBiRJiPUYrDF8NHDQ: + assume {:captureState "$main$__2__$0NcRUSBiRJiPUYrDF8NHDQ"} true; + R0, Gamma_R0 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1856$0"} true; goto $main$__3__$K4NVIb_2TLqhdwKQk4e4yQ; $main$__3__$K4NVIb_2TLqhdwKQk4e4yQ: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R0_8, Gamma_R0_8 := 1bv64, true; + assume {:captureState "$main$__3__$K4NVIb_2TLqhdwKQk4e4yQ"} true; + R0, Gamma_R0 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1864$0"} true; + goto $main$__5__$9WeRIM9VQHukMzVZYtgvQA; + $main$__4__$DonY551VSjGOjsGSDV0czQ: + assume {:captureState "$main$__4__$DonY551VSjGOjsGSDV0czQ"} true; + R0, Gamma_R0 := 5bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1876$0"} true; goto $main$__5__$9WeRIM9VQHukMzVZYtgvQA; $main$__5__$9WeRIM9VQHukMzVZYtgvQA: + assume {:captureState "$main$__5__$9WeRIM9VQHukMzVZYtgvQA"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$fTP6a10DRkW0uClOUn3VYg_goto_$main$__3__$K4NVIb_2TLqhdwKQk4e4yQ: + assume {:captureState "$main$__0__$fTP6a10DRkW0uClOUn3VYg_goto_$main$__3__$K4NVIb_2TLqhdwKQk4e4yQ"} true; + assume (ZF == 1bv1); + goto $main$__3__$K4NVIb_2TLqhdwKQk4e4yQ; + $main$__0__$fTP6a10DRkW0uClOUn3VYg_goto_$main$__1__$qKMMRobvQhOFWJ6vLsAXWw: + assume {:captureState "$main$__0__$fTP6a10DRkW0uClOUn3VYg_goto_$main$__1__$qKMMRobvQhOFWJ6vLsAXWw"} true; + assume (!(ZF == 1bv1)); + goto $main$__1__$qKMMRobvQhOFWJ6vLsAXWw; + $main$__1__$qKMMRobvQhOFWJ6vLsAXWw_goto_$main$__4__$DonY551VSjGOjsGSDV0czQ: + assume {:captureState "$main$__1__$qKMMRobvQhOFWJ6vLsAXWw_goto_$main$__4__$DonY551VSjGOjsGSDV0czQ"} true; + assume (!(ZF == 1bv1)); + goto $main$__4__$DonY551VSjGOjsGSDV0czQ; + $main$__1__$qKMMRobvQhOFWJ6vLsAXWw_goto_$main$__2__$0NcRUSBiRJiPUYrDF8NHDQ: + assume {:captureState "$main$__1__$qKMMRobvQhOFWJ6vLsAXWw_goto_$main$__2__$0NcRUSBiRJiPUYrDF8NHDQ"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__2__$0NcRUSBiRJiPUYrDF8NHDQ; main_basil_return: - R0_out, R31_out := R0_8, R31_in; - Gamma_R0_out, Gamma_R31_out := Gamma_R0_8, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/switch/gcc_O2/switch.expected b/src/test/correct/switch/gcc_O2/switch.expected index 579f58cfd..a1aa0c66c 100644 --- a/src/test/correct/switch/gcc_O2/switch.expected +++ b/src/test/correct/switch/gcc_O2/switch.expected @@ -3,22 +3,19 @@ var {:extern} mem: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1896bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { - (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { + (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -26,8 +23,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -40,33 +37,27 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure main(); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { lmain: + assume {:captureState "lmain"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R12_out, R13_out, R14_out, R15_out, R16_out, R17_out, R18_out, R19_out, R1_out, R20_out, R21_out, R22_out, R23_out, R24_out, R25_out, R26_out, R27_out, R28_out, R29_out, R2_out, R30_out, R31_out, R3_out, R4_out, R5_out, R6_out, R7_out, R8_out, R9_out := R0_in, R10_in, R11_in, R12_in, R13_in, R14_in, R15_in, R16_in, R17_in, R18_in, R19_in, R1_in, R20_in, R21_in, R22_in, R23_in, R24_in, R25_in, R26_in, R27_in, R28_in, R29_in, R2_in, R30_in, R31_in, R3_in, R4_in, R5_in, R6_in, R7_in, R8_in, R9_in; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R12_out, Gamma_R13_out, Gamma_R14_out, Gamma_R15_out, Gamma_R16_out, Gamma_R17_out, Gamma_R18_out, Gamma_R19_out, Gamma_R1_out, Gamma_R20_out, Gamma_R21_out, Gamma_R22_out, Gamma_R23_out, Gamma_R24_out, Gamma_R25_out, Gamma_R26_out, Gamma_R27_out, Gamma_R28_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out, Gamma_R3_out, Gamma_R4_out, Gamma_R5_out, Gamma_R6_out, Gamma_R7_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_in, Gamma_R10_in, Gamma_R11_in, Gamma_R12_in, Gamma_R13_in, Gamma_R14_in, Gamma_R15_in, Gamma_R16_in, Gamma_R17_in, Gamma_R18_in, Gamma_R19_in, Gamma_R1_in, Gamma_R20_in, Gamma_R21_in, Gamma_R22_in, Gamma_R23_in, Gamma_R24_in, Gamma_R25_in, Gamma_R26_in, Gamma_R27_in, Gamma_R28_in, Gamma_R29_in, Gamma_R2_in, Gamma_R30_in, Gamma_R31_in, Gamma_R3_in, Gamma_R4_in, Gamma_R5_in, Gamma_R6_in, Gamma_R7_in, Gamma_R8_in, Gamma_R9_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/switch/gcc_O2/switch_gtirb.expected b/src/test/correct/switch/gcc_O2/switch_gtirb.expected index 39c88e37d..aca746161 100644 --- a/src/test/correct/switch/gcc_O2/switch_gtirb.expected +++ b/src/test/correct/switch/gcc_O2/switch_gtirb.expected @@ -3,22 +3,19 @@ var {:extern} mem: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1896bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { - (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { + (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -26,8 +23,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -40,33 +37,27 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure main(); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { $main$__0__$DWpLJcPSSFO5KWiSANP3Qw: + assume {:captureState "$main$__0__$DWpLJcPSSFO5KWiSANP3Qw"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R12_out, R13_out, R14_out, R15_out, R16_out, R17_out, R18_out, R19_out, R1_out, R20_out, R21_out, R22_out, R23_out, R24_out, R25_out, R26_out, R27_out, R28_out, R29_out, R2_out, R30_out, R31_out, R3_out, R4_out, R5_out, R6_out, R7_out, R8_out, R9_out := R0_in, R10_in, R11_in, R12_in, R13_in, R14_in, R15_in, R16_in, R17_in, R18_in, R19_in, R1_in, R20_in, R21_in, R22_in, R23_in, R24_in, R25_in, R26_in, R27_in, R28_in, R29_in, R2_in, R30_in, R31_in, R3_in, R4_in, R5_in, R6_in, R7_in, R8_in, R9_in; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R12_out, Gamma_R13_out, Gamma_R14_out, Gamma_R15_out, Gamma_R16_out, Gamma_R17_out, Gamma_R18_out, Gamma_R19_out, Gamma_R1_out, Gamma_R20_out, Gamma_R21_out, Gamma_R22_out, Gamma_R23_out, Gamma_R24_out, Gamma_R25_out, Gamma_R26_out, Gamma_R27_out, Gamma_R28_out, Gamma_R29_out, Gamma_R2_out, Gamma_R30_out, Gamma_R31_out, Gamma_R3_out, Gamma_R4_out, Gamma_R5_out, Gamma_R6_out, Gamma_R7_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_in, Gamma_R10_in, Gamma_R11_in, Gamma_R12_in, Gamma_R13_in, Gamma_R14_in, Gamma_R15_in, Gamma_R16_in, Gamma_R17_in, Gamma_R18_in, Gamma_R19_in, Gamma_R1_in, Gamma_R20_in, Gamma_R21_in, Gamma_R22_in, Gamma_R23_in, Gamma_R24_in, Gamma_R25_in, Gamma_R26_in, Gamma_R27_in, Gamma_R28_in, Gamma_R29_in, Gamma_R2_in, Gamma_R30_in, Gamma_R31_in, Gamma_R3_in, Gamma_R4_in, Gamma_R5_in, Gamma_R6_in, Gamma_R7_in, Gamma_R8_in, Gamma_R9_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/syscall/clang/syscall.expected b/src/test/correct/syscall/clang/syscall.expected index d2eb7549d..d7e0403c0 100644 --- a/src/test/correct/syscall/clang/syscall.expected +++ b/src/test/correct/syscall/clang/syscall.expected @@ -1,28 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1944bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -32,15 +28,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -51,27 +43,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1944bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1945bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1946bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1947bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1944bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); @@ -79,8 +64,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -93,189 +78,74 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure fork(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure fork(); modifies Gamma_R16, Gamma_R17, R16, R17; - free requires (memory_load8_le(mem, 1944bv64) == 1bv8); - free requires (memory_load8_le(mem, 1945bv64) == 0bv8); - free requires (memory_load8_le(mem, 1946bv64) == 2bv8); - free requires (memory_load8_le(mem, 1947bv64) == 0bv8); + free requires (memory_load32_le(mem, 1944bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); - free ensures (memory_load8_le(mem, 1944bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1945bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1946bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1947bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1944bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_stack, R16, R17, stack; +procedure main(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_stack, R0, R16, R17, R29, R30, R31, stack; free requires (memory_load64_le(mem, 69672bv64) == 0bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); - free requires (memory_load8_le(mem, 1944bv64) == 1bv8); - free requires (memory_load8_le(mem, 1945bv64) == 0bv8); - free requires (memory_load8_le(mem, 1946bv64) == 2bv8); - free requires (memory_load8_le(mem, 1947bv64) == 0bv8); + free requires (memory_load32_le(mem, 1944bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); - free ensures (memory_load8_le(mem, 1944bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1945bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1946bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1947bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1944bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_2: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30_3: bool; - var Gamma_R30_4: bool; - var Gamma_R31_3: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0_2: bv64; - var R0_3: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16: bv64; - var R16_1: bv64; - var R17: bv64; - var R17_1: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_2: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R2_1: bv64; - var R3: bv64; - var R30_3: bv64; - var R30_4: bv64; - var R31_3: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; + var #4: bv64; + var #5: bv64; + var Gamma_#4: bool; + var Gamma_#5: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R1_in); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_2, Gamma_R1_2, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := fork(R0_in, Gamma_R0_in, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1_in, Gamma_R1_in, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in, R2, Gamma_R2, 1904bv64, true, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + #4, Gamma_#4 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002ea"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002f0"} true; + R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%000002fd"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551608bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551608bv64), Gamma_R0); + assume {:captureState "%00000305"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%0000030d"} true; + R30, Gamma_R30 := 1904bv64, true; + call fork(); goto l00000317; l00000317: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_3, 12bv64), R0_2[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_3, 12bv64), Gamma_R0_2); - R0_3, Gamma_R0_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_3, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31_3, 12bv64)); - R29_4, Gamma_R29_4 := memory_load64_le(stack, bvadd64(R31_3, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 32bv64)); - R30_4, Gamma_R30_4 := memory_load64_le(stack, bvadd64(R31_3, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 40bv64)); + assume {:captureState "l00000317"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000031d"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + #5, Gamma_#5 := bvadd64(R31, 32bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#5, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out := R0_3, R29_4, R30_4, bvadd64(R31_3, 48bv64); - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := Gamma_R0_3, Gamma_R29_4, Gamma_R30_4, Gamma_R31_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/syscall/clang/syscall_gtirb.expected b/src/test/correct/syscall/clang/syscall_gtirb.expected index 1fce2cbcf..40bab66af 100644 --- a/src/test/correct/syscall/clang/syscall_gtirb.expected +++ b/src/test/correct/syscall/clang/syscall_gtirb.expected @@ -1,28 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1944bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -32,15 +32,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -51,27 +47,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1944bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1945bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1946bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1947bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1944bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); @@ -79,8 +68,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -93,228 +82,96 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69672bv64) == 0bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); - free requires (memory_load8_le(mem, 1944bv64) == 1bv8); - free requires (memory_load8_le(mem, 1945bv64) == 0bv8); - free requires (memory_load8_le(mem, 1946bv64) == 2bv8); - free requires (memory_load8_le(mem, 1947bv64) == 0bv8); + free requires (memory_load32_le(mem, 1944bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); - free ensures (memory_load8_le(mem, 1944bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1945bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1946bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1947bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1944bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var R0_2: bv64; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; - var R29_3: bv64; - var R30_3: bv64; + var Cse0__5$0$1: bv64; + var Cse0__5$1$2: bv64; + var Gamma_Cse0__5$0$1: bool; + var Gamma_Cse0__5$1$2: bool; $main$__0__$NmHi4RAWSYmKU32HkJ0NXQ: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551600bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R1_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_610(R16, Gamma_R16); + assume {:captureState "$main$__0__$NmHi4RAWSYmKU32HkJ0NXQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + Cse0__5$0$1, Gamma_Cse0__5$0$1 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$1, R29), gamma_store64(Gamma_stack, Cse0__5$0$1, Gamma_R29); + assume {:captureState "1880$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$1, 8bv64), Gamma_R30); + assume {:captureState "1880$2"} true; + R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "1888$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551608bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551608bv64), Gamma_R0); + assume {:captureState "1892$0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "1896$0"} true; + R30, Gamma_R30 := 1904bv64, true; + call FUN_610(); goto $main$__1__$ttg35E3ATxG9q5C2p8wnzQ; $main$__1__$ttg35E3ATxG9q5C2p8wnzQ: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551580bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64), Gamma_R0_in); - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551580bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551580bv64)); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551600bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__1__$ttg35E3ATxG9q5C2p8wnzQ"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1904$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + Cse0__5$1$2, Gamma_Cse0__5$1$2 := bvadd64(R31, 32bv64), Gamma_R31; + R29, Gamma_R29 := memory_load64_le(stack, Cse0__5$1$2), gamma_load64(Gamma_stack, Cse0__5$1$2); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(Cse0__5$1$2, 8bv64)), gamma_load64(Gamma_stack, bvadd64(Cse0__5$1$2, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out := R0_2, R29_3, R30_3, R31_in; - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := Gamma_R0_2, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } -procedure FUN_610(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 1944bv64) == 1bv8); - free requires (memory_load8_le(mem, 1945bv64) == 0bv8); - free requires (memory_load8_le(mem, 1946bv64) == 2bv8); - free requires (memory_load8_le(mem, 1947bv64) == 0bv8); +procedure FUN_610(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; + free requires (memory_load32_le(mem, 1944bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); - free ensures (memory_load8_le(mem, 1944bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1945bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1946bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1947bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1944bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation FUN_610(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_610() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_610$__0__$3ABOOETYTria~jSyU9mmbQ: + assume {:captureState "$FUN_610$__0__$3ABOOETYTria~jSyU9mmbQ"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69648bv64), (gamma_load64(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := fork(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69648bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 16bv64)) || L(mem, bvadd64(R16, 16bv64))); + R16, Gamma_R16 := bvadd64(R16, 16bv64), Gamma_R16; + call fork(); assume false; } -procedure fork(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - free requires (memory_load8_le(mem, 1944bv64) == 1bv8); - free requires (memory_load8_le(mem, 1945bv64) == 0bv8); - free requires (memory_load8_le(mem, 1946bv64) == 2bv8); - free requires (memory_load8_le(mem, 1947bv64) == 0bv8); +procedure fork(); + free requires (memory_load32_le(mem, 1944bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); - free ensures (memory_load8_le(mem, 1944bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1945bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1946bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1947bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1944bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); diff --git a/src/test/correct/syscall/clang_O2/syscall_gtirb.expected b/src/test/correct/syscall/clang_O2/syscall_gtirb.expected index 2c07d6457..4ce3e54e5 100644 --- a/src/test/correct/syscall/clang_O2/syscall_gtirb.expected +++ b/src/test/correct/syscall/clang_O2/syscall_gtirb.expected @@ -1,8 +1,12 @@ +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R16: bv64; +var {:extern} R17: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1900bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } @@ -11,22 +15,19 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { - (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { + (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); @@ -34,8 +35,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -48,205 +49,61 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 69672bv64) == 0bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); - free requires (memory_load8_le(mem, 1900bv64) == 1bv8); - free requires (memory_load8_le(mem, 1901bv64) == 0bv8); - free requires (memory_load8_le(mem, 1902bv64) == 2bv8); - free requires (memory_load8_le(mem, 1903bv64) == 0bv8); + free requires (memory_load32_le(mem, 1900bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R16_2: bool; - var Gamma_R17_2: bool; - var R16_2: bv64; - var R17_2: bv64; $main$__0__$noLlJkgwRnOvXgJivIONmQ: - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := .L_610(R16_in, Gamma_R16_in); + assume {:captureState "$main$__0__$noLlJkgwRnOvXgJivIONmQ"} true; + call .L_610(); assume false; } -procedure .L_610(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 1900bv64) == 1bv8); - free requires (memory_load8_le(mem, 1901bv64) == 0bv8); - free requires (memory_load8_le(mem, 1902bv64) == 2bv8); - free requires (memory_load8_le(mem, 1903bv64) == 0bv8); +procedure .L_610(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; + free requires (memory_load32_le(mem, 1900bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69680bv64) == 69680bv64); -implementation .L_610(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation .L_610() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $.L_610$__0__$gey1dltDQsGWPLJ2NyIKRg: + assume {:captureState "$.L_610$__0__$gey1dltDQsGWPLJ2NyIKRg"} true; + R16, Gamma_R16 := 69632bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69648bv64), (gamma_load64(Gamma_mem, 69648bv64) || L(mem, 69648bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := fork(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69648bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 16bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 16bv64)) || L(mem, bvadd64(R16, 16bv64))); + R16, Gamma_R16 := bvadd64(R16, 16bv64), Gamma_R16; + call fork(); assume false; } -procedure fork(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - free requires (memory_load8_le(mem, 1900bv64) == 1bv8); - free requires (memory_load8_le(mem, 1901bv64) == 0bv8); - free requires (memory_load8_le(mem, 1902bv64) == 2bv8); - free requires (memory_load8_le(mem, 1903bv64) == 0bv8); +procedure fork(); + free requires (memory_load32_le(mem, 1900bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1872bv64); free requires (memory_load64_le(mem, 69072bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); free requires (memory_load64_le(mem, 69680bv64) == 69680bv64); - free ensures (memory_load8_le(mem, 1900bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1901bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1902bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1903bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1900bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); diff --git a/src/test/correct/syscall/gcc/syscall.expected b/src/test/correct/syscall/gcc/syscall.expected index c75acc620..9b5a6bfb5 100644 --- a/src/test/correct/syscall/gcc/syscall.expected +++ b/src/test/correct/syscall/gcc/syscall.expected @@ -1,28 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_R16: bool; var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} R16: bv64; var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1932bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -32,15 +28,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -51,27 +43,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); @@ -79,8 +64,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -93,188 +78,69 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure fork(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure fork(); modifies Gamma_R16, Gamma_R17, R16, R17; - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_R16, Gamma_R17, Gamma_stack, R16, R17, stack; +procedure main(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_stack, R0, R16, R17, R29, R30, R31, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17: bool; - var Gamma_R17_1: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_2: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29_3: bool; - var Gamma_R29_4: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30_3: bool; - var Gamma_R30_4: bool; - var Gamma_R31_3: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0_2: bv64; - var R0_3: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16: bv64; - var R16_1: bv64; - var R17: bv64; - var R17_1: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_2: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29_3: bv64; - var R29_4: bv64; - var R2_1: bv64; - var R3: bv64; - var R30_3: bv64; - var R30_4: bv64; - var R31_3: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; + var #4: bv64; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551576bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R1_in); - call R0_2, Gamma_R0_2, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_1, Gamma_R16_1, R17_1, Gamma_R17_1, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_2, Gamma_R1_2, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_3, Gamma_R29_3, R2_1, Gamma_R2_1, R30_3, Gamma_R30_3, R31_3, Gamma_R31_3, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := fork(R0_in, Gamma_R0_in, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, R16, Gamma_R16, R17, Gamma_R17, R18, Gamma_R18, R19, Gamma_R19, R1_in, Gamma_R1_in, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R31_in, R2, Gamma_R2, 1896bv64, true, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R31_in, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + assume {:captureState "lmain"} true; + #4, Gamma_#4 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002d8"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002de"} true; + R31, Gamma_R31 := #4, Gamma_#4; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%000002f0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%000002f8"} true; + R30, Gamma_R30 := 1896bv64, true; + call fork(); goto l00000302; l00000302: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_3, 44bv64), R0_2[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_3, 44bv64), Gamma_R0_2); - R0_3, Gamma_R0_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_3, 44bv64))), gamma_load32(Gamma_stack, bvadd64(R31_3, 44bv64)); - R29_4, Gamma_R29_4 := memory_load64_le(stack, R31_3), gamma_load64(Gamma_stack, R31_3); - R30_4, Gamma_R30_4 := memory_load64_le(stack, bvadd64(R31_3, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_3, 8bv64)); + assume {:captureState "l00000302"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000308"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 44bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 44bv64)); + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R29_out, R30_out, R31_out := R0_3, R29_4, R30_4, bvadd64(R31_3, 48bv64); - Gamma_R0_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := Gamma_R0_3, Gamma_R29_4, Gamma_R30_4, Gamma_R31_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/syscall/gcc/syscall_gtirb.expected b/src/test/correct/syscall/gcc/syscall_gtirb.expected index c94df9814..56a484a3f 100644 --- a/src/test/correct/syscall/gcc/syscall_gtirb.expected +++ b/src/test/correct/syscall/gcc/syscall_gtirb.expected @@ -1,28 +1,28 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1932bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -32,15 +32,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -51,27 +47,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); @@ -79,8 +68,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -93,227 +82,91 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure FUN_610(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); +procedure FUN_610(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation FUN_610(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation FUN_610() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $FUN_610$__0__$w_DgyGR~RVC8g46zYhiiEg: + assume {:captureState "$FUN_610$__0__$w_DgyGR~RVC8g46zYhiiEg"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69560bv64), (gamma_load64(Gamma_mem, 69560bv64) || L(mem, 69560bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := fork(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69560bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4024bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4024bv64)) || L(mem, bvadd64(R16, 4024bv64))); + R16, Gamma_R16 := bvadd64(R16, 4024bv64), Gamma_R16; + call fork(); assume false; } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R16, Gamma_R17, Gamma_R29, Gamma_R30, Gamma_R31, Gamma_mem, Gamma_stack, R0, R16, R17, R29, R30, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); + free ensures (Gamma_R29 == old(Gamma_R29)); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R29 == old(R29)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool, R29_in: bv64, Gamma_R29_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R29_out: bv64, Gamma_R29_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R16: bool; - var Gamma_R16_1: bool; - var Gamma_R17_1: bool; - var Gamma_R29_3: bool; - var Gamma_R30_3: bool; - var R0_2: bv64; - var R16: bv64; - var R16_1: bv64; - var R17_1: bv64; - var R29_3: bv64; - var R30_3: bv64; + var Cse0__5$0$0: bv64; + var Gamma_Cse0__5$0$0: bool; $main$__0__$B56wTC6STE~1xacxBcjikg: - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551568bv64), R29_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64), Gamma_R29_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551576bv64), R30_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64), Gamma_R30_in); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551584bv64), R1_in), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551584bv64), Gamma_R1_in); - call R16_1, Gamma_R16_1, R17_1, Gamma_R17_1 := FUN_610(R16, Gamma_R16); + assume {:captureState "$main$__0__$B56wTC6STE~1xacxBcjikg"} true; + Cse0__5$0$0, Gamma_Cse0__5$0$0 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; + stack, Gamma_stack := memory_store64_le(stack, Cse0__5$0$0, R29), gamma_store64(Gamma_stack, Cse0__5$0$0, Gamma_R29); + assume {:captureState "1876$1"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(Cse0__5$0$0, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(Cse0__5$0$0, 8bv64), Gamma_R30); + assume {:captureState "1876$2"} true; + R31, Gamma_R31 := Cse0__5$0$0, Gamma_Cse0__5$0$0; + R29, Gamma_R29 := R31, Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1884$0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "1888$0"} true; + R30, Gamma_R30 := 1896bv64, true; + call FUN_610(); goto $main$__1__$gXScKm7ETUm9MNcMqMU~Og; $main$__1__$gXScKm7ETUm9MNcMqMU~Og: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_in); - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - R29_3, Gamma_R29_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551568bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551568bv64)); - R30_3, Gamma_R30_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551576bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551576bv64)); + assume {:captureState "$main$__1__$gXScKm7ETUm9MNcMqMU~Og"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "1896$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 44bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 44bv64)); + R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); + R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R16_out, R17_out, R29_out, R30_out, R31_out := R0_2, R16_1, R17_1, R29_3, R30_3, R31_in; - Gamma_R0_out, Gamma_R16_out, Gamma_R17_out, Gamma_R29_out, Gamma_R30_out, Gamma_R31_out := Gamma_R0_2, Gamma_R16_1, Gamma_R17_1, Gamma_R29_3, Gamma_R30_3, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } -procedure fork(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); +procedure fork(); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); diff --git a/src/test/correct/syscall/gcc_O2/syscall.expected b/src/test/correct/syscall/gcc_O2/syscall.expected index 4c308f6a8..fef381e05 100644 --- a/src/test/correct/syscall/gcc_O2/syscall.expected +++ b/src/test/correct/syscall/gcc_O2/syscall.expected @@ -7,22 +7,19 @@ var {:extern} mem: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1960bv64); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { - (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { + (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69008bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1600bv64); @@ -30,8 +27,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -44,22 +41,16 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure fork(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); +procedure fork(); modifies Gamma_R16, Gamma_R17, R16, R17; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1960bv64) == 1bv8); - free requires (memory_load8_le(mem, 1961bv64) == 0bv8); - free requires (memory_load8_le(mem, 1962bv64) == 2bv8); - free requires (memory_load8_le(mem, 1963bv64) == 0bv8); + free requires (memory_load32_le(mem, 1960bv64) == 131073bv32); free requires (memory_load64_le(mem, 69008bv64) == 1936bv64); free requires (memory_load64_le(mem, 69016bv64) == 1856bv64); free requires (memory_load64_le(mem, 69616bv64) == 1600bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69008bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1600bv64); diff --git a/src/test/correct/syscall/gcc_O2/syscall_gtirb.expected b/src/test/correct/syscall/gcc_O2/syscall_gtirb.expected index 801dbd10a..c8f72f876 100644 --- a/src/test/correct/syscall/gcc_O2/syscall_gtirb.expected +++ b/src/test/correct/syscall/gcc_O2/syscall_gtirb.expected @@ -1,8 +1,12 @@ +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R16: bv64; +var {:extern} R17: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1960bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } @@ -11,22 +15,19 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { - (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { + (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69008bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1600bv64); @@ -34,8 +35,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -48,205 +49,61 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1960bv64) == 1bv8); - free requires (memory_load8_le(mem, 1961bv64) == 0bv8); - free requires (memory_load8_le(mem, 1962bv64) == 2bv8); - free requires (memory_load8_le(mem, 1963bv64) == 0bv8); + free requires (memory_load32_le(mem, 1960bv64) == 131073bv32); free requires (memory_load64_le(mem, 69008bv64) == 1936bv64); free requires (memory_load64_le(mem, 69016bv64) == 1856bv64); free requires (memory_load64_le(mem, 69616bv64) == 1600bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69008bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1600bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R16_2: bool; - var Gamma_R17_2: bool; - var R16_2: bv64; - var R17_2: bv64; $main$__0__$LN79XLVpSMWduuQh58xTyg: - call R16_2, Gamma_R16_2, R17_2, Gamma_R17_2 := .L_610(R16_in, Gamma_R16_in); + assume {:captureState "$main$__0__$LN79XLVpSMWduuQh58xTyg"} true; + call .L_610(); assume false; } -procedure .L_610(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool); - modifies Gamma_mem, mem; - free requires (memory_load8_le(mem, 1960bv64) == 1bv8); - free requires (memory_load8_le(mem, 1961bv64) == 0bv8); - free requires (memory_load8_le(mem, 1962bv64) == 2bv8); - free requires (memory_load8_le(mem, 1963bv64) == 0bv8); +procedure .L_610(); + modifies Gamma_R16, Gamma_R17, Gamma_mem, R16, R17, mem; + free requires (memory_load32_le(mem, 1960bv64) == 131073bv32); free requires (memory_load64_le(mem, 69008bv64) == 1936bv64); free requires (memory_load64_le(mem, 69016bv64) == 1856bv64); free requires (memory_load64_le(mem, 69616bv64) == 1600bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69008bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1600bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation .L_610(R16_in: bv64, Gamma_R16_in: bool) returns (R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool) +implementation .L_610() { - var Gamma_R0: bool; - var Gamma_R0_1: bool; - var Gamma_R1: bool; - var Gamma_R10: bool; - var Gamma_R10_1: bool; - var Gamma_R11: bool; - var Gamma_R11_1: bool; - var Gamma_R12: bool; - var Gamma_R12_1: bool; - var Gamma_R13: bool; - var Gamma_R13_1: bool; - var Gamma_R14: bool; - var Gamma_R14_1: bool; - var Gamma_R15: bool; - var Gamma_R15_1: bool; - var Gamma_R16_4: bool; - var Gamma_R17_1: bool; - var Gamma_R17_2: bool; - var Gamma_R18: bool; - var Gamma_R18_1: bool; - var Gamma_R19: bool; - var Gamma_R19_1: bool; - var Gamma_R1_1: bool; - var Gamma_R2: bool; - var Gamma_R20: bool; - var Gamma_R20_1: bool; - var Gamma_R21: bool; - var Gamma_R21_1: bool; - var Gamma_R22: bool; - var Gamma_R22_1: bool; - var Gamma_R23: bool; - var Gamma_R23_1: bool; - var Gamma_R24: bool; - var Gamma_R24_1: bool; - var Gamma_R25: bool; - var Gamma_R25_1: bool; - var Gamma_R26: bool; - var Gamma_R26_1: bool; - var Gamma_R27: bool; - var Gamma_R27_1: bool; - var Gamma_R28: bool; - var Gamma_R28_1: bool; - var Gamma_R29: bool; - var Gamma_R29_1: bool; - var Gamma_R2_1: bool; - var Gamma_R3: bool; - var Gamma_R30: bool; - var Gamma_R30_1: bool; - var Gamma_R31: bool; - var Gamma_R31_1: bool; - var Gamma_R3_1: bool; - var Gamma_R4: bool; - var Gamma_R4_1: bool; - var Gamma_R5: bool; - var Gamma_R5_1: bool; - var Gamma_R6: bool; - var Gamma_R6_1: bool; - var Gamma_R7: bool; - var Gamma_R7_1: bool; - var Gamma_R8: bool; - var Gamma_R8_1: bool; - var Gamma_R9: bool; - var Gamma_R9_1: bool; - var R0: bv64; - var R0_1: bv64; - var R1: bv64; - var R10: bv64; - var R10_1: bv64; - var R11: bv64; - var R11_1: bv64; - var R12: bv64; - var R12_1: bv64; - var R13: bv64; - var R13_1: bv64; - var R14: bv64; - var R14_1: bv64; - var R15: bv64; - var R15_1: bv64; - var R16_4: bv64; - var R17_1: bv64; - var R17_2: bv64; - var R18: bv64; - var R18_1: bv64; - var R19: bv64; - var R19_1: bv64; - var R1_1: bv64; - var R2: bv64; - var R20: bv64; - var R20_1: bv64; - var R21: bv64; - var R21_1: bv64; - var R22: bv64; - var R22_1: bv64; - var R23: bv64; - var R23_1: bv64; - var R24: bv64; - var R24_1: bv64; - var R25: bv64; - var R25_1: bv64; - var R26: bv64; - var R26_1: bv64; - var R27: bv64; - var R27_1: bv64; - var R28: bv64; - var R28_1: bv64; - var R29: bv64; - var R29_1: bv64; - var R2_1: bv64; - var R3: bv64; - var R30: bv64; - var R30_1: bv64; - var R31: bv64; - var R31_1: bv64; - var R3_1: bv64; - var R4: bv64; - var R4_1: bv64; - var R5: bv64; - var R5_1: bv64; - var R6: bv64; - var R6_1: bv64; - var R7: bv64; - var R7_1: bv64; - var R8: bv64; - var R8_1: bv64; - var R9: bv64; - var R9_1: bv64; $.L_610$__0__$RiGyG5O~QPG2HCmgeNO63Q: + assume {:captureState "$.L_610$__0__$RiGyG5O~QPG2HCmgeNO63Q"} true; + R16, Gamma_R16 := 65536bv64, true; call rely(); - R17_1, Gamma_R17_1 := memory_load64_le(mem, 69560bv64), (gamma_load64(Gamma_mem, 69560bv64) || L(mem, 69560bv64)); - call R0_1, Gamma_R0_1, R10_1, Gamma_R10_1, R11_1, Gamma_R11_1, R12_1, Gamma_R12_1, R13_1, Gamma_R13_1, R14_1, Gamma_R14_1, R15_1, Gamma_R15_1, R16_4, Gamma_R16_4, R17_2, Gamma_R17_2, R18_1, Gamma_R18_1, R19_1, Gamma_R19_1, R1_1, Gamma_R1_1, R20_1, Gamma_R20_1, R21_1, Gamma_R21_1, R22_1, Gamma_R22_1, R23_1, Gamma_R23_1, R24_1, Gamma_R24_1, R25_1, Gamma_R25_1, R26_1, Gamma_R26_1, R27_1, Gamma_R27_1, R28_1, Gamma_R28_1, R29_1, Gamma_R29_1, R2_1, Gamma_R2_1, R30_1, Gamma_R30_1, R31_1, Gamma_R31_1, R3_1, Gamma_R3_1, R4_1, Gamma_R4_1, R5_1, Gamma_R5_1, R6_1, Gamma_R6_1, R7_1, Gamma_R7_1, R8_1, Gamma_R8_1, R9_1, Gamma_R9_1 := fork(R0, Gamma_R0, R10, Gamma_R10, R11, Gamma_R11, R12, Gamma_R12, R13, Gamma_R13, R14, Gamma_R14, R15, Gamma_R15, 69560bv64, true, R17_1, Gamma_R17_1, R18, Gamma_R18, R19, Gamma_R19, R1, Gamma_R1, R20, Gamma_R20, R21, Gamma_R21, R22, Gamma_R22, R23, Gamma_R23, R24, Gamma_R24, R25, Gamma_R25, R26, Gamma_R26, R27, Gamma_R27, R28, Gamma_R28, R29, Gamma_R29, R2, Gamma_R2, R30, Gamma_R30, R31, Gamma_R31, R3, Gamma_R3, R4, Gamma_R4, R5, Gamma_R5, R6, Gamma_R6, R7, Gamma_R7, R8, Gamma_R8, R9, Gamma_R9); + R17, Gamma_R17 := memory_load64_le(mem, bvadd64(R16, 4024bv64)), (gamma_load64(Gamma_mem, bvadd64(R16, 4024bv64)) || L(mem, bvadd64(R16, 4024bv64))); + R16, Gamma_R16 := bvadd64(R16, 4024bv64), Gamma_R16; + call fork(); assume false; } -procedure fork(R0_in: bv64, Gamma_R0_in: bool, R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R12_in: bv64, Gamma_R12_in: bool, R13_in: bv64, Gamma_R13_in: bool, R14_in: bv64, Gamma_R14_in: bool, R15_in: bv64, Gamma_R15_in: bool, R16_in: bv64, Gamma_R16_in: bool, R17_in: bv64, Gamma_R17_in: bool, R18_in: bv64, Gamma_R18_in: bool, R19_in: bv64, Gamma_R19_in: bool, R1_in: bv64, Gamma_R1_in: bool, R20_in: bv64, Gamma_R20_in: bool, R21_in: bv64, Gamma_R21_in: bool, R22_in: bv64, Gamma_R22_in: bool, R23_in: bv64, Gamma_R23_in: bool, R24_in: bv64, Gamma_R24_in: bool, R25_in: bv64, Gamma_R25_in: bool, R26_in: bv64, Gamma_R26_in: bool, R27_in: bv64, Gamma_R27_in: bool, R28_in: bv64, Gamma_R28_in: bool, R29_in: bv64, Gamma_R29_in: bool, R2_in: bv64, Gamma_R2_in: bool, R30_in: bv64, Gamma_R30_in: bool, R31_in: bv64, Gamma_R31_in: bool, R3_in: bv64, Gamma_R3_in: bool, R4_in: bv64, Gamma_R4_in: bool, R5_in: bv64, Gamma_R5_in: bool, R6_in: bv64, Gamma_R6_in: bool, R7_in: bv64, Gamma_R7_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R12_out: bv64, Gamma_R12_out: bool, R13_out: bv64, Gamma_R13_out: bool, R14_out: bv64, Gamma_R14_out: bool, R15_out: bv64, Gamma_R15_out: bool, R16_out: bv64, Gamma_R16_out: bool, R17_out: bv64, Gamma_R17_out: bool, R18_out: bv64, Gamma_R18_out: bool, R19_out: bv64, Gamma_R19_out: bool, R1_out: bv64, Gamma_R1_out: bool, R20_out: bv64, Gamma_R20_out: bool, R21_out: bv64, Gamma_R21_out: bool, R22_out: bv64, Gamma_R22_out: bool, R23_out: bv64, Gamma_R23_out: bool, R24_out: bv64, Gamma_R24_out: bool, R25_out: bv64, Gamma_R25_out: bool, R26_out: bv64, Gamma_R26_out: bool, R27_out: bv64, Gamma_R27_out: bool, R28_out: bv64, Gamma_R28_out: bool, R29_out: bv64, Gamma_R29_out: bool, R2_out: bv64, Gamma_R2_out: bool, R30_out: bv64, Gamma_R30_out: bool, R31_out: bv64, Gamma_R31_out: bool, R3_out: bv64, Gamma_R3_out: bool, R4_out: bv64, Gamma_R4_out: bool, R5_out: bv64, Gamma_R5_out: bool, R6_out: bv64, Gamma_R6_out: bool, R7_out: bv64, Gamma_R7_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - free requires (memory_load8_le(mem, 1960bv64) == 1bv8); - free requires (memory_load8_le(mem, 1961bv64) == 0bv8); - free requires (memory_load8_le(mem, 1962bv64) == 2bv8); - free requires (memory_load8_le(mem, 1963bv64) == 0bv8); +procedure fork(); + free requires (memory_load32_le(mem, 1960bv64) == 131073bv32); free requires (memory_load64_le(mem, 69008bv64) == 1936bv64); free requires (memory_load64_le(mem, 69016bv64) == 1856bv64); free requires (memory_load64_le(mem, 69616bv64) == 1600bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1960bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1961bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1962bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1963bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1960bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69008bv64) == 1936bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1856bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1600bv64); diff --git a/src/test/correct/using_gamma_conditional/clang/using_gamma_conditional.expected b/src/test/correct/using_gamma_conditional/clang/using_gamma_conditional.expected index 053f9afb7..f85384bef 100644 --- a/src/test/correct/using_gamma_conditional/clang/using_gamma_conditional.expected +++ b/src/test/correct/using_gamma_conditional/clang/using_gamma_conditional.expected @@ -1,35 +1,42 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +47,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -87,71 +89,93 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_2: bool; - var Gamma_R8_7: bool; - var R0_1: bv64; - var R8_10: bv64; - var R8_2: bv32; - var R8_7: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f5"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000322, lmain_goto_l00000325; - lmain_goto_l00000325: - assume (R8_2 == 0bv32); - R8_7, Gamma_R8_7 := 1bv64, true; + l00000325: + assume {:captureState "l00000325"} true; + R8, Gamma_R8 := 1bv64, true; goto l00000328; - lmain_goto_l00000322: - assume (!(R8_2 == 0bv32)); - R8_7, Gamma_R8_7 := 0bv64, true; + l00000322: + assume {:captureState "l00000322"} true; + R8, Gamma_R8 := 0bv64, true; goto l00000328; l00000328: - assert Gamma_R8_7; + assume {:captureState "l00000328"} true; + assert Gamma_R8; goto l00000328_goto_l00000330, l00000328_goto_l00000358; - l00000328_goto_l00000358: - assume (!(R8_7[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_10, Gamma_R8_10 := R8_7, Gamma_R8_7; + l00000330: + assume {:captureState "l00000330"} true; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000340"} true; goto l00000343; - l00000328_goto_l00000330: - assume (R8_7[1:0] == 1bv1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_10, Gamma_R8_10 := 1bv64, true; + l00000358: + assume {:captureState "l00000358"} true; + goto l00000359; + l00000359: + assume {:captureState "l00000359"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000361"} true; goto l00000343; l00000343: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l00000343"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000322: + assume {:captureState "lmain_goto_l00000322"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000322; + lmain_goto_l00000325: + assume {:captureState "lmain_goto_l00000325"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000325; + l00000328_goto_l00000330: + assume {:captureState "l00000328_goto_l00000330"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l00000330; + l00000328_goto_l00000358: + assume {:captureState "l00000328_goto_l00000358"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000358; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_10; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_10; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_conditional/clang/using_gamma_conditional_gtirb.expected b/src/test/correct/using_gamma_conditional/clang/using_gamma_conditional_gtirb.expected index a07a216ba..f5400493a 100644 --- a/src/test/correct/using_gamma_conditional/clang/using_gamma_conditional_gtirb.expected +++ b/src/test/correct/using_gamma_conditional/clang/using_gamma_conditional_gtirb.expected @@ -1,35 +1,41 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,23 +46,17 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -87,84 +87,85 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_12: bool; - var Gamma_R8_2: bool; - var Gamma_R8_8: bool; - var R0_1: bv64; - var R8_10: bv64; - var R8_12: bv64; - var R8_2: bv32; - var R8_8: bv64; + var Cse0__5$3$4: bv32; + var Gamma_Cse0__5$3$4: bool; $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1816$0"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + Cse0__5$3$4, Gamma_Cse0__5$3$4 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$3$4, Cse0__5$3$4)), Gamma_Cse0__5$3$4; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$4), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$3$4); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$4, 0bv32), Gamma_Cse0__5$3$4; + NF, Gamma_NF := Cse0__5$3$4[32:31], Gamma_Cse0__5$3$4; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$3$4), Gamma_Cse0__5$3$4; + assert Gamma_ZF; goto $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__0, $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__1; - $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__1: - assume (R8_2 == 0bv32); - goto $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__1_phi_$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__3__$jjgsO_vVSHaixByd_HFc4w_phi_back_$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__3__$jjgsO_vVSHaixByd_HFc4w, $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__1_phi_$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__1__$xuuJL1lASei7mFxWPiiMDQ_phi_back_$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__1__$xuuJL1lASei7mFxWPiiMDQ; - $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__1_phi_$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__1__$xuuJL1lASei7mFxWPiiMDQ_phi_back_$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__1__$xuuJL1lASei7mFxWPiiMDQ: - R8_8, Gamma_R8_8 := 1bv64, true; - assert Gamma_R8_8; - goto $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__1__$xuuJL1lASei7mFxWPiiMDQ; - $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__1_phi_$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__3__$jjgsO_vVSHaixByd_HFc4w_phi_back_$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__3__$jjgsO_vVSHaixByd_HFc4w: - R8_10, Gamma_R8_10 := 1bv64, true; - assert Gamma_R8_10; - goto $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__3__$jjgsO_vVSHaixByd_HFc4w; - $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__0: - assume (!(R8_2 == 0bv32)); - goto $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__0_phi_back_$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__1__$xuuJL1lASei7mFxWPiiMDQ, $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__0_phi_back_$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__3__$jjgsO_vVSHaixByd_HFc4w; - $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__0_phi_back_$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__3__$jjgsO_vVSHaixByd_HFc4w: - R8_10, Gamma_R8_10 := 0bv64, true; - assert Gamma_R8_10; - goto $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__3__$jjgsO_vVSHaixByd_HFc4w; - $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__3__$jjgsO_vVSHaixByd_HFc4w: - assume (R8_10[1:0] == 1bv1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_12, Gamma_R8_12 := 1bv64, true; + $main$__1__$xuuJL1lASei7mFxWPiiMDQ: + assume {:captureState "$main$__1__$xuuJL1lASei7mFxWPiiMDQ"} true; + goto $main$__2__$lw6YF3ynQySaNA9zxekV6Q; + $main$__2__$lw6YF3ynQySaNA9zxekV6Q: + assume {:captureState "$main$__2__$lw6YF3ynQySaNA9zxekV6Q"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1844$0"} true; goto $main$__4__$iCJDxo4mS1WWxijWWu0_Pg; - $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__0_phi_back_$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__1__$xuuJL1lASei7mFxWPiiMDQ: - R8_8, Gamma_R8_8 := 0bv64, true; - assert Gamma_R8_8; - goto $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__1__$xuuJL1lASei7mFxWPiiMDQ; - $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__1__$xuuJL1lASei7mFxWPiiMDQ: - assume (!(R8_8[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_12, Gamma_R8_12 := R8_8, Gamma_R8_8; + $main$__3__$jjgsO_vVSHaixByd_HFc4w: + assume {:captureState "$main$__3__$jjgsO_vVSHaixByd_HFc4w"} true; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1856$0"} true; goto $main$__4__$iCJDxo4mS1WWxijWWu0_Pg; $main$__4__$iCJDxo4mS1WWxijWWu0_Pg: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__4__$iCJDxo4mS1WWxijWWu0_Pg"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__3__$jjgsO_vVSHaixByd_HFc4w: + assume {:captureState "$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__3__$jjgsO_vVSHaixByd_HFc4w"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$jjgsO_vVSHaixByd_HFc4w; + $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__1__$xuuJL1lASei7mFxWPiiMDQ: + assume {:captureState "$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__1__$xuuJL1lASei7mFxWPiiMDQ"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$xuuJL1lASei7mFxWPiiMDQ; + $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__0: + assume {:captureState "$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__0"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__3__$jjgsO_vVSHaixByd_HFc4w, $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__1__$xuuJL1lASei7mFxWPiiMDQ; + $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__1: + assume {:captureState "$main$__0__$2UJDyJD_RrSHL2vo1BbK8Q$__1"} true; + assume (!(!(ZF == 1bv1))); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__3__$jjgsO_vVSHaixByd_HFc4w, $main$__0__$2UJDyJD_RrSHL2vo1BbK8Q_goto_$main$__1__$xuuJL1lASei7mFxWPiiMDQ; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_12; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_12; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional.expected b/src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional.expected index 5f01e4f89..5bbfbd38f 100644 --- a/src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional.expected +++ b/src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional.expected @@ -1,14 +1,32 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -21,19 +39,14 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -64,52 +77,59 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure main(R8_in: bv64, Gamma_R8_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R8, VF, ZF, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_4: bool; - var Gamma_R8_3: bool; - var R0_4: bv64; - var R8_3: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l000002e5, lmain_goto_l000002e8; - lmain_goto_l000002e8: - assume (R8_3[32:0] == 0bv32); - R0_4, Gamma_R0_4 := 1bv64, true; + l000002e8: + assume {:captureState "l000002e8"} true; + R0, Gamma_R0 := 1bv64, true; goto l000002eb; - lmain_goto_l000002e5: - assume (!(R8_3[32:0] == 0bv32)); - R0_4, Gamma_R0_4 := 0bv64, true; + l000002e5: + assume {:captureState "l000002e5"} true; + R0, Gamma_R0 := 0bv64, true; goto l000002eb; l000002eb: + assume {:captureState "l000002eb"} true; goto main_basil_return; + lmain_goto_l000002e5: + assume {:captureState "lmain_goto_l000002e5"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l000002e5; + lmain_goto_l000002e8: + assume {:captureState "lmain_goto_l000002e8"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l000002e8; main_basil_return: - R0_out, R8_out := R0_4, R8_3; - Gamma_R0_out, Gamma_R8_out := Gamma_R0_4, Gamma_R8_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional_gtirb.expected b/src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional_gtirb.expected index 27d068c09..739f58556 100644 --- a/src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional_gtirb.expected +++ b/src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional_gtirb.expected @@ -1,14 +1,31 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -21,19 +38,13 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -64,50 +75,50 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure main(R8_in: bv64, Gamma_R8_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, R8, VF, ZF, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_4: bool; - var Gamma_R8_3: bool; - var R0_4: bv64; - var R8_3: bv64; + var Cse0__5$0$2: bv32; + var Gamma_Cse0__5$0$2: bool; $main$__0__$Xci9C6~RSgeAKtB8I~m3wg: + assume {:captureState "$main$__0__$Xci9C6~RSgeAKtB8I~m3wg"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + Cse0__5$0$2, Gamma_Cse0__5$0$2 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$0$2, Cse0__5$0$2)), Gamma_Cse0__5$0$2; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$0$2), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$0$2); + ZF, Gamma_ZF := bvcomp32(Cse0__5$0$2, 0bv32), Gamma_Cse0__5$0$2; + NF, Gamma_NF := Cse0__5$0$2[32:31], Gamma_Cse0__5$0$2; + assert Gamma_ZF; goto $main$__0__$Xci9C6~RSgeAKtB8I~m3wg$__0, $main$__0__$Xci9C6~RSgeAKtB8I~m3wg$__1; - $main$__0__$Xci9C6~RSgeAKtB8I~m3wg$__1: - assume (R8_3[32:0] == 0bv32); - R0_4, Gamma_R0_4 := 1bv64, true; - goto main_basil_return; $main$__0__$Xci9C6~RSgeAKtB8I~m3wg$__0: - assume (!(R8_3[32:0] == 0bv32)); - R0_4, Gamma_R0_4 := 0bv64, true; + assume {:captureState "$main$__0__$Xci9C6~RSgeAKtB8I~m3wg$__0"} true; + assume (!(ZF == 1bv1)); + R0, Gamma_R0 := 0bv64, true; + goto main_basil_return; + $main$__0__$Xci9C6~RSgeAKtB8I~m3wg$__1: + assume {:captureState "$main$__0__$Xci9C6~RSgeAKtB8I~m3wg$__1"} true; + assume (!(!(ZF == 1bv1))); + R0, Gamma_R0 := 1bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out := R0_4, R8_3; - Gamma_R0_out, Gamma_R8_out := Gamma_R0_4, Gamma_R8_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional.expected b/src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional.expected index 050ddb860..6c064e72e 100644 --- a/src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional.expected +++ b/src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional.expected @@ -1,25 +1,36 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +40,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,28 +51,23 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -92,77 +94,97 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_8: bool; - var R0_1: bv64; - var R8_11: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_8: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f9"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l0000032d, lmain_goto_l00000330; - lmain_goto_l00000330: - assume (R8_3 == 0bv32); - R8_8, Gamma_R8_8 := 1bv64, true; + l00000330: + assume {:captureState "l00000330"} true; + R8, Gamma_R8 := 1bv64, true; goto l00000333; - lmain_goto_l0000032d: - assume (!(R8_3 == 0bv32)); - R8_8, Gamma_R8_8 := 0bv64, true; + l0000032d: + assume {:captureState "l0000032d"} true; + R8, Gamma_R8 := 0bv64, true; goto l00000333; l00000333: - assert Gamma_R8_8; + assume {:captureState "l00000333"} true; + assert Gamma_R8; goto l00000333_goto_l0000033b, l00000333_goto_l00000363; - l00000333_goto_l00000363: - assume (!(R8_8[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_11, Gamma_R8_11 := R8_8, Gamma_R8_8; + l0000033b: + assume {:captureState "l0000033b"} true; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%0000034b"} true; goto l0000034e; - l00000333_goto_l0000033b: - assume (R8_8[1:0] == 1bv1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_11, Gamma_R8_11 := 1bv64, true; + l00000363: + assume {:captureState "l00000363"} true; + goto l00000364; + l00000364: + assume {:captureState "l00000364"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%0000036c"} true; goto l0000034e; l0000034e: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l0000034e"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l0000032d: + assume {:captureState "lmain_goto_l0000032d"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l0000032d; + lmain_goto_l00000330: + assume {:captureState "lmain_goto_l00000330"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000330; + l00000333_goto_l0000033b: + assume {:captureState "l00000333_goto_l0000033b"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l0000033b; + l00000333_goto_l00000363: + assume {:captureState "l00000333_goto_l00000363"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000363; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_11; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_11; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional_gtirb.expected b/src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional_gtirb.expected index 16b630f46..bab1430f0 100644 --- a/src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional_gtirb.expected +++ b/src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional_gtirb.expected @@ -1,25 +1,35 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +39,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,28 +50,22 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -92,90 +92,89 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, VF, ZF, mem, stack; requires (gamma_load32(Gamma_mem, $x_addr) == true); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_1: bool; - var Gamma_R8_11: bool; - var Gamma_R8_13: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_9: bool; - var R0_1: bv64; - var R8_11: bv64; - var R8_13: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_9: bv64; + var Cse0__5$1$5: bv32; + var Gamma_Cse0__5$1$5: bool; $main$__0__$WvserH3~TZmxgcnn~OP60A: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assume {:captureState "$main$__0__$WvserH3~TZmxgcnn~OP60A"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1880$0"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + Cse0__5$1$5, Gamma_Cse0__5$1$5 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$1$5, Cse0__5$1$5)), Gamma_Cse0__5$1$5; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$1$5), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$1$5); + ZF, Gamma_ZF := bvcomp32(Cse0__5$1$5, 0bv32), Gamma_Cse0__5$1$5; + NF, Gamma_NF := Cse0__5$1$5[32:31], Gamma_Cse0__5$1$5; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$1$5), Gamma_Cse0__5$1$5; + assert Gamma_ZF; goto $main$__0__$WvserH3~TZmxgcnn~OP60A$__0, $main$__0__$WvserH3~TZmxgcnn~OP60A$__1; - $main$__0__$WvserH3~TZmxgcnn~OP60A$__1: - assume (R8_3 == 0bv32); - goto $main$__0__$WvserH3~TZmxgcnn~OP60A$__1_phi_$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__3__$GuPi8JNBSIam340giZcdIw_phi_back_$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__3__$GuPi8JNBSIam340giZcdIw, $main$__0__$WvserH3~TZmxgcnn~OP60A$__1_phi_$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ_phi_back_$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ; - $main$__0__$WvserH3~TZmxgcnn~OP60A$__1_phi_$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ_phi_back_$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ: - R8_9, Gamma_R8_9 := 1bv64, true; - assert Gamma_R8_9; - goto $main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ; - $main$__0__$WvserH3~TZmxgcnn~OP60A$__1_phi_$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__3__$GuPi8JNBSIam340giZcdIw_phi_back_$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__3__$GuPi8JNBSIam340giZcdIw: - R8_11, Gamma_R8_11 := 1bv64, true; - assert Gamma_R8_11; - goto $main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__3__$GuPi8JNBSIam340giZcdIw; - $main$__0__$WvserH3~TZmxgcnn~OP60A$__0: - assume (!(R8_3 == 0bv32)); - goto $main$__0__$WvserH3~TZmxgcnn~OP60A$__0_phi_back_$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ, $main$__0__$WvserH3~TZmxgcnn~OP60A$__0_phi_back_$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__3__$GuPi8JNBSIam340giZcdIw; - $main$__0__$WvserH3~TZmxgcnn~OP60A$__0_phi_back_$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__3__$GuPi8JNBSIam340giZcdIw: - R8_11, Gamma_R8_11 := 0bv64, true; - assert Gamma_R8_11; - goto $main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__3__$GuPi8JNBSIam340giZcdIw; - $main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__3__$GuPi8JNBSIam340giZcdIw: - assume (R8_11[1:0] == 1bv1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_13, Gamma_R8_13 := 1bv64, true; + $main$__1__$G0q4wFaXSHCrjXIW8xOBDQ: + assume {:captureState "$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ"} true; + goto $main$__2__$z5KdSl61QzyIK9muKLFxgQ; + $main$__2__$z5KdSl61QzyIK9muKLFxgQ: + assume {:captureState "$main$__2__$z5KdSl61QzyIK9muKLFxgQ"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1912$0"} true; goto $main$__4__$5nmLw0UdTXyYfW~alw3bBw; - $main$__0__$WvserH3~TZmxgcnn~OP60A$__0_phi_back_$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ: - R8_9, Gamma_R8_9 := 0bv64, true; - assert Gamma_R8_9; - goto $main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ; - $main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ: - assume (!(R8_9[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R8_13, Gamma_R8_13 := R8_9, Gamma_R8_9; + $main$__3__$GuPi8JNBSIam340giZcdIw: + assume {:captureState "$main$__3__$GuPi8JNBSIam340giZcdIw"} true; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1924$0"} true; goto $main$__4__$5nmLw0UdTXyYfW~alw3bBw; $main$__4__$5nmLw0UdTXyYfW~alw3bBw: - R0_1, Gamma_R0_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "$main$__4__$5nmLw0UdTXyYfW~alw3bBw"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__3__$GuPi8JNBSIam340giZcdIw: + assume {:captureState "$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__3__$GuPi8JNBSIam340giZcdIw"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$GuPi8JNBSIam340giZcdIw; + $main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ: + assume {:captureState "$main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$G0q4wFaXSHCrjXIW8xOBDQ; + $main$__0__$WvserH3~TZmxgcnn~OP60A$__0: + assume {:captureState "$main$__0__$WvserH3~TZmxgcnn~OP60A$__0"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__3__$GuPi8JNBSIam340giZcdIw, $main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ; + $main$__0__$WvserH3~TZmxgcnn~OP60A$__1: + assume {:captureState "$main$__0__$WvserH3~TZmxgcnn~OP60A$__1"} true; + assume (!(!(ZF == 1bv1))); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__3__$GuPi8JNBSIam340giZcdIw, $main$__0__$WvserH3~TZmxgcnn~OP60A_goto_$main$__1__$G0q4wFaXSHCrjXIW8xOBDQ; main_basil_return: - R0_out, R31_out, R8_out := R0_1, R31_in, R8_13; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_1, Gamma_R31_in, Gamma_R8_13; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_conditional/gcc/using_gamma_conditional.expected b/src/test/correct/using_gamma_conditional/gcc/using_gamma_conditional.expected index 47a26d845..d15546bc6 100644 --- a/src/test/correct/using_gamma_conditional/gcc/using_gamma_conditional.expected +++ b/src/test/correct/using_gamma_conditional/gcc/using_gamma_conditional.expected @@ -1,14 +1,30 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -21,18 +37,14 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -63,52 +75,60 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, VF, ZF, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool) +implementation main() { - var Gamma_R0_4: bool; - var Gamma_R0_8: bool; - var R0_4: bv32; - var R0_8: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l000002fa, lmain_goto_l00000309; - lmain_goto_l00000309: - assume (!(R0_4 == 0bv32)); - R0_8, Gamma_R0_8 := 0bv64, true; + l000002fa: + assume {:captureState "l000002fa"} true; + R0, Gamma_R0 := 1bv64, true; goto l00000304; - lmain_goto_l000002fa: - assume (R0_4 == 0bv32); - R0_8, Gamma_R0_8 := 1bv64, true; + l00000309: + assume {:captureState "l00000309"} true; + R0, Gamma_R0 := 0bv64, true; goto l00000304; l00000304: + assume {:captureState "l00000304"} true; goto main_basil_return; + lmain_goto_l000002fa: + assume {:captureState "lmain_goto_l000002fa"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l000002fa; + lmain_goto_l00000309: + assume {:captureState "lmain_goto_l00000309"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l00000309; main_basil_return: - R0_out := R0_8; - Gamma_R0_out := Gamma_R0_8; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_conditional/gcc/using_gamma_conditional_gtirb.expected b/src/test/correct/using_gamma_conditional/gcc/using_gamma_conditional_gtirb.expected index 9ac9aa57a..092d40222 100644 --- a/src/test/correct/using_gamma_conditional/gcc/using_gamma_conditional_gtirb.expected +++ b/src/test/correct/using_gamma_conditional/gcc/using_gamma_conditional_gtirb.expected @@ -1,14 +1,29 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -21,18 +36,13 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -63,52 +73,60 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, VF, ZF, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1868bv64) == 1bv8); - free requires (memory_load8_le(mem, 1869bv64) == 0bv8); - free requires (memory_load8_le(mem, 1870bv64) == 2bv8); - free requires (memory_load8_le(mem, 1871bv64) == 0bv8); + free requires (memory_load32_le(mem, 1868bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1868bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1869bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1870bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1871bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1868bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool) +implementation main() { - var Gamma_R0_4: bool; - var Gamma_R0_8: bool; - var R0_4: bv32; - var R0_8: bv64; + var Cse0__5$3$3: bv32; + var Gamma_Cse0__5$3$3: bool; $main$__0__$0Z93XS38RGCWcCuYAn4Wlg: + assume {:captureState "$main$__0__$0Z93XS38RGCWcCuYAn4Wlg"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$3$3, Gamma_Cse0__5$3$3 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$3$3, Cse0__5$3$3)), Gamma_Cse0__5$3$3; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$3), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$3$3); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$3, 0bv32), Gamma_Cse0__5$3$3; + NF, Gamma_NF := Cse0__5$3$3[32:31], Gamma_Cse0__5$3$3; + assert Gamma_ZF; goto $main$__0__$0Z93XS38RGCWcCuYAn4Wlg_goto_$main$__2__$dFUCtpaoQFSZ3wSzJ5ELFA, $main$__0__$0Z93XS38RGCWcCuYAn4Wlg_goto_$main$__1__$Nfpd5K~xSA6Q~xrcC34K8w; - $main$__0__$0Z93XS38RGCWcCuYAn4Wlg_goto_$main$__1__$Nfpd5K~xSA6Q~xrcC34K8w: - assume (!(R0_4 == 0bv32)); - R0_8, Gamma_R0_8 := 0bv64, true; + $main$__1__$Nfpd5K~xSA6Q~xrcC34K8w: + assume {:captureState "$main$__1__$Nfpd5K~xSA6Q~xrcC34K8w"} true; + R0, Gamma_R0 := 0bv64, true; goto $main$__3__$R27N5eQARYq8nJdevhUAeQ; - $main$__0__$0Z93XS38RGCWcCuYAn4Wlg_goto_$main$__2__$dFUCtpaoQFSZ3wSzJ5ELFA: - assume (R0_4 == 0bv32); - R0_8, Gamma_R0_8 := 1bv64, true; + $main$__2__$dFUCtpaoQFSZ3wSzJ5ELFA: + assume {:captureState "$main$__2__$dFUCtpaoQFSZ3wSzJ5ELFA"} true; + R0, Gamma_R0 := 1bv64, true; goto $main$__3__$R27N5eQARYq8nJdevhUAeQ; $main$__3__$R27N5eQARYq8nJdevhUAeQ: + assume {:captureState "$main$__3__$R27N5eQARYq8nJdevhUAeQ"} true; goto main_basil_return; + $main$__0__$0Z93XS38RGCWcCuYAn4Wlg_goto_$main$__2__$dFUCtpaoQFSZ3wSzJ5ELFA: + assume {:captureState "$main$__0__$0Z93XS38RGCWcCuYAn4Wlg_goto_$main$__2__$dFUCtpaoQFSZ3wSzJ5ELFA"} true; + assume (ZF == 1bv1); + goto $main$__2__$dFUCtpaoQFSZ3wSzJ5ELFA; + $main$__0__$0Z93XS38RGCWcCuYAn4Wlg_goto_$main$__1__$Nfpd5K~xSA6Q~xrcC34K8w: + assume {:captureState "$main$__0__$0Z93XS38RGCWcCuYAn4Wlg_goto_$main$__1__$Nfpd5K~xSA6Q~xrcC34K8w"} true; + assume (!(ZF == 1bv1)); + goto $main$__1__$Nfpd5K~xSA6Q~xrcC34K8w; main_basil_return: - R0_out := R0_8; - Gamma_R0_out := Gamma_R0_8; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_conditional/gcc_pic/using_gamma_conditional.expected b/src/test/correct/using_gamma_conditional/gcc_pic/using_gamma_conditional.expected index 17e4f4d50..e36ae841a 100644 --- a/src/test/correct/using_gamma_conditional/gcc_pic/using_gamma_conditional.expected +++ b/src/test/correct/using_gamma_conditional/gcc_pic/using_gamma_conditional.expected @@ -1,14 +1,30 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -25,23 +41,19 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -68,58 +80,63 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, VF, ZF, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_8: bool; - var R0_3: bv64; - var R0_4: bv32; - var R0_8: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, R0_3), (gamma_load32(Gamma_mem, R0_3) || L(mem, R0_3)); - assert Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l000002fb, lmain_goto_l0000030a; - lmain_goto_l0000030a: - assume (!(R0_4 == 0bv32)); - R0_8, Gamma_R0_8 := 0bv64, true; + l000002fb: + assume {:captureState "l000002fb"} true; + R0, Gamma_R0 := 1bv64, true; goto l00000305; - lmain_goto_l000002fb: - assume (R0_4 == 0bv32); - R0_8, Gamma_R0_8 := 1bv64, true; + l0000030a: + assume {:captureState "l0000030a"} true; + R0, Gamma_R0 := 0bv64, true; goto l00000305; l00000305: + assume {:captureState "l00000305"} true; goto main_basil_return; + lmain_goto_l000002fb: + assume {:captureState "lmain_goto_l000002fb"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l000002fb; + lmain_goto_l0000030a: + assume {:captureState "lmain_goto_l0000030a"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l0000030a; main_basil_return: - R0_out := R0_8; - Gamma_R0_out := Gamma_R0_8; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_conditional/gcc_pic/using_gamma_conditional_gtirb.expected b/src/test/correct/using_gamma_conditional/gcc_pic/using_gamma_conditional_gtirb.expected index 2f615d045..b1b14067c 100644 --- a/src/test/correct/using_gamma_conditional/gcc_pic/using_gamma_conditional_gtirb.expected +++ b/src/test/correct/using_gamma_conditional/gcc_pic/using_gamma_conditional_gtirb.expected @@ -1,14 +1,29 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -25,23 +40,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -68,58 +78,63 @@ implementation {:extern} guarantee_reflexive() assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_VF, Gamma_ZF, Gamma_mem, NF, R0, VF, ZF, mem; requires (gamma_load32(Gamma_mem, $x_addr) == true); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1932bv64) == 1bv8); - free requires (memory_load8_le(mem, 1933bv64) == 0bv8); - free requires (memory_load8_le(mem, 1934bv64) == 2bv8); - free requires (memory_load8_le(mem, 1935bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1932bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1932bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1933bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1934bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1935bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1932bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_4: bool; - var Gamma_R0_8: bool; - var R0_3: bv64; - var R0_4: bv32; - var R0_8: bv64; + var Cse0__5$3$3: bv32; + var Gamma_Cse0__5$3$3: bool; $main$__0__$0opbVr6FSKqk~SauZFq~bg: + assume {:captureState "$main$__0__$0opbVr6FSKqk~SauZFq~bg"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_4, Gamma_R0_4 := memory_load32_le(mem, R0_3), (gamma_load32(Gamma_mem, R0_3) || L(mem, R0_3)); - assert Gamma_R0_4; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$3$3, Gamma_Cse0__5$3$3 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$3$3, Cse0__5$3$3)), Gamma_Cse0__5$3$3; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$3), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$3$3); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$3, 0bv32), Gamma_Cse0__5$3$3; + NF, Gamma_NF := Cse0__5$3$3[32:31], Gamma_Cse0__5$3$3; + assert Gamma_ZF; goto $main$__0__$0opbVr6FSKqk~SauZFq~bg_goto_$main$__2__$PU15ptK8QmqsodwKTutr4A, $main$__0__$0opbVr6FSKqk~SauZFq~bg_goto_$main$__1__$MkdgQZmORkuq9AzG1tEbvg; - $main$__0__$0opbVr6FSKqk~SauZFq~bg_goto_$main$__1__$MkdgQZmORkuq9AzG1tEbvg: - assume (!(R0_4 == 0bv32)); - R0_8, Gamma_R0_8 := 0bv64, true; + $main$__1__$MkdgQZmORkuq9AzG1tEbvg: + assume {:captureState "$main$__1__$MkdgQZmORkuq9AzG1tEbvg"} true; + R0, Gamma_R0 := 0bv64, true; goto $main$__3__$rmk1cd0ERD~sxbsj_Z3~5Q; - $main$__0__$0opbVr6FSKqk~SauZFq~bg_goto_$main$__2__$PU15ptK8QmqsodwKTutr4A: - assume (R0_4 == 0bv32); - R0_8, Gamma_R0_8 := 1bv64, true; + $main$__2__$PU15ptK8QmqsodwKTutr4A: + assume {:captureState "$main$__2__$PU15ptK8QmqsodwKTutr4A"} true; + R0, Gamma_R0 := 1bv64, true; goto $main$__3__$rmk1cd0ERD~sxbsj_Z3~5Q; $main$__3__$rmk1cd0ERD~sxbsj_Z3~5Q: + assume {:captureState "$main$__3__$rmk1cd0ERD~sxbsj_Z3~5Q"} true; goto main_basil_return; + $main$__0__$0opbVr6FSKqk~SauZFq~bg_goto_$main$__2__$PU15ptK8QmqsodwKTutr4A: + assume {:captureState "$main$__0__$0opbVr6FSKqk~SauZFq~bg_goto_$main$__2__$PU15ptK8QmqsodwKTutr4A"} true; + assume (ZF == 1bv1); + goto $main$__2__$PU15ptK8QmqsodwKTutr4A; + $main$__0__$0opbVr6FSKqk~SauZFq~bg_goto_$main$__1__$MkdgQZmORkuq9AzG1tEbvg: + assume {:captureState "$main$__0__$0opbVr6FSKqk~SauZFq~bg_goto_$main$__1__$MkdgQZmORkuq9AzG1tEbvg"} true; + assume (!(ZF == 1bv1)); + goto $main$__1__$MkdgQZmORkuq9AzG1tEbvg; main_basil_return: - R0_out := R0_8; - Gamma_R0_out := Gamma_R0_8; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_write_z/clang/using_gamma_write_z.expected b/src/test/correct/using_gamma_write_z/clang/using_gamma_write_z.expected index 737601deb..9d59e8152 100644 --- a/src/test/correct/using_gamma_write_z/clang/using_gamma_write_z.expected +++ b/src/test/correct/using_gamma_write_z/clang/using_gamma_write_z.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,22 +31,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -84,42 +70,39 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires ((memory_load32_le(mem, $z_addr) == 0bv32) ==> gamma_load32(Gamma_mem, $x_addr)); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var Gamma_x_old: bool; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); - assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + assume {:captureState "%000002ce"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 1bv64, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_write_z/clang/using_gamma_write_z_gtirb.expected b/src/test/correct/using_gamma_write_z/clang/using_gamma_write_z_gtirb.expected index c52bcbabd..740065fd5 100644 --- a/src/test/correct/using_gamma_write_z/clang/using_gamma_write_z_gtirb.expected +++ b/src/test/correct/using_gamma_write_z/clang/using_gamma_write_z_gtirb.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,22 +31,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -84,42 +70,39 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires ((memory_load32_le(mem, $z_addr) == 0bv32) ==> gamma_load32(Gamma_mem, $x_addr)); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1852bv64) == 1bv8); - free requires (memory_load8_le(mem, 1853bv64) == 0bv8); - free requires (memory_load8_le(mem, 1854bv64) == 2bv8); - free requires (memory_load8_le(mem, 1855bv64) == 0bv8); + free requires (memory_load32_le(mem, 1852bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1852bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1853bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1854bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1855bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1852bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { var Gamma_x_old: bool; $main$__0__$ap7BIakXQIKH6aKZFtlpAw: + assume {:captureState "$main$__0__$ap7BIakXQIKH6aKZFtlpAw"} true; + R9, Gamma_R9 := 69632bv64, true; + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> true); + assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, 1bv32), gamma_store32(Gamma_mem, 69684bv64, true); - assert ((69684bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); - assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + assume {:captureState "1820$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 1bv64, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z.expected b/src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z.expected index 6d695e426..8525eea2b 100644 --- a/src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z.expected +++ b/src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z.expected @@ -1,23 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +24,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,27 +35,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -89,48 +75,43 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires ((memory_load32_le(mem, $z_addr) == 0bv32) ==> gamma_load32(Gamma_mem, $x_addr)); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R9_3: bool; var Gamma_x_old: bool; - var R9_3: bv64; lmain: + assume {:captureState "lmain"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> Gamma_R8); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 1bv32), gamma_store32(Gamma_mem, R9_3, true); - assert ((R9_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); - assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + assume {:captureState "%000002d9"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 1bv64, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z_gtirb.expected b/src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z_gtirb.expected index 2266a9a80..8062aae34 100644 --- a/src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z_gtirb.expected +++ b/src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z_gtirb.expected @@ -1,23 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +24,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,27 +35,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -89,48 +75,43 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; requires ((memory_load32_le(mem, $z_addr) == 0bv32) ==> gamma_load32(Gamma_mem, $x_addr)); free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); free requires (memory_load64_le(mem, 69056bv64) == 1872bv64); free requires (memory_load64_le(mem, 69064bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69056bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69064bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R9_3: bool; var Gamma_x_old: bool; - var R9_3: bv64; $main$__0__$biI7cD_YRjyqxfg99RZiSw: + assume {:captureState "$main$__0__$biI7cD_YRjyqxfg99RZiSw"} true; + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); + R8, Gamma_R8 := 1bv64, true; call rely(); - assert (L(mem, R9_3) ==> true); + assert (L(mem, R9) ==> Gamma_R8); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R9_3, 1bv32), gamma_store32(Gamma_mem, R9_3, true); - assert ((R9_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); - assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + assume {:captureState "1888$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, 1bv64, R9_3; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z.expected b/src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z.expected index 2b306dcd7..2fe980180 100644 --- a/src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z.expected +++ b/src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,22 +29,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -84,42 +68,40 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires ((memory_load32_le(mem, $z_addr) == 0bv32) ==> gamma_load32(Gamma_mem, $x_addr)); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { var Gamma_x_old: bool; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 1bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); - assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + assume {:captureState "%000002d8"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z_gtirb.expected b/src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z_gtirb.expected index 3874f3820..da53252e5 100644 --- a/src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z_gtirb.expected +++ b/src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z_gtirb.expected @@ -1,33 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,22 +29,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -84,42 +68,40 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires ((memory_load32_le(mem, $z_addr) == 0bv32) ==> gamma_load32(Gamma_mem, $x_addr)); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { var Gamma_x_old: bool; $main$__0__$nQskxO9URuKUrmpkeGLfhQ: + assume {:captureState "$main$__0__$nQskxO9URuKUrmpkeGLfhQ"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, 69656bv64) ==> true); + assert (L(mem, R0) ==> Gamma_R1); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, 1bv32), gamma_store32(Gamma_mem, 69656bv64, true); - assert ((69656bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); - assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z.expected b/src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z.expected index 0ebb4b62d..d253f2a2e 100644 --- a/src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z.expected +++ b/src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,22 +31,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -84,42 +70,39 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; requires ((memory_load32_le(mem, $z_addr) == 0bv32) ==> gamma_load32(Gamma_mem, $x_addr)); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { var Gamma_x_old: bool; lmain: + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := 1bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); - assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); + assert ((bvadd64(R1, 20bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + assume {:captureState "%000001bd"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z_gtirb.expected b/src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z_gtirb.expected index 63d4ae83f..0f13da53f 100644 --- a/src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z_gtirb.expected +++ b/src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z_gtirb.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,22 +31,15 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -84,42 +70,39 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; requires ((memory_load32_le(mem, $z_addr) == 0bv32) ==> gamma_load32(Gamma_mem, $x_addr)); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { var Gamma_x_old: bool; $main$__0__$5Y8e~5V6Ssy1xVGyOZzCzw: + assume {:captureState "$main$__0__$5Y8e~5V6Ssy1xVGyOZzCzw"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := 1bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69652bv64) ==> true); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 1bv32), gamma_store32(Gamma_mem, 69652bv64, true); - assert ((69652bv64 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); - assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); + assert ((bvadd64(R1, 20bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + assume {:captureState "1548$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z.expected b/src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z.expected index 758399338..23cde8fa0 100644 --- a/src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z.expected +++ b/src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z.expected @@ -1,23 +1,18 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +22,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,27 +33,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -89,48 +73,43 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires ((memory_load32_le(mem, $z_addr) == 0bv32) ==> gamma_load32(Gamma_mem, $x_addr)); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; var Gamma_x_old: bool; - var R0_3: bv64; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> Gamma_R1); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); - assert ((R0_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); - assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + assume {:captureState "%000002d9"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z_gtirb.expected b/src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z_gtirb.expected index 4fdbb1e25..e70802918 100644 --- a/src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z_gtirb.expected +++ b/src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z_gtirb.expected @@ -1,23 +1,18 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { - (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { + (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(mem$in, $z_addr) == 0bv32) else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +22,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,27 +33,20 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -89,48 +73,43 @@ implementation {:extern} guarantee_reflexive() assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; requires ((memory_load32_le(mem, $z_addr) == 0bv32) ==> gamma_load32(Gamma_mem, $x_addr)); free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1920bv64) == 1bv8); - free requires (memory_load8_le(mem, 1921bv64) == 0bv8); - free requires (memory_load8_le(mem, 1922bv64) == 2bv8); - free requires (memory_load8_le(mem, 1923bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1920bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); free requires (memory_load64_le(mem, 69016bv64) == 1792bv64); free requires (memory_load64_le(mem, 69600bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69008bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1920bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1921bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1922bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1923bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 1920bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69016bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69600bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69008bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_3: bool; var Gamma_x_old: bool; - var R0_3: bv64; $main$__0__$wzE5390IST~kmbO~2Ze3Kw: + assume {:captureState "$main$__0__$wzE5390IST~kmbO~2Ze3Kw"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := 1bv64, true; call rely(); - assert (L(mem, R0_3) ==> true); + assert (L(mem, R0) ==> Gamma_R1); Gamma_x_old := (gamma_load32(Gamma_mem, $x_addr) || L(mem, $x_addr)); - mem, Gamma_mem := memory_store32_le(mem, R0_3, 1bv32), gamma_store32(Gamma_mem, R0_3, true); - assert ((R0_3 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); - assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); + assume {:captureState "1888$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, 1bv64; - Gamma_R0_out, Gamma_R1_out := true, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic.adt b/src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic.adt new file mode 100755 index 000000000..b3975b7b4 --- /dev/null +++ b/src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic.adt @@ -0,0 +1,609 @@ +Project(Attrs([Attr("filename","interproc_pointer_arithmetic.out"), +Attr("image-specification","(declare abi (name str))\n(declare arch (name str))\n(declare base-address (addr int))\n(declare bias (off int))\n(declare bits (size int))\n(declare code-region (addr int) (size int) (off int))\n(declare code-start (addr int))\n(declare entry-point (addr int))\n(declare external-reference (addr int) (name str))\n(declare format (name str))\n(declare is-executable (flag bool))\n(declare is-little-endian (flag bool))\n(declare llvm:base-address (addr int))\n(declare llvm:code-entry (name str) (off int) (size int))\n(declare llvm:coff-import-library (name str))\n(declare llvm:coff-virtual-section-header (name str) (addr int) (size int))\n(declare llvm:elf-program-header (name str) (off int) (size int))\n(declare llvm:elf-program-header-flags (name str) (ld bool) (r bool) \n (w bool) (x bool))\n(declare llvm:elf-virtual-program-header (name str) (addr int) (size int))\n(declare llvm:entry-point (addr int))\n(declare llvm:macho-symbol (name str) (value int))\n(declare llvm:name-reference (at int) (name str))\n(declare llvm:relocation (at int) (addr int))\n(declare llvm:section-entry (name str) (addr int) (size int) (off int))\n(declare llvm:section-flags (name str) (r bool) (w bool) (x bool))\n(declare llvm:segment-command (name str) (off int) (size int))\n(declare llvm:segment-command-flags (name str) (r bool) (w bool) (x bool))\n(declare llvm:symbol-entry (name str) (addr int) (size int) (off int)\n (value int))\n(declare llvm:virtual-segment-command (name str) (addr int) (size int))\n(declare mapped (addr int) (size int) (off int))\n(declare named-region (addr int) (size int) (name str))\n(declare named-symbol (addr int) (name str))\n(declare require (name str))\n(declare section (addr int) (size int))\n(declare segment (addr int) (size int) (r bool) (w bool) (x bool))\n(declare subarch (name str))\n(declare symbol-chunk (addr int) (size int) (root int))\n(declare symbol-value (addr int) (value int))\n(declare system (name str))\n(declare vendor (name str))\n\n(abi unknown)\n(arch aarch64)\n(base-address 0)\n(bias 0)\n(bits 64)\n(code-region 2000 20 2000)\n(code-region 1600 400 1600)\n(code-region 1488 112 1488)\n(code-region 1464 24 1464)\n(code-start 1652)\n(code-start 1600)\n(code-start 1908)\n(code-start 1876)\n(entry-point 1600)\n(external-reference 131032 _ITM_deregisterTMCloneTable)\n(external-reference 131040 __cxa_finalize)\n(external-reference 131048 __gmon_start__)\n(external-reference 131064 _ITM_registerTMCloneTable)\n(external-reference 130984 __libc_start_main)\n(external-reference 130992 __cxa_finalize)\n(external-reference 131000 malloc)\n(external-reference 131008 __gmon_start__)\n(external-reference 131016 abort)\n(format elf)\n(is-executable true)\n(is-little-endian true)\n(llvm:base-address 0)\n(llvm:code-entry abort 0 0)\n(llvm:code-entry malloc 0 0)\n(llvm:code-entry __cxa_finalize 0 0)\n(llvm:code-entry __libc_start_main 0 0)\n(llvm:code-entry _init 1464 0)\n(llvm:code-entry callee 1876 32)\n(llvm:code-entry main 1908 92)\n(llvm:code-entry _start 1600 52)\n(llvm:code-entry abort@GLIBC_2.17 0 0)\n(llvm:code-entry malloc@GLIBC_2.17 0 0)\n(llvm:code-entry _fini 2000 0)\n(llvm:code-entry __cxa_finalize@GLIBC_2.17 0 0)\n(llvm:code-entry __libc_start_main@GLIBC_2.34 0 0)\n(llvm:code-entry frame_dummy 1872 0)\n(llvm:code-entry __do_global_dtors_aux 1792 0)\n(llvm:code-entry register_tm_clones 1728 0)\n(llvm:code-entry deregister_tm_clones 1680 0)\n(llvm:code-entry call_weak_fn 1652 20)\n(llvm:code-entry .fini 2000 20)\n(llvm:code-entry .text 1600 400)\n(llvm:code-entry .plt 1488 112)\n(llvm:code-entry .init 1464 24)\n(llvm:elf-program-header 08 64912 624)\n(llvm:elf-program-header 07 0 0)\n(llvm:elf-program-header 06 2024 68)\n(llvm:elf-program-header 05 596 68)\n(llvm:elf-program-header 04 64928 496)\n(llvm:elf-program-header 03 64912 640)\n(llvm:elf-program-header 02 0 2292)\n(llvm:elf-program-header 01 568 27)\n(llvm:elf-program-header 00 64 504)\n(llvm:elf-program-header-flags 08 false true false false)\n(llvm:elf-program-header-flags 07 false true true false)\n(llvm:elf-program-header-flags 06 false true false false)\n(llvm:elf-program-header-flags 05 false true false false)\n(llvm:elf-program-header-flags 04 false true true false)\n(llvm:elf-program-header-flags 03 true true true false)\n(llvm:elf-program-header-flags 02 true true false true)\n(llvm:elf-program-header-flags 01 false true false false)\n(llvm:elf-program-header-flags 00 false true false false)\n(llvm:elf-virtual-program-header 08 130448 624)\n(llvm:elf-virtual-program-header 07 0 0)\n(llvm:elf-virtual-program-header 06 2024 68)\n(llvm:elf-virtual-program-header 05 596 68)\n(llvm:elf-virtual-program-header 04 130464 496)\n(llvm:elf-virtual-program-header 03 130448 648)\n(llvm:elf-virtual-program-header 02 0 2292)\n(llvm:elf-virtual-program-header 01 568 27)\n(llvm:elf-virtual-program-header 00 64 504)\n(llvm:entry-point 1600)\n(llvm:name-reference 131016 abort)\n(llvm:name-reference 131008 __gmon_start__)\n(llvm:name-reference 131000 malloc)\n(llvm:name-reference 130992 __cxa_finalize)\n(llvm:name-reference 130984 __libc_start_main)\n(llvm:name-reference 131064 _ITM_registerTMCloneTable)\n(llvm:name-reference 131048 __gmon_start__)\n(llvm:name-reference 131040 __cxa_finalize)\n(llvm:name-reference 131032 _ITM_deregisterTMCloneTable)\n(llvm:section-entry .shstrtab 0 250 68301)\n(llvm:section-entry .strtab 0 589 67712)\n(llvm:section-entry .symtab 0 2112 65600)\n(llvm:section-entry .comment 0 43 65552)\n(llvm:section-entry .bss 131088 8 65552)\n(llvm:section-entry .data 131072 16 65536)\n(llvm:section-entry .got 130960 112 65424)\n(llvm:section-entry .dynamic 130464 496 64928)\n(llvm:section-entry .fini_array 130456 8 64920)\n(llvm:section-entry .init_array 130448 8 64912)\n(llvm:section-entry .eh_frame 2096 196 2096)\n(llvm:section-entry .eh_frame_hdr 2024 68 2024)\n(llvm:section-entry .rodata 2020 4 2020)\n(llvm:section-entry .fini 2000 20 2000)\n(llvm:section-entry .text 1600 400 1600)\n(llvm:section-entry .plt 1488 112 1488)\n(llvm:section-entry .init 1464 24 1464)\n(llvm:section-entry .rela.plt 1344 120 1344)\n(llvm:section-entry .rela.dyn 1152 192 1152)\n(llvm:section-entry .gnu.version_r 1104 48 1104)\n(llvm:section-entry .gnu.version 1084 20 1084)\n(llvm:section-entry .dynstr 936 148 936)\n(llvm:section-entry .dynsym 696 240 696)\n(llvm:section-entry .gnu.hash 664 28 664)\n(llvm:section-entry .note.ABI-tag 632 32 632)\n(llvm:section-entry .note.gnu.build-id 596 36 596)\n(llvm:section-entry .interp 568 27 568)\n(llvm:section-flags .shstrtab true false false)\n(llvm:section-flags .strtab true false false)\n(llvm:section-flags .symtab true false false)\n(llvm:section-flags .comment true false false)\n(llvm:section-flags .bss true true false)\n(llvm:section-flags .data true true false)\n(llvm:section-flags .got true true false)\n(llvm:section-flags .dynamic true true false)\n(llvm:section-flags .fini_array true true false)\n(llvm:section-flags .init_array true true false)\n(llvm:section-flags .eh_frame true false false)\n(llvm:section-flags .eh_frame_hdr true false false)\n(llvm:section-flags .rodata true false false)\n(llvm:section-flags .fini true false true)\n(llvm:section-flags .text true false true)\n(llvm:section-flags .plt true false true)\n(llvm:section-flags .init true false true)\n(llvm:section-flags .rela.plt true false false)\n(llvm:section-flags .rela.dyn true false false)\n(llvm:section-flags .gnu.version_r true false false)\n(llvm:section-flags .gnu.version true false false)\n(llvm:section-flags .dynstr true false false)\n(llvm:section-flags .dynsym true false false)\n(llvm:section-flags .gnu.hash true false false)\n(llvm:section-flags .note.ABI-tag true false false)\n(llvm:section-flags .note.gnu.build-id true false false)\n(llvm:section-flags .interp true false false)\n(llvm:symbol-entry abort 0 0 0 0)\n(llvm:symbol-entry malloc 0 0 0 0)\n(llvm:symbol-entry __cxa_finalize 0 0 0 0)\n(llvm:symbol-entry __libc_start_main 0 0 0 0)\n(llvm:symbol-entry _init 1464 0 1464 1464)\n(llvm:symbol-entry callee 1876 32 1876 1876)\n(llvm:symbol-entry main 1908 92 1908 1908)\n(llvm:symbol-entry _start 1600 52 1600 1600)\n(llvm:symbol-entry abort@GLIBC_2.17 0 0 0 0)\n(llvm:symbol-entry malloc@GLIBC_2.17 0 0 0 0)\n(llvm:symbol-entry _fini 2000 0 2000 2000)\n(llvm:symbol-entry __cxa_finalize@GLIBC_2.17 0 0 0 0)\n(llvm:symbol-entry __libc_start_main@GLIBC_2.34 0 0 0 0)\n(llvm:symbol-entry frame_dummy 1872 0 1872 1872)\n(llvm:symbol-entry __do_global_dtors_aux 1792 0 1792 1792)\n(llvm:symbol-entry register_tm_clones 1728 0 1728 1728)\n(llvm:symbol-entry deregister_tm_clones 1680 0 1680 1680)\n(llvm:symbol-entry call_weak_fn 1652 20 1652 1652)\n(mapped 0 2292 0)\n(mapped 130448 640 64912)\n(named-region 0 2292 02)\n(named-region 130448 648 03)\n(named-region 568 27 .interp)\n(named-region 596 36 .note.gnu.build-id)\n(named-region 632 32 .note.ABI-tag)\n(named-region 664 28 .gnu.hash)\n(named-region 696 240 .dynsym)\n(named-region 936 148 .dynstr)\n(named-region 1084 20 .gnu.version)\n(named-region 1104 48 .gnu.version_r)\n(named-region 1152 192 .rela.dyn)\n(named-region 1344 120 .rela.plt)\n(named-region 1464 24 .init)\n(named-region 1488 112 .plt)\n(named-region 1600 400 .text)\n(named-region 2000 20 .fini)\n(named-region 2020 4 .rodata)\n(named-region 2024 68 .eh_frame_hdr)\n(named-region 2096 196 .eh_frame)\n(named-region 130448 8 .init_array)\n(named-region 130456 8 .fini_array)\n(named-region 130464 496 .dynamic)\n(named-region 130960 112 .got)\n(named-region 131072 16 .data)\n(named-region 131088 8 .bss)\n(named-region 0 43 .comment)\n(named-region 0 2112 .symtab)\n(named-region 0 589 .strtab)\n(named-region 0 250 .shstrtab)\n(named-symbol 1652 call_weak_fn)\n(named-symbol 1680 deregister_tm_clones)\n(named-symbol 1728 register_tm_clones)\n(named-symbol 1792 __do_global_dtors_aux)\n(named-symbol 1872 frame_dummy)\n(named-symbol 0 __libc_start_main@GLIBC_2.34)\n(named-symbol 0 __cxa_finalize@GLIBC_2.17)\n(named-symbol 2000 _fini)\n(named-symbol 0 malloc@GLIBC_2.17)\n(named-symbol 0 abort@GLIBC_2.17)\n(named-symbol 1600 _start)\n(named-symbol 1908 main)\n(named-symbol 1876 callee)\n(named-symbol 1464 _init)\n(named-symbol 0 __libc_start_main)\n(named-symbol 0 __cxa_finalize)\n(named-symbol 0 malloc)\n(named-symbol 0 abort)\n(require libc.so.6)\n(section 568 27)\n(section 596 36)\n(section 632 32)\n(section 664 28)\n(section 696 240)\n(section 936 148)\n(section 1084 20)\n(section 1104 48)\n(section 1152 192)\n(section 1344 120)\n(section 1464 24)\n(section 1488 112)\n(section 1600 400)\n(section 2000 20)\n(section 2020 4)\n(section 2024 68)\n(section 2096 196)\n(section 130448 8)\n(section 130456 8)\n(section 130464 496)\n(section 130960 112)\n(section 131072 16)\n(section 131088 8)\n(section 0 43)\n(section 0 2112)\n(section 0 589)\n(section 0 250)\n(segment 0 2292 true false true)\n(segment 130448 648 true true false)\n(subarch v8)\n(symbol-chunk 1652 20 1652)\n(symbol-chunk 1600 52 1600)\n(symbol-chunk 1908 92 1908)\n(symbol-chunk 1876 32 1876)\n(symbol-value 1652 1652)\n(symbol-value 1680 1680)\n(symbol-value 1728 1728)\n(symbol-value 1792 1792)\n(symbol-value 1872 1872)\n(symbol-value 2000 2000)\n(symbol-value 1600 1600)\n(symbol-value 1908 1908)\n(symbol-value 1876 1876)\n(symbol-value 1464 1464)\n(symbol-value 0 0)\n(system \"\")\n(vendor \"\")\n"), +Attr("abi-name","aarch64-linux-gnu-elf")]), +Sections([Section(".shstrtab", 0x0, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7\x00\x01\x00\x00\x00\x40\x06\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xc8\x0b\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x38\x00\x09\x00\x40\x00\x1c\x00\x1b\x00\x06\x00\x00\x00\x04\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x08\x00\x00\x00\x00\x00\x00\xf4\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x00\x00\x06\x00\x00\x00\x90\xfd\x00\x00\x00\x00\x00\x00\x90\xfd"), +Section(".strtab", 0x0, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7\x00\x01\x00\x00\x00\x40\x06\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xc8\x0b\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x38\x00\x09\x00\x40\x00\x1c\x00\x1b\x00\x06\x00\x00\x00\x04\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x08\x00\x00\x00\x00\x00\x00\xf4\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x00\x00\x06\x00\x00\x00\x90\xfd\x00\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x80\x02\x00\x00\x00\x00\x00\x00\x88\x02\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x02\x00\x00\x00\x06\x00\x00\x00\xa0\xfd\x00\x00\x00\x00\x00\x00\xa0\xfd\x01\x00\x00\x00\x00\x00\xa0\xfd\x01\x00\x00\x00\x00\x00\xf0\x01\x00\x00\x00\x00\x00\x00\xf0\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x50\xe5\x74\x64\x04\x00\x00\x00\xe8\x07\x00\x00\x00\x00\x00\x00\xe8\x07\x00\x00\x00\x00\x00\x00\xe8\x07\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x51\xe5\x74\x64\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x52\xe5\x74\x64\x04\x00\x00\x00\x90\xfd\x00\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x70\x02\x00\x00\x00\x00\x00\x00\x70\x02\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x2f\x6c\x69\x62\x2f\x6c\x64\x2d\x6c\x69\x6e\x75\x78\x2d\x61\x61\x72\x63\x68\x36\x34"), +Section(".symtab", 0x0, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7\x00\x01\x00\x00\x00\x40\x06\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xc8\x0b\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x38\x00\x09\x00\x40\x00\x1c\x00\x1b\x00\x06\x00\x00\x00\x04\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x08\x00\x00\x00\x00\x00\x00\xf4\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x00\x00\x06\x00\x00\x00\x90\xfd\x00\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x80\x02\x00\x00\x00\x00\x00\x00\x88\x02\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x02\x00\x00\x00\x06\x00\x00\x00\xa0\xfd\x00\x00\x00\x00\x00\x00\xa0\xfd\x01\x00\x00\x00\x00\x00\xa0\xfd\x01\x00\x00\x00\x00\x00\xf0\x01\x00\x00\x00\x00\x00\x00\xf0\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x50\xe5\x74\x64\x04\x00\x00\x00\xe8\x07\x00\x00\x00\x00\x00\x00\xe8\x07\x00\x00\x00\x00\x00\x00\xe8\x07\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x51\xe5\x74\x64\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x52\xe5\x74\x64\x04\x00\x00\x00\x90\xfd\x00\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x70\x02\x00\x00\x00\x00\x00\x00\x70\x02\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x2f\x6c\x69\x62\x2f\x6c\x64\x2d\x6c\x69\x6e\x75\x78\x2d\x61\x61\x72\x63\x68\x36\x34\x2e\x73\x6f\x2e\x31\x00\x00\x04\x00\x00\x00\x14\x00\x00\x00\x03\x00\x00\x00\x47\x4e\x55\x00\x56\x39\x03\xc2\xe1\x5e\x80\x94\xce\xd1\x56\x3a\x67\x2f\x13\x1f\x3c\x67\x44\x5e\x04\x00\x00\x00\x10\x00\x00\x00\x01\x00\x00\x00\x47\x4e\x55\x00\x00\x00\x00\x00\x03\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x0b\x00\xb8\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x16\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4f\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6b\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x29\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7a\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6d\x61\x6c\x6c\x6f\x63\x00\x5f\x5f\x6c\x69\x62\x63\x5f\x73\x74\x61\x72\x74\x5f\x6d\x61\x69\x6e\x00\x5f\x5f\x63\x78\x61\x5f\x66\x69\x6e\x61\x6c\x69\x7a\x65\x00\x61\x62\x6f\x72\x74\x00\x6c\x69\x62\x63\x2e\x73\x6f\x2e\x36\x00\x47\x4c\x49\x42\x43\x5f\x32\x2e\x31\x37\x00\x47\x4c\x49\x42\x43\x5f\x32\x2e\x33\x34\x00\x5f\x49\x54\x4d\x5f\x64\x65\x72\x65\x67\x69\x73\x74\x65\x72\x54\x4d\x43\x6c\x6f\x6e\x65\x54\x61\x62\x6c\x65\x00\x5f\x5f\x67\x6d\x6f\x6e\x5f\x73\x74\x61\x72\x74\x5f\x5f\x00\x5f\x49\x54\x4d\x5f\x72\x65\x67\x69\x73\x74\x65\x72\x54\x4d\x43\x6c\x6f\x6e\x65\x54\x61\x62\x6c\x65\x00\x00\x00\x00\x00\x00\x00\x02\x00\x01\x00\x03\x00\x03\x00\x01\x00\x03\x00\x01\x00\x01\x00\x02\x00\x2f\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x97\x91\x96\x06\x00\x00\x03\x00\x39\x00\x00\x00\x10\x00\x00\x00\xb4\x91\x96\x06\x00\x00\x02\x00\x44\x00\x00\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x50\x07\x00\x00\x00\x00\x00\x00\x98\xfd\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\xf0\xff\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x74\x07\x00\x00\x00\x00\x00\x00\x08\x00\x02\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x08\x00\x02\x00\x00\x00\x00\x00\xd8\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe8\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa8\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb0\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb8\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc8\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x20\x03\xd5\xfd\x7b\xbf\xa9\xfd\x03\x00\x91\x2c\x00\x00\x94\xfd\x7b\xc1\xa8\xc0\x03\x5f\xd6\xf0\x7b\xbf\xa9\xf0\x00\x00\xf0\x11\xd2\x47\xf9\x10\x82\x3e\x91\x20\x02\x1f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x1f\x20\x03\xd5\xf0\x00\x00\xf0\x11\xd6\x47\xf9\x10\xa2\x3e\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xda\x47\xf9\x10\xc2\x3e\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xde\x47\xf9\x10\xe2\x3e\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xe2\x47\xf9\x10\x02\x3f\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xe6\x47\xf9\x10\x22\x3f\x91\x20\x02\x1f\xd6\x1f\x20\x03\xd5\x1d\x00\x80\xd2\x1e\x00\x80\xd2\xe5\x03\x00\xaa\xe1\x03\x40\xf9\xe2\x23\x00\x91\xe6\x03\x00\x91\xe0\x00\x00\xf0\x00\xf8\x47\xf9\x03\x00\x80\xd2\x04\x00\x80\xd2\xe1\xff\xff\x97\xf0\xff\xff\x97\xe0\x00\x00\xf0\x00\xf4\x47\xf9\x40\x00\x00\xb4\xe8\xff\xff\x17\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x00\x01\x00\x90\x00\x40\x00\x91\x01\x01\x00\x90\x21\x40\x00\x91\x3f\x00\x00\xeb\xc0\x00\x00\x54\xe1\x00\x00\xf0\x21\xec\x47\xf9\x61\x00\x00\xb4\xf0\x03\x01\xaa\x00\x02\x1f\xd6\xc0\x03\x5f\xd6\x00\x01\x00\x90\x00\x40\x00\x91\x01\x01\x00\x90\x21\x40\x00\x91\x21\x00\x00\xcb\x22\xfc\x7f\xd3\x41\x0c\x81\x8b\x21\xfc\x41\x93\xc1\x00\x00\xb4\xe2\x00\x00\xf0\x42\xfc\x47\xf9\x62\x00\x00\xb4\xf0\x03\x02\xaa\x00\x02\x1f\xd6\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\xfd\x7b\xbe\xa9\xfd\x03\x00\x91\xf3\x0b\x00\xf9\x13\x01\x00\x90\x60\x42\x40\x39\x40\x01\x00\x35\xe0\x00\x00\xf0\x00\xf0\x47\xf9\x80\x00\x00\xb4\x00\x01\x00\x90\x00\x04\x40\xf9\xb5\xff\xff\x97\xd8\xff\xff\x97\x20\x00\x80\x52\x60\x42\x00\x39\xf3\x0b\x40\xf9\xfd\x7b\xc2\xa8\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\xdc\xff\xff\x17\xff\x83\x00\xd1\xe0\x07\x00\xf9\xe0\x07\x40\xf9\x00\x40\x00\x91\xe0\x0f\x00\xf9\xe0\x0f\x40\xf9\xff\x83\x00\x91\xc0\x03\x5f\xd6\xfd\x7b\xbd\xa9\xfd\x03\x00\x91\x80\x02\x80\xd2\xa4\xff\xff\x97\xe0\x0f\x00\xf9\xe0\x0f\x40\xf9\x81\x01\x80\x52\x01\x00\x00\xb9\xe0\x0f\x40\xf9\x00\x40\x00\x91\xe0\x13\x00\xf9\xe0\x13\x40\xf9\xa1\x01\x80\x52\x01\x00\x00\xb9\xe0\x13\x40\xf9\xe9\xff\xff\x97\xe0\x17\x00\xf9\xe0\x17\x40\xf9\xc1\x01\x80\x52\x01\x00\x00\xb9\x00\x00\x80\x52\xfd\x7b\xc3\xa8\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\xfd\x7b\xbf\xa9\xfd\x03\x00\x91\xfd\x7b\xc1\xa8\xc0\x03\x5f\xd6\x01\x00\x02\x00\x01\x1b\x03\x3b\x44\x00\x00\x00\x07\x00\x00\x00\x58\xfe\xff\xff\x5c\x00\x00\x00\xa8\xfe\xff\xff\x70\x00\x00\x00\xd8\xfe\xff\xff\x84\x00\x00\x00\x18\xff\xff\xff\x98\x00\x00\x00\x68\xff\xff\xff\xbc\x00\x00\x00\x6c\xff\xff\xff\xd0\x00\x00\x00\x8c\xff\xff\xff\xe8\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x01\x7a\x52\x00\x04\x78\x1e\x01"), +Section(".comment", 0x0, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7\x00\x01\x00\x00\x00\x40\x06\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xc8\x0b\x01"), +Section(".interp", 0x238, "\x2f\x6c\x69\x62\x2f\x6c\x64\x2d\x6c\x69\x6e\x75\x78\x2d\x61\x61\x72\x63\x68\x36\x34\x2e\x73\x6f\x2e\x31\x00"), +Section(".note.gnu.build-id", 0x254, "\x04\x00\x00\x00\x14\x00\x00\x00\x03\x00\x00\x00\x47\x4e\x55\x00\x56\x39\x03\xc2\xe1\x5e\x80\x94\xce\xd1\x56\x3a\x67\x2f\x13\x1f\x3c\x67\x44\x5e"), +Section(".note.ABI-tag", 0x278, "\x04\x00\x00\x00\x10\x00\x00\x00\x01\x00\x00\x00\x47\x4e\x55\x00\x00\x00\x00\x00\x03\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00"), +Section(".gnu.hash", 0x298, "\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".dynsym", 0x2B8, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x0b\x00\xb8\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x16\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4f\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6b\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x29\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7a\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".dynstr", 0x3A8, "\x00\x6d\x61\x6c\x6c\x6f\x63\x00\x5f\x5f\x6c\x69\x62\x63\x5f\x73\x74\x61\x72\x74\x5f\x6d\x61\x69\x6e\x00\x5f\x5f\x63\x78\x61\x5f\x66\x69\x6e\x61\x6c\x69\x7a\x65\x00\x61\x62\x6f\x72\x74\x00\x6c\x69\x62\x63\x2e\x73\x6f\x2e\x36\x00\x47\x4c\x49\x42\x43\x5f\x32\x2e\x31\x37\x00\x47\x4c\x49\x42\x43\x5f\x32\x2e\x33\x34\x00\x5f\x49\x54\x4d\x5f\x64\x65\x72\x65\x67\x69\x73\x74\x65\x72\x54\x4d\x43\x6c\x6f\x6e\x65\x54\x61\x62\x6c\x65\x00\x5f\x5f\x67\x6d\x6f\x6e\x5f\x73\x74\x61\x72\x74\x5f\x5f\x00\x5f\x49\x54\x4d\x5f\x72\x65\x67\x69\x73\x74\x65\x72\x54\x4d\x43\x6c\x6f\x6e\x65\x54\x61\x62\x6c\x65\x00"), +Section(".gnu.version", 0x43C, "\x00\x00\x00\x00\x00\x00\x02\x00\x01\x00\x03\x00\x03\x00\x01\x00\x03\x00\x01\x00"), +Section(".gnu.version_r", 0x450, "\x01\x00\x02\x00\x2f\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x97\x91\x96\x06\x00\x00\x03\x00\x39\x00\x00\x00\x10\x00\x00\x00\xb4\x91\x96\x06\x00\x00\x02\x00\x44\x00\x00\x00\x00\x00\x00\x00"), +Section(".rela.dyn", 0x480, "\x90\xfd\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x50\x07\x00\x00\x00\x00\x00\x00\x98\xfd\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\xf0\xff\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x74\x07\x00\x00\x00\x00\x00\x00\x08\x00\x02\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x08\x00\x02\x00\x00\x00\x00\x00\xd8\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe8\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".rela.plt", 0x540, "\xa8\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb0\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb8\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc8\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".init", 0x5B8, "\x1f\x20\x03\xd5\xfd\x7b\xbf\xa9\xfd\x03\x00\x91\x2c\x00\x00\x94\xfd\x7b\xc1\xa8\xc0\x03\x5f\xd6"), +Section(".plt", 0x5D0, "\xf0\x7b\xbf\xa9\xf0\x00\x00\xf0\x11\xd2\x47\xf9\x10\x82\x3e\x91\x20\x02\x1f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x1f\x20\x03\xd5\xf0\x00\x00\xf0\x11\xd6\x47\xf9\x10\xa2\x3e\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xda\x47\xf9\x10\xc2\x3e\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xde\x47\xf9\x10\xe2\x3e\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xe2\x47\xf9\x10\x02\x3f\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xe6\x47\xf9\x10\x22\x3f\x91\x20\x02\x1f\xd6"), +Section(".text", 0x640, "\x1f\x20\x03\xd5\x1d\x00\x80\xd2\x1e\x00\x80\xd2\xe5\x03\x00\xaa\xe1\x03\x40\xf9\xe2\x23\x00\x91\xe6\x03\x00\x91\xe0\x00\x00\xf0\x00\xf8\x47\xf9\x03\x00\x80\xd2\x04\x00\x80\xd2\xe1\xff\xff\x97\xf0\xff\xff\x97\xe0\x00\x00\xf0\x00\xf4\x47\xf9\x40\x00\x00\xb4\xe8\xff\xff\x17\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x00\x01\x00\x90\x00\x40\x00\x91\x01\x01\x00\x90\x21\x40\x00\x91\x3f\x00\x00\xeb\xc0\x00\x00\x54\xe1\x00\x00\xf0\x21\xec\x47\xf9\x61\x00\x00\xb4\xf0\x03\x01\xaa\x00\x02\x1f\xd6\xc0\x03\x5f\xd6\x00\x01\x00\x90\x00\x40\x00\x91\x01\x01\x00\x90\x21\x40\x00\x91\x21\x00\x00\xcb\x22\xfc\x7f\xd3\x41\x0c\x81\x8b\x21\xfc\x41\x93\xc1\x00\x00\xb4\xe2\x00\x00\xf0\x42\xfc\x47\xf9\x62\x00\x00\xb4\xf0\x03\x02\xaa\x00\x02\x1f\xd6\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\xfd\x7b\xbe\xa9\xfd\x03\x00\x91\xf3\x0b\x00\xf9\x13\x01\x00\x90\x60\x42\x40\x39\x40\x01\x00\x35\xe0\x00\x00\xf0\x00\xf0\x47\xf9\x80\x00\x00\xb4\x00\x01\x00\x90\x00\x04\x40\xf9\xb5\xff\xff\x97\xd8\xff\xff\x97\x20\x00\x80\x52\x60\x42\x00\x39\xf3\x0b\x40\xf9\xfd\x7b\xc2\xa8\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\xdc\xff\xff\x17\xff\x83\x00\xd1\xe0\x07\x00\xf9\xe0\x07\x40\xf9\x00\x40\x00\x91\xe0\x0f\x00\xf9\xe0\x0f\x40\xf9\xff\x83\x00\x91\xc0\x03\x5f\xd6\xfd\x7b\xbd\xa9\xfd\x03\x00\x91\x80\x02\x80\xd2\xa4\xff\xff\x97\xe0\x0f\x00\xf9\xe0\x0f\x40\xf9\x81\x01\x80\x52\x01\x00\x00\xb9\xe0\x0f\x40\xf9\x00\x40\x00\x91\xe0\x13\x00\xf9\xe0\x13\x40\xf9\xa1\x01\x80\x52\x01\x00\x00\xb9\xe0\x13\x40\xf9\xe9\xff\xff\x97\xe0\x17\x00\xf9\xe0\x17\x40\xf9\xc1\x01\x80\x52\x01\x00\x00\xb9\x00\x00\x80\x52\xfd\x7b\xc3\xa8\xc0\x03\x5f\xd6"), +Section(".fini", 0x7D0, "\x1f\x20\x03\xd5\xfd\x7b\xbf\xa9\xfd\x03\x00\x91\xfd\x7b\xc1\xa8\xc0\x03\x5f\xd6"), +Section(".rodata", 0x7E4, "\x01\x00\x02\x00"), +Section(".eh_frame_hdr", 0x7E8, "\x01\x1b\x03\x3b\x44\x00\x00\x00\x07\x00\x00\x00\x58\xfe\xff\xff\x5c\x00\x00\x00\xa8\xfe\xff\xff\x70\x00\x00\x00\xd8\xfe\xff\xff\x84\x00\x00\x00\x18\xff\xff\xff\x98\x00\x00\x00\x68\xff\xff\xff\xbc\x00\x00\x00\x6c\xff\xff\xff\xd0\x00\x00\x00\x8c\xff\xff\xff\xe8\x00\x00\x00"), +Section(".eh_frame", 0x830, "\x10\x00\x00\x00\x00\x00\x00\x00\x01\x7a\x52\x00\x04\x78\x1e\x01\x1b\x0c\x1f\x00\x10\x00\x00\x00\x18\x00\x00\x00\xf4\xfd\xff\xff\x34\x00\x00\x00\x00\x41\x07\x1e\x10\x00\x00\x00\x2c\x00\x00\x00\x30\xfe\xff\xff\x30\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x40\x00\x00\x00\x4c\xfe\xff\xff\x3c\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x54\x00\x00\x00\x78\xfe\xff\xff\x48\x00\x00\x00\x00\x41\x0e\x20\x9d\x04\x9e\x03\x42\x93\x02\x4e\xde\xdd\xd3\x0e\x00\x00\x00\x00\x10\x00\x00\x00\x78\x00\x00\x00\xa4\xfe\xff\xff\x04\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x8c\x00\x00\x00\x94\xfe\xff\xff\x20\x00\x00\x00\x00\x41\x0e\x20\x46\x0e\x00\x00\x1c\x00\x00\x00\xa4\x00\x00\x00\x9c\xfe\xff\xff\x5c\x00\x00\x00\x00\x41\x0e\x30\x9d\x06\x9e\x05\x55\xde\xdd\x0e\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".fini_array", 0x1FD98, "\x00\x07\x00\x00\x00\x00\x00\x00"), +Section(".dynamic", 0x1FDA0, "\x01\x00\x00\x00\x00\x00\x00\x00\x2f\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x00\x00\xb8\x05\x00\x00\x00\x00\x00\x00\x0d\x00\x00\x00\x00\x00\x00\x00\xd0\x07\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00\x00\x00\x00\x00\x98\xfd\x01\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\xf5\xfe\xff\x6f\x00\x00\x00\x00\x98\x02\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\xa8\x03\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\xb8\x02\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x94\x00\x00\x00\x00\x00\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x15\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x90\xff\x01\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x78\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x17\x00\x00\x00\x00\x00\x00\x00\x40\x05\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x80\x04\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\xc0\x00\x00\x00\x00\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\xfb\xff\xff\x6f\x00\x00\x00\x00\x01\x00\x00\x08\x00\x00\x00\x00\xfe\xff\xff\x6f\x00\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x00\xff\xff\xff\x6f\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\xf0\xff\xff\x6f\x00\x00\x00\x00\x3c\x04\x00\x00\x00\x00\x00\x00\xf9\xff\xff\x6f\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".got", 0x1FF90, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd0\x05\x00\x00\x00\x00\x00\x00\xd0\x05\x00\x00\x00\x00\x00\x00\xd0\x05\x00\x00\x00\x00\x00\x00\xd0\x05\x00\x00\x00\x00\x00\x00\xd0\x05\x00\x00\x00\x00\x00\x00\xa0\xfd\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x74\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".data", 0x20000, "\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x02\x00\x00\x00\x00\x00"), +Section(".init_array", 0x1FD90, "\x50\x07\x00\x00\x00\x00\x00\x00")]), +Memmap([Annotation(Region(0x0,0x8F3), Attr("segment","02 0 2292")), +Annotation(Region(0x640,0x673), Attr("symbol","_start")), +Annotation(Region(0x0,0xF9), Attr("section",".shstrtab")), +Annotation(Region(0x0,0x24C), Attr("section",".strtab")), +Annotation(Region(0x0,0x83F), Attr("section",".symtab")), +Annotation(Region(0x0,0x2A), Attr("section",".comment")), +Annotation(Region(0x238,0x252), Attr("section",".interp")), +Annotation(Region(0x254,0x277), Attr("section",".note.gnu.build-id")), +Annotation(Region(0x278,0x297), Attr("section",".note.ABI-tag")), +Annotation(Region(0x298,0x2B3), Attr("section",".gnu.hash")), +Annotation(Region(0x2B8,0x3A7), Attr("section",".dynsym")), +Annotation(Region(0x3A8,0x43B), Attr("section",".dynstr")), +Annotation(Region(0x43C,0x44F), Attr("section",".gnu.version")), +Annotation(Region(0x450,0x47F), Attr("section",".gnu.version_r")), +Annotation(Region(0x480,0x53F), Attr("section",".rela.dyn")), +Annotation(Region(0x540,0x5B7), Attr("section",".rela.plt")), +Annotation(Region(0x5B8,0x5CF), Attr("section",".init")), +Annotation(Region(0x5D0,0x63F), Attr("section",".plt")), +Annotation(Region(0x5B8,0x5CF), Attr("code-region","()")), +Annotation(Region(0x5D0,0x63F), Attr("code-region","()")), +Annotation(Region(0x640,0x673), Attr("symbol-info","_start 0x640 52")), +Annotation(Region(0x674,0x687), Attr("symbol","call_weak_fn")), +Annotation(Region(0x674,0x687), Attr("symbol-info","call_weak_fn 0x674 20")), +Annotation(Region(0x754,0x773), Attr("symbol","callee")), +Annotation(Region(0x640,0x7CF), Attr("section",".text")), +Annotation(Region(0x640,0x7CF), Attr("code-region","()")), +Annotation(Region(0x754,0x773), Attr("symbol-info","callee 0x754 32")), +Annotation(Region(0x774,0x7CF), Attr("symbol","main")), +Annotation(Region(0x774,0x7CF), Attr("symbol-info","main 0x774 92")), +Annotation(Region(0x7D0,0x7E3), Attr("section",".fini")), +Annotation(Region(0x7D0,0x7E3), Attr("code-region","()")), +Annotation(Region(0x7E4,0x7E7), Attr("section",".rodata")), +Annotation(Region(0x7E8,0x82B), Attr("section",".eh_frame_hdr")), +Annotation(Region(0x830,0x8F3), Attr("section",".eh_frame")), +Annotation(Region(0x1FD90,0x2000F), Attr("segment","03 0x1FD90 648")), +Annotation(Region(0x1FD98,0x1FD9F), Attr("section",".fini_array")), +Annotation(Region(0x1FDA0,0x1FF8F), Attr("section",".dynamic")), +Annotation(Region(0x1FF90,0x1FFFF), Attr("section",".got")), +Annotation(Region(0x20000,0x2000F), Attr("section",".data")), +Annotation(Region(0x1FD90,0x1FD97), Attr("section",".init_array"))]), +Program(Tid(1_844, "%00000734"), Attrs([]), + Subs([Sub(Tid(1_789, "@__cxa_finalize"), Attrs([Attr("address","0x600"), +Attr("stub","()"), Attr("c.proto","signed (*)(void)")]), "__cxa_finalize", + Args([Arg(Tid(1_845, "%00000735"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("__cxa_finalize_result",Imm(32)), LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(1_113, "@__cxa_finalize"), Attrs([Attr("address","0x600")]), + Phis([]), Defs([Def(Tid(1_377, "%00000561"), Attrs([Attr("address","0x600"), +Attr("insn","adrp x16, #126976")]), Var("R16",Imm(64)), Int(126976,64)), +Def(Tid(1_384, "%00000568"), Attrs([Attr("address","0x604"), +Attr("insn","ldr x17, [x16, #0xfb0]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R16",Imm(64)),Int(4016,64)),LittleEndian(),64)), +Def(Tid(1_390, "%0000056e"), Attrs([Attr("address","0x608"), +Attr("insn","add x16, x16, #0xfb0")]), Var("R16",Imm(64)), +PLUS(Var("R16",Imm(64)),Int(4016,64)))]), Jmps([Call(Tid(1_395, "%00000573"), + Attrs([Attr("address","0x60C"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), +Sub(Tid(1_790, "@__do_global_dtors_aux"), Attrs([Attr("address","0x700"), +Attr("c.proto","signed (*)(void)")]), "__do_global_dtors_aux", + Args([Arg(Tid(1_846, "%00000736"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("__do_global_dtors_aux_result",Imm(32)), LOW(32,Var("R0",Imm(64))), +Out())]), Blks([Blk(Tid(735, "@__do_global_dtors_aux"), + Attrs([Attr("address","0x700")]), Phis([]), Defs([Def(Tid(739, "%000002e3"), + Attrs([Attr("address","0x700"), +Attr("insn","stp x29, x30, [sp, #-0x20]!")]), Var("#3",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(18446744073709551584,64))), +Def(Tid(745, "%000002e9"), Attrs([Attr("address","0x700"), +Attr("insn","stp x29, x30, [sp, #-0x20]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("#3",Imm(64)),Var("R29",Imm(64)),LittleEndian(),64)), +Def(Tid(751, "%000002ef"), Attrs([Attr("address","0x700"), +Attr("insn","stp x29, x30, [sp, #-0x20]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("#3",Imm(64)),Int(8,64)),Var("R30",Imm(64)),LittleEndian(),64)), +Def(Tid(755, "%000002f3"), Attrs([Attr("address","0x700"), +Attr("insn","stp x29, x30, [sp, #-0x20]!")]), Var("R31",Imm(64)), +Var("#3",Imm(64))), Def(Tid(761, "%000002f9"), + Attrs([Attr("address","0x704"), Attr("insn","mov x29, sp")]), + Var("R29",Imm(64)), Var("R31",Imm(64))), Def(Tid(769, "%00000301"), + Attrs([Attr("address","0x708"), Attr("insn","str x19, [sp, #0x10]")]), + Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(16,64)),Var("R19",Imm(64)),LittleEndian(),64)), +Def(Tid(774, "%00000306"), Attrs([Attr("address","0x70C"), +Attr("insn","adrp x19, #131072")]), Var("R19",Imm(64)), Int(131072,64)), +Def(Tid(781, "%0000030d"), Attrs([Attr("address","0x710"), +Attr("insn","ldrb w0, [x19, #0x10]")]), Var("R0",Imm(64)), +UNSIGNED(64,Load(Var("mem",Mem(64,8)),PLUS(Var("R19",Imm(64)),Int(16,64)),LittleEndian(),8)))]), +Jmps([Goto(Tid(788, "%00000314"), Attrs([Attr("address","0x714"), +Attr("insn","cbnz w0, #0x28")]), + NEQ(Extract(31,0,Var("R0",Imm(64))),Int(0,32)), +Direct(Tid(786, "%00000312"))), Goto(Tid(1_834, "%0000072a"), Attrs([]), + Int(1,1), Direct(Tid(1_058, "%00000422")))])), Blk(Tid(1_058, "%00000422"), + Attrs([Attr("address","0x718")]), Phis([]), +Defs([Def(Tid(1_061, "%00000425"), Attrs([Attr("address","0x718"), +Attr("insn","adrp x0, #126976")]), Var("R0",Imm(64)), Int(126976,64)), +Def(Tid(1_068, "%0000042c"), Attrs([Attr("address","0x71C"), +Attr("insn","ldr x0, [x0, #0xfe0]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R0",Imm(64)),Int(4064,64)),LittleEndian(),64))]), +Jmps([Goto(Tid(1_074, "%00000432"), Attrs([Attr("address","0x720"), +Attr("insn","cbz x0, #0x10")]), EQ(Var("R0",Imm(64)),Int(0,64)), +Direct(Tid(1_072, "%00000430"))), Goto(Tid(1_835, "%0000072b"), Attrs([]), + Int(1,1), Direct(Tid(1_097, "%00000449")))])), Blk(Tid(1_097, "%00000449"), + Attrs([Attr("address","0x724")]), Phis([]), +Defs([Def(Tid(1_100, "%0000044c"), Attrs([Attr("address","0x724"), +Attr("insn","adrp x0, #131072")]), Var("R0",Imm(64)), Int(131072,64)), +Def(Tid(1_107, "%00000453"), Attrs([Attr("address","0x728"), +Attr("insn","ldr x0, [x0, #0x8]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R0",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(1_112, "%00000458"), Attrs([Attr("address","0x72C"), +Attr("insn","bl #-0x12c")]), Var("R30",Imm(64)), Int(1840,64))]), +Jmps([Call(Tid(1_115, "%0000045b"), Attrs([Attr("address","0x72C"), +Attr("insn","bl #-0x12c")]), Int(1,1), +(Direct(Tid(1_789, "@__cxa_finalize")),Direct(Tid(1_072, "%00000430"))))])), +Blk(Tid(1_072, "%00000430"), Attrs([Attr("address","0x730")]), Phis([]), +Defs([Def(Tid(1_080, "%00000438"), Attrs([Attr("address","0x730"), +Attr("insn","bl #-0xa0")]), Var("R30",Imm(64)), Int(1844,64))]), +Jmps([Call(Tid(1_082, "%0000043a"), Attrs([Attr("address","0x730"), +Attr("insn","bl #-0xa0")]), Int(1,1), +(Direct(Tid(1_804, "@deregister_tm_clones")),Direct(Tid(1_084, "%0000043c"))))])), +Blk(Tid(1_084, "%0000043c"), Attrs([Attr("address","0x734")]), Phis([]), +Defs([Def(Tid(1_087, "%0000043f"), Attrs([Attr("address","0x734"), +Attr("insn","mov w0, #0x1")]), Var("R0",Imm(64)), Int(1,64)), +Def(Tid(1_095, "%00000447"), Attrs([Attr("address","0x738"), +Attr("insn","strb w0, [x19, #0x10]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R19",Imm(64)),Int(16,64)),Extract(7,0,Var("R0",Imm(64))),LittleEndian(),8))]), +Jmps([Goto(Tid(1_836, "%0000072c"), Attrs([]), Int(1,1), +Direct(Tid(786, "%00000312")))])), Blk(Tid(786, "%00000312"), + Attrs([Attr("address","0x73C")]), Phis([]), Defs([Def(Tid(796, "%0000031c"), + Attrs([Attr("address","0x73C"), Attr("insn","ldr x19, [sp, #0x10]")]), + Var("R19",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(16,64)),LittleEndian(),64)), +Def(Tid(803, "%00000323"), Attrs([Attr("address","0x740"), +Attr("insn","ldp x29, x30, [sp], #0x20")]), Var("R29",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(808, "%00000328"), Attrs([Attr("address","0x740"), +Attr("insn","ldp x29, x30, [sp], #0x20")]), Var("R30",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(812, "%0000032c"), Attrs([Attr("address","0x740"), +Attr("insn","ldp x29, x30, [sp], #0x20")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(32,64)))]), Jmps([Call(Tid(817, "%00000331"), + Attrs([Attr("address","0x744"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))])), Sub(Tid(1_794, "@__libc_start_main"), + Attrs([Attr("address","0x5F0"), Attr("stub","()"), +Attr("c.proto","signed (*)(signed (*)(signed , char** , char** );* main, signed , char** , \nvoid* auxv)")]), + "__libc_start_main", Args([Arg(Tid(1_847, "%00000737"), + Attrs([Attr("c.data","Top:u64 ptr ptr"), +Attr("c.layout","**[ : 64]"), +Attr("c.type","signed (*)(signed , char** , char** );*")]), + Var("__libc_start_main_main",Imm(64)), Var("R0",Imm(64)), In()), +Arg(Tid(1_848, "%00000738"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("__libc_start_main_arg2",Imm(32)), LOW(32,Var("R1",Imm(64))), In()), +Arg(Tid(1_849, "%00000739"), Attrs([Attr("c.data","Top:u8 ptr ptr"), +Attr("c.layout","**[char : 8]"), Attr("c.type","char**")]), + Var("__libc_start_main_arg3",Imm(64)), Var("R2",Imm(64)), Both()), +Arg(Tid(1_850, "%0000073a"), Attrs([Attr("c.data","{} ptr"), +Attr("c.layout","*[ : 8]"), Attr("c.type","void*")]), + Var("__libc_start_main_auxv",Imm(64)), Var("R3",Imm(64)), Both()), +Arg(Tid(1_851, "%0000073b"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("__libc_start_main_result",Imm(32)), LOW(32,Var("R0",Imm(64))), +Out())]), Blks([Blk(Tid(568, "@__libc_start_main"), + Attrs([Attr("address","0x5F0")]), Phis([]), +Defs([Def(Tid(1_355, "%0000054b"), Attrs([Attr("address","0x5F0"), +Attr("insn","adrp x16, #126976")]), Var("R16",Imm(64)), Int(126976,64)), +Def(Tid(1_362, "%00000552"), Attrs([Attr("address","0x5F4"), +Attr("insn","ldr x17, [x16, #0xfa8]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R16",Imm(64)),Int(4008,64)),LittleEndian(),64)), +Def(Tid(1_368, "%00000558"), Attrs([Attr("address","0x5F8"), +Attr("insn","add x16, x16, #0xfa8")]), Var("R16",Imm(64)), +PLUS(Var("R16",Imm(64)),Int(4008,64)))]), Jmps([Call(Tid(1_373, "%0000055d"), + Attrs([Attr("address","0x5FC"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), Sub(Tid(1_795, "@_fini"), + Attrs([Attr("address","0x7D0"), Attr("c.proto","signed (*)(void)")]), + "_fini", Args([Arg(Tid(1_852, "%0000073c"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("_fini_result",Imm(32)), LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(52, "@_fini"), Attrs([Attr("address","0x7D0")]), Phis([]), +Defs([Def(Tid(58, "%0000003a"), Attrs([Attr("address","0x7D4"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("#0",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(18446744073709551600,64))), +Def(Tid(64, "%00000040"), Attrs([Attr("address","0x7D4"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("#0",Imm(64)),Var("R29",Imm(64)),LittleEndian(),64)), +Def(Tid(70, "%00000046"), Attrs([Attr("address","0x7D4"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("#0",Imm(64)),Int(8,64)),Var("R30",Imm(64)),LittleEndian(),64)), +Def(Tid(74, "%0000004a"), Attrs([Attr("address","0x7D4"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("R31",Imm(64)), +Var("#0",Imm(64))), Def(Tid(80, "%00000050"), Attrs([Attr("address","0x7D8"), +Attr("insn","mov x29, sp")]), Var("R29",Imm(64)), Var("R31",Imm(64))), +Def(Tid(87, "%00000057"), Attrs([Attr("address","0x7DC"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R29",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(92, "%0000005c"), Attrs([Attr("address","0x7DC"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R30",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(96, "%00000060"), Attrs([Attr("address","0x7DC"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(16,64)))]), Jmps([Call(Tid(101, "%00000065"), + Attrs([Attr("address","0x7E0"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))])), Sub(Tid(1_796, "@_init"), + Attrs([Attr("address","0x5B8"), Attr("c.proto","signed (*)(void)")]), + "_init", Args([Arg(Tid(1_853, "%0000073d"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("_init_result",Imm(32)), LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(1_596, "@_init"), Attrs([Attr("address","0x5B8")]), Phis([]), +Defs([Def(Tid(1_602, "%00000642"), Attrs([Attr("address","0x5BC"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("#6",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(18446744073709551600,64))), +Def(Tid(1_608, "%00000648"), Attrs([Attr("address","0x5BC"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("#6",Imm(64)),Var("R29",Imm(64)),LittleEndian(),64)), +Def(Tid(1_614, "%0000064e"), Attrs([Attr("address","0x5BC"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("#6",Imm(64)),Int(8,64)),Var("R30",Imm(64)),LittleEndian(),64)), +Def(Tid(1_618, "%00000652"), Attrs([Attr("address","0x5BC"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("R31",Imm(64)), +Var("#6",Imm(64))), Def(Tid(1_624, "%00000658"), + Attrs([Attr("address","0x5C0"), Attr("insn","mov x29, sp")]), + Var("R29",Imm(64)), Var("R31",Imm(64))), Def(Tid(1_629, "%0000065d"), + Attrs([Attr("address","0x5C4"), Attr("insn","bl #0xb0")]), + Var("R30",Imm(64)), Int(1480,64))]), Jmps([Call(Tid(1_631, "%0000065f"), + Attrs([Attr("address","0x5C4"), Attr("insn","bl #0xb0")]), Int(1,1), +(Direct(Tid(1_801, "@call_weak_fn")),Direct(Tid(1_633, "%00000661"))))])), +Blk(Tid(1_633, "%00000661"), Attrs([Attr("address","0x5C8")]), Phis([]), +Defs([Def(Tid(1_638, "%00000666"), Attrs([Attr("address","0x5C8"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R29",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(1_643, "%0000066b"), Attrs([Attr("address","0x5C8"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R30",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(1_647, "%0000066f"), Attrs([Attr("address","0x5C8"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(16,64)))]), Jmps([Call(Tid(1_652, "%00000674"), + Attrs([Attr("address","0x5CC"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))])), Sub(Tid(1_797, "@_start"), + Attrs([Attr("address","0x640"), Attr("stub","()"), Attr("entry-point","()"), +Attr("c.proto","signed (*)(void)")]), "_start", + Args([Arg(Tid(1_854, "%0000073e"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("_start_result",Imm(32)), LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(505, "@_start"), Attrs([Attr("address","0x640")]), Phis([]), +Defs([Def(Tid(510, "%000001fe"), Attrs([Attr("address","0x644"), +Attr("insn","mov x29, #0x0")]), Var("R29",Imm(64)), Int(0,64)), +Def(Tid(515, "%00000203"), Attrs([Attr("address","0x648"), +Attr("insn","mov x30, #0x0")]), Var("R30",Imm(64)), Int(0,64)), +Def(Tid(521, "%00000209"), Attrs([Attr("address","0x64C"), +Attr("insn","mov x5, x0")]), Var("R5",Imm(64)), Var("R0",Imm(64))), +Def(Tid(528, "%00000210"), Attrs([Attr("address","0x650"), +Attr("insn","ldr x1, [sp]")]), Var("R1",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(534, "%00000216"), Attrs([Attr("address","0x654"), +Attr("insn","add x2, sp, #0x8")]), Var("R2",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(8,64))), Def(Tid(540, "%0000021c"), + Attrs([Attr("address","0x658"), Attr("insn","mov x6, sp")]), + Var("R6",Imm(64)), Var("R31",Imm(64))), Def(Tid(545, "%00000221"), + Attrs([Attr("address","0x65C"), Attr("insn","adrp x0, #126976")]), + Var("R0",Imm(64)), Int(126976,64)), Def(Tid(552, "%00000228"), + Attrs([Attr("address","0x660"), Attr("insn","ldr x0, [x0, #0xff0]")]), + Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R0",Imm(64)),Int(4080,64)),LittleEndian(),64)), +Def(Tid(557, "%0000022d"), Attrs([Attr("address","0x664"), +Attr("insn","mov x3, #0x0")]), Var("R3",Imm(64)), Int(0,64)), +Def(Tid(562, "%00000232"), Attrs([Attr("address","0x668"), +Attr("insn","mov x4, #0x0")]), Var("R4",Imm(64)), Int(0,64)), +Def(Tid(567, "%00000237"), Attrs([Attr("address","0x66C"), +Attr("insn","bl #-0x7c")]), Var("R30",Imm(64)), Int(1648,64))]), +Jmps([Call(Tid(570, "%0000023a"), Attrs([Attr("address","0x66C"), +Attr("insn","bl #-0x7c")]), Int(1,1), +(Direct(Tid(1_794, "@__libc_start_main")),Direct(Tid(572, "%0000023c"))))])), +Blk(Tid(572, "%0000023c"), Attrs([Attr("address","0x670")]), Phis([]), +Defs([Def(Tid(575, "%0000023f"), Attrs([Attr("address","0x670"), +Attr("insn","bl #-0x40")]), Var("R30",Imm(64)), Int(1652,64))]), +Jmps([Call(Tid(578, "%00000242"), Attrs([Attr("address","0x670"), +Attr("insn","bl #-0x40")]), Int(1,1), +(Direct(Tid(1_800, "@abort")),Direct(Tid(1_837, "%0000072d"))))])), +Blk(Tid(1_837, "%0000072d"), Attrs([]), Phis([]), Defs([]), +Jmps([Call(Tid(1_838, "%0000072e"), Attrs([]), Int(1,1), +(Direct(Tid(1_801, "@call_weak_fn")),))]))])), Sub(Tid(1_800, "@abort"), + Attrs([Attr("address","0x630"), Attr("stub","()"), Attr("noreturn","()"), +Attr("c.proto","void (*)(void)")]), "abort", Args([]), +Blks([Blk(Tid(576, "@abort"), Attrs([Attr("address","0x630")]), Phis([]), +Defs([Def(Tid(1_443, "%000005a3"), Attrs([Attr("address","0x630"), +Attr("insn","adrp x16, #126976")]), Var("R16",Imm(64)), Int(126976,64)), +Def(Tid(1_450, "%000005aa"), Attrs([Attr("address","0x634"), +Attr("insn","ldr x17, [x16, #0xfc8]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R16",Imm(64)),Int(4040,64)),LittleEndian(),64)), +Def(Tid(1_456, "%000005b0"), Attrs([Attr("address","0x638"), +Attr("insn","add x16, x16, #0xfc8")]), Var("R16",Imm(64)), +PLUS(Var("R16",Imm(64)),Int(4040,64)))]), Jmps([Call(Tid(1_461, "%000005b5"), + Attrs([Attr("address","0x63C"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), Sub(Tid(1_801, "@call_weak_fn"), + Attrs([Attr("address","0x674"), Attr("c.proto","signed (*)(void)")]), + "call_weak_fn", Args([Arg(Tid(1_855, "%0000073f"), + Attrs([Attr("c.data","Top:u32"), Attr("c.layout","[signed : 32]"), +Attr("c.type","signed")]), Var("call_weak_fn_result",Imm(32)), +LOW(32,Var("R0",Imm(64))), Out())]), Blks([Blk(Tid(580, "@call_weak_fn"), + Attrs([Attr("address","0x674")]), Phis([]), Defs([Def(Tid(583, "%00000247"), + Attrs([Attr("address","0x674"), Attr("insn","adrp x0, #126976")]), + Var("R0",Imm(64)), Int(126976,64)), Def(Tid(590, "%0000024e"), + Attrs([Attr("address","0x678"), Attr("insn","ldr x0, [x0, #0xfe8]")]), + Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R0",Imm(64)),Int(4072,64)),LittleEndian(),64))]), +Jmps([Goto(Tid(596, "%00000254"), Attrs([Attr("address","0x67C"), +Attr("insn","cbz x0, #0x8")]), EQ(Var("R0",Imm(64)),Int(0,64)), +Direct(Tid(594, "%00000252"))), Goto(Tid(1_839, "%0000072f"), Attrs([]), + Int(1,1), Direct(Tid(1_177, "%00000499")))])), Blk(Tid(594, "%00000252"), + Attrs([Attr("address","0x684")]), Phis([]), Defs([]), +Jmps([Call(Tid(602, "%0000025a"), Attrs([Attr("address","0x684"), +Attr("insn","ret")]), Int(1,1), (Indirect(Var("R30",Imm(64))),))])), +Blk(Tid(1_177, "%00000499"), Attrs([Attr("address","0x680")]), Phis([]), +Defs([]), Jmps([Goto(Tid(1_180, "%0000049c"), Attrs([Attr("address","0x680"), +Attr("insn","b #-0x60")]), Int(1,1), +Direct(Tid(1_178, "@__gmon_start__")))])), Blk(Tid(1_178, "@__gmon_start__"), + Attrs([Attr("address","0x620")]), Phis([]), +Defs([Def(Tid(1_421, "%0000058d"), Attrs([Attr("address","0x620"), +Attr("insn","adrp x16, #126976")]), Var("R16",Imm(64)), Int(126976,64)), +Def(Tid(1_428, "%00000594"), Attrs([Attr("address","0x624"), +Attr("insn","ldr x17, [x16, #0xfc0]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R16",Imm(64)),Int(4032,64)),LittleEndian(),64)), +Def(Tid(1_434, "%0000059a"), Attrs([Attr("address","0x628"), +Attr("insn","add x16, x16, #0xfc0")]), Var("R16",Imm(64)), +PLUS(Var("R16",Imm(64)),Int(4032,64)))]), Jmps([Call(Tid(1_439, "%0000059f"), + Attrs([Attr("address","0x62C"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), Sub(Tid(1_803, "@callee"), + Attrs([Attr("address","0x754"), Attr("c.proto","signed (*)(void)")]), + "callee", Args([Arg(Tid(1_856, "%00000740"), + Attrs([Attr("c.data","Top:u32"), Attr("c.layout","[signed : 32]"), +Attr("c.type","signed")]), Var("callee_result",Imm(32)), +LOW(32,Var("R0",Imm(64))), Out())]), Blks([Blk(Tid(827, "@callee"), + Attrs([Attr("address","0x754")]), Phis([]), Defs([Def(Tid(831, "%0000033f"), + Attrs([Attr("address","0x754"), Attr("insn","sub sp, sp, #0x20")]), + Var("R31",Imm(64)), PLUS(Var("R31",Imm(64)),Int(18446744073709551584,64))), +Def(Tid(839, "%00000347"), Attrs([Attr("address","0x758"), +Attr("insn","str x0, [sp, #0x8]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),Var("R0",Imm(64)),LittleEndian(),64)), +Def(Tid(846, "%0000034e"), Attrs([Attr("address","0x75C"), +Attr("insn","ldr x0, [sp, #0x8]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(852, "%00000354"), Attrs([Attr("address","0x760"), +Attr("insn","add x0, x0, #0x10")]), Var("R0",Imm(64)), +PLUS(Var("R0",Imm(64)),Int(16,64))), Def(Tid(860, "%0000035c"), + Attrs([Attr("address","0x764"), Attr("insn","str x0, [sp, #0x18]")]), + Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(24,64)),Var("R0",Imm(64)),LittleEndian(),64)), +Def(Tid(867, "%00000363"), Attrs([Attr("address","0x768"), +Attr("insn","ldr x0, [sp, #0x18]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(24,64)),LittleEndian(),64)), +Def(Tid(873, "%00000369"), Attrs([Attr("address","0x76C"), +Attr("insn","add sp, sp, #0x20")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(32,64)))]), Jmps([Call(Tid(878, "%0000036e"), + Attrs([Attr("address","0x770"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))])), +Sub(Tid(1_804, "@deregister_tm_clones"), Attrs([Attr("address","0x690"), +Attr("c.proto","signed (*)(void)")]), "deregister_tm_clones", + Args([Arg(Tid(1_857, "%00000741"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("deregister_tm_clones_result",Imm(32)), LOW(32,Var("R0",Imm(64))), +Out())]), Blks([Blk(Tid(608, "@deregister_tm_clones"), + Attrs([Attr("address","0x690")]), Phis([]), Defs([Def(Tid(611, "%00000263"), + Attrs([Attr("address","0x690"), Attr("insn","adrp x0, #131072")]), + Var("R0",Imm(64)), Int(131072,64)), Def(Tid(617, "%00000269"), + Attrs([Attr("address","0x694"), Attr("insn","add x0, x0, #0x10")]), + Var("R0",Imm(64)), PLUS(Var("R0",Imm(64)),Int(16,64))), +Def(Tid(622, "%0000026e"), Attrs([Attr("address","0x698"), +Attr("insn","adrp x1, #131072")]), Var("R1",Imm(64)), Int(131072,64)), +Def(Tid(628, "%00000274"), Attrs([Attr("address","0x69C"), +Attr("insn","add x1, x1, #0x10")]), Var("R1",Imm(64)), +PLUS(Var("R1",Imm(64)),Int(16,64))), Def(Tid(634, "%0000027a"), + Attrs([Attr("address","0x6A0"), Attr("insn","cmp x1, x0")]), + Var("#1",Imm(64)), NOT(Var("R0",Imm(64)))), Def(Tid(639, "%0000027f"), + Attrs([Attr("address","0x6A0"), Attr("insn","cmp x1, x0")]), + Var("#2",Imm(64)), PLUS(Var("R1",Imm(64)),NOT(Var("R0",Imm(64))))), +Def(Tid(645, "%00000285"), Attrs([Attr("address","0x6A0"), +Attr("insn","cmp x1, x0")]), Var("VF",Imm(1)), +NEQ(SIGNED(65,PLUS(Var("#2",Imm(64)),Int(1,64))),PLUS(PLUS(SIGNED(65,Var("R1",Imm(64))),SIGNED(65,Var("#1",Imm(64)))),Int(1,65)))), +Def(Tid(651, "%0000028b"), Attrs([Attr("address","0x6A0"), +Attr("insn","cmp x1, x0")]), Var("CF",Imm(1)), +NEQ(UNSIGNED(65,PLUS(Var("#2",Imm(64)),Int(1,64))),PLUS(PLUS(UNSIGNED(65,Var("R1",Imm(64))),UNSIGNED(65,Var("#1",Imm(64)))),Int(1,65)))), +Def(Tid(655, "%0000028f"), Attrs([Attr("address","0x6A0"), +Attr("insn","cmp x1, x0")]), Var("ZF",Imm(1)), +EQ(PLUS(Var("#2",Imm(64)),Int(1,64)),Int(0,64))), Def(Tid(659, "%00000293"), + Attrs([Attr("address","0x6A0"), Attr("insn","cmp x1, x0")]), + Var("NF",Imm(1)), Extract(63,63,PLUS(Var("#2",Imm(64)),Int(1,64))))]), +Jmps([Goto(Tid(665, "%00000299"), Attrs([Attr("address","0x6A4"), +Attr("insn","b.eq #0x18")]), EQ(Var("ZF",Imm(1)),Int(1,1)), +Direct(Tid(663, "%00000297"))), Goto(Tid(1_840, "%00000730"), Attrs([]), + Int(1,1), Direct(Tid(1_147, "%0000047b")))])), Blk(Tid(1_147, "%0000047b"), + Attrs([Attr("address","0x6A8")]), Phis([]), +Defs([Def(Tid(1_150, "%0000047e"), Attrs([Attr("address","0x6A8"), +Attr("insn","adrp x1, #126976")]), Var("R1",Imm(64)), Int(126976,64)), +Def(Tid(1_157, "%00000485"), Attrs([Attr("address","0x6AC"), +Attr("insn","ldr x1, [x1, #0xfd8]")]), Var("R1",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R1",Imm(64)),Int(4056,64)),LittleEndian(),64))]), +Jmps([Goto(Tid(1_162, "%0000048a"), Attrs([Attr("address","0x6B0"), +Attr("insn","cbz x1, #0xc")]), EQ(Var("R1",Imm(64)),Int(0,64)), +Direct(Tid(663, "%00000297"))), Goto(Tid(1_841, "%00000731"), Attrs([]), + Int(1,1), Direct(Tid(1_166, "%0000048e")))])), Blk(Tid(663, "%00000297"), + Attrs([Attr("address","0x6BC")]), Phis([]), Defs([]), +Jmps([Call(Tid(671, "%0000029f"), Attrs([Attr("address","0x6BC"), +Attr("insn","ret")]), Int(1,1), (Indirect(Var("R30",Imm(64))),))])), +Blk(Tid(1_166, "%0000048e"), Attrs([Attr("address","0x6B4")]), Phis([]), +Defs([Def(Tid(1_170, "%00000492"), Attrs([Attr("address","0x6B4"), +Attr("insn","mov x16, x1")]), Var("R16",Imm(64)), Var("R1",Imm(64)))]), +Jmps([Call(Tid(1_175, "%00000497"), Attrs([Attr("address","0x6B8"), +Attr("insn","br x16")]), Int(1,1), (Indirect(Var("R16",Imm(64))),))]))])), +Sub(Tid(1_807, "@frame_dummy"), Attrs([Attr("address","0x750"), +Attr("c.proto","signed (*)(void)")]), "frame_dummy", + Args([Arg(Tid(1_858, "%00000742"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("frame_dummy_result",Imm(32)), LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(823, "@frame_dummy"), Attrs([Attr("address","0x750")]), + Phis([]), Defs([]), Jmps([Call(Tid(825, "%00000339"), + Attrs([Attr("address","0x750"), Attr("insn","b #-0x90")]), Int(1,1), +(Direct(Tid(1_810, "@register_tm_clones")),))]))])), Sub(Tid(1_808, "@main"), + Attrs([Attr("address","0x774"), +Attr("c.proto","signed (*)(signed argc, const char** argv)")]), "main", + Args([Arg(Tid(1_859, "%00000743"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("main_argc",Imm(32)), LOW(32,Var("R0",Imm(64))), In()), +Arg(Tid(1_860, "%00000744"), Attrs([Attr("c.data","Top:u8 ptr ptr"), +Attr("c.layout","**[char : 8]"), Attr("c.type"," const char**")]), + Var("main_argv",Imm(64)), Var("R1",Imm(64)), Both()), +Arg(Tid(1_861, "%00000745"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("main_result",Imm(32)), LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(880, "@main"), Attrs([Attr("address","0x774")]), Phis([]), +Defs([Def(Tid(884, "%00000374"), Attrs([Attr("address","0x774"), +Attr("insn","stp x29, x30, [sp, #-0x30]!")]), Var("#4",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(18446744073709551568,64))), +Def(Tid(890, "%0000037a"), Attrs([Attr("address","0x774"), +Attr("insn","stp x29, x30, [sp, #-0x30]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("#4",Imm(64)),Var("R29",Imm(64)),LittleEndian(),64)), +Def(Tid(896, "%00000380"), Attrs([Attr("address","0x774"), +Attr("insn","stp x29, x30, [sp, #-0x30]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("#4",Imm(64)),Int(8,64)),Var("R30",Imm(64)),LittleEndian(),64)), +Def(Tid(900, "%00000384"), Attrs([Attr("address","0x774"), +Attr("insn","stp x29, x30, [sp, #-0x30]!")]), Var("R31",Imm(64)), +Var("#4",Imm(64))), Def(Tid(906, "%0000038a"), + Attrs([Attr("address","0x778"), Attr("insn","mov x29, sp")]), + Var("R29",Imm(64)), Var("R31",Imm(64))), Def(Tid(911, "%0000038f"), + Attrs([Attr("address","0x77C"), Attr("insn","mov x0, #0x14")]), + Var("R0",Imm(64)), Int(20,64)), Def(Tid(916, "%00000394"), + Attrs([Attr("address","0x780"), Attr("insn","bl #-0x170")]), + Var("R30",Imm(64)), Int(1924,64))]), Jmps([Call(Tid(919, "%00000397"), + Attrs([Attr("address","0x780"), Attr("insn","bl #-0x170")]), Int(1,1), +(Direct(Tid(1_809, "@malloc")),Direct(Tid(921, "%00000399"))))])), +Blk(Tid(921, "%00000399"), Attrs([Attr("address","0x784")]), Phis([]), +Defs([Def(Tid(927, "%0000039f"), Attrs([Attr("address","0x784"), +Attr("insn","str x0, [sp, #0x18]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(24,64)),Var("R0",Imm(64)),LittleEndian(),64)), +Def(Tid(934, "%000003a6"), Attrs([Attr("address","0x788"), +Attr("insn","ldr x0, [sp, #0x18]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(24,64)),LittleEndian(),64)), +Def(Tid(939, "%000003ab"), Attrs([Attr("address","0x78C"), +Attr("insn","mov w1, #0xc")]), Var("R1",Imm(64)), Int(12,64)), +Def(Tid(947, "%000003b3"), Attrs([Attr("address","0x790"), +Attr("insn","str w1, [x0]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("R0",Imm(64)),Extract(31,0,Var("R1",Imm(64))),LittleEndian(),32)), +Def(Tid(954, "%000003ba"), Attrs([Attr("address","0x794"), +Attr("insn","ldr x0, [sp, #0x18]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(24,64)),LittleEndian(),64)), +Def(Tid(960, "%000003c0"), Attrs([Attr("address","0x798"), +Attr("insn","add x0, x0, #0x10")]), Var("R0",Imm(64)), +PLUS(Var("R0",Imm(64)),Int(16,64))), Def(Tid(968, "%000003c8"), + Attrs([Attr("address","0x79C"), Attr("insn","str x0, [sp, #0x20]")]), + Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(32,64)),Var("R0",Imm(64)),LittleEndian(),64)), +Def(Tid(975, "%000003cf"), Attrs([Attr("address","0x7A0"), +Attr("insn","ldr x0, [sp, #0x20]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(32,64)),LittleEndian(),64)), +Def(Tid(980, "%000003d4"), Attrs([Attr("address","0x7A4"), +Attr("insn","mov w1, #0xd")]), Var("R1",Imm(64)), Int(13,64)), +Def(Tid(988, "%000003dc"), Attrs([Attr("address","0x7A8"), +Attr("insn","str w1, [x0]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("R0",Imm(64)),Extract(31,0,Var("R1",Imm(64))),LittleEndian(),32)), +Def(Tid(995, "%000003e3"), Attrs([Attr("address","0x7AC"), +Attr("insn","ldr x0, [sp, #0x20]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(32,64)),LittleEndian(),64)), +Def(Tid(1_000, "%000003e8"), Attrs([Attr("address","0x7B0"), +Attr("insn","bl #-0x5c")]), Var("R30",Imm(64)), Int(1972,64))]), +Jmps([Call(Tid(1_002, "%000003ea"), Attrs([Attr("address","0x7B0"), +Attr("insn","bl #-0x5c")]), Int(1,1), +(Direct(Tid(1_803, "@callee")),Direct(Tid(1_004, "%000003ec"))))])), +Blk(Tid(1_004, "%000003ec"), Attrs([Attr("address","0x7B4")]), Phis([]), +Defs([Def(Tid(1_010, "%000003f2"), Attrs([Attr("address","0x7B4"), +Attr("insn","str x0, [sp, #0x28]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(40,64)),Var("R0",Imm(64)),LittleEndian(),64)), +Def(Tid(1_017, "%000003f9"), Attrs([Attr("address","0x7B8"), +Attr("insn","ldr x0, [sp, #0x28]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(40,64)),LittleEndian(),64)), +Def(Tid(1_022, "%000003fe"), Attrs([Attr("address","0x7BC"), +Attr("insn","mov w1, #0xe")]), Var("R1",Imm(64)), Int(14,64)), +Def(Tid(1_030, "%00000406"), Attrs([Attr("address","0x7C0"), +Attr("insn","str w1, [x0]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("R0",Imm(64)),Extract(31,0,Var("R1",Imm(64))),LittleEndian(),32)), +Def(Tid(1_035, "%0000040b"), Attrs([Attr("address","0x7C4"), +Attr("insn","mov w0, #0x0")]), Var("R0",Imm(64)), Int(0,64)), +Def(Tid(1_042, "%00000412"), Attrs([Attr("address","0x7C8"), +Attr("insn","ldp x29, x30, [sp], #0x30")]), Var("R29",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(1_047, "%00000417"), Attrs([Attr("address","0x7C8"), +Attr("insn","ldp x29, x30, [sp], #0x30")]), Var("R30",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(1_051, "%0000041b"), Attrs([Attr("address","0x7C8"), +Attr("insn","ldp x29, x30, [sp], #0x30")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(48,64)))]), Jmps([Call(Tid(1_056, "%00000420"), + Attrs([Attr("address","0x7CC"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))])), Sub(Tid(1_809, "@malloc"), + Attrs([Attr("address","0x610"), Attr("stub","()"), Attr("malloc","()"), +Attr("c.proto","void* (*)(unsigned long size)")]), "malloc", + Args([Arg(Tid(1_862, "%00000746"), Attrs([Attr("alloc-size","()"), +Attr("c.data","Top:u64"), Attr("c.layout","[unsigned long : 64]"), +Attr("c.type","unsigned long")]), Var("malloc_size",Imm(64)), +Var("R0",Imm(64)), In()), Arg(Tid(1_863, "%00000747"), + Attrs([Attr("warn-unused","()"), Attr("c.data","{} ptr"), +Attr("c.layout","*[ : 8]"), Attr("c.type","void*")]), + Var("malloc_result",Imm(64)), Var("R0",Imm(64)), Out())]), +Blks([Blk(Tid(917, "@malloc"), Attrs([Attr("address","0x610")]), Phis([]), +Defs([Def(Tid(1_399, "%00000577"), Attrs([Attr("address","0x610"), +Attr("insn","adrp x16, #126976")]), Var("R16",Imm(64)), Int(126976,64)), +Def(Tid(1_406, "%0000057e"), Attrs([Attr("address","0x614"), +Attr("insn","ldr x17, [x16, #0xfb8]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R16",Imm(64)),Int(4024,64)),LittleEndian(),64)), +Def(Tid(1_412, "%00000584"), Attrs([Attr("address","0x618"), +Attr("insn","add x16, x16, #0xfb8")]), Var("R16",Imm(64)), +PLUS(Var("R16",Imm(64)),Int(4024,64)))]), Jmps([Call(Tid(1_417, "%00000589"), + Attrs([Attr("address","0x61C"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), +Sub(Tid(1_810, "@register_tm_clones"), Attrs([Attr("address","0x6C0"), +Attr("c.proto","signed (*)(void)")]), "register_tm_clones", + Args([Arg(Tid(1_864, "%00000748"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("register_tm_clones_result",Imm(32)), LOW(32,Var("R0",Imm(64))), +Out())]), Blks([Blk(Tid(673, "@register_tm_clones"), + Attrs([Attr("address","0x6C0")]), Phis([]), Defs([Def(Tid(676, "%000002a4"), + Attrs([Attr("address","0x6C0"), Attr("insn","adrp x0, #131072")]), + Var("R0",Imm(64)), Int(131072,64)), Def(Tid(682, "%000002aa"), + Attrs([Attr("address","0x6C4"), Attr("insn","add x0, x0, #0x10")]), + Var("R0",Imm(64)), PLUS(Var("R0",Imm(64)),Int(16,64))), +Def(Tid(687, "%000002af"), Attrs([Attr("address","0x6C8"), +Attr("insn","adrp x1, #131072")]), Var("R1",Imm(64)), Int(131072,64)), +Def(Tid(693, "%000002b5"), Attrs([Attr("address","0x6CC"), +Attr("insn","add x1, x1, #0x10")]), Var("R1",Imm(64)), +PLUS(Var("R1",Imm(64)),Int(16,64))), Def(Tid(700, "%000002bc"), + Attrs([Attr("address","0x6D0"), Attr("insn","sub x1, x1, x0")]), + Var("R1",Imm(64)), +PLUS(PLUS(Var("R1",Imm(64)),NOT(Var("R0",Imm(64)))),Int(1,64))), +Def(Tid(706, "%000002c2"), Attrs([Attr("address","0x6D4"), +Attr("insn","lsr x2, x1, #63")]), Var("R2",Imm(64)), +Concat(Int(0,63),Extract(63,63,Var("R1",Imm(64))))), +Def(Tid(713, "%000002c9"), Attrs([Attr("address","0x6D8"), +Attr("insn","add x1, x2, x1, asr #3")]), Var("R1",Imm(64)), +PLUS(Var("R2",Imm(64)),ARSHIFT(Var("R1",Imm(64)),Int(3,3)))), +Def(Tid(719, "%000002cf"), Attrs([Attr("address","0x6DC"), +Attr("insn","asr x1, x1, #1")]), Var("R1",Imm(64)), +SIGNED(64,Extract(63,1,Var("R1",Imm(64)))))]), +Jmps([Goto(Tid(725, "%000002d5"), Attrs([Attr("address","0x6E0"), +Attr("insn","cbz x1, #0x18")]), EQ(Var("R1",Imm(64)),Int(0,64)), +Direct(Tid(723, "%000002d3"))), Goto(Tid(1_842, "%00000732"), Attrs([]), + Int(1,1), Direct(Tid(1_117, "%0000045d")))])), Blk(Tid(1_117, "%0000045d"), + Attrs([Attr("address","0x6E4")]), Phis([]), +Defs([Def(Tid(1_120, "%00000460"), Attrs([Attr("address","0x6E4"), +Attr("insn","adrp x2, #126976")]), Var("R2",Imm(64)), Int(126976,64)), +Def(Tid(1_127, "%00000467"), Attrs([Attr("address","0x6E8"), +Attr("insn","ldr x2, [x2, #0xff8]")]), Var("R2",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R2",Imm(64)),Int(4088,64)),LittleEndian(),64))]), +Jmps([Goto(Tid(1_132, "%0000046c"), Attrs([Attr("address","0x6EC"), +Attr("insn","cbz x2, #0xc")]), EQ(Var("R2",Imm(64)),Int(0,64)), +Direct(Tid(723, "%000002d3"))), Goto(Tid(1_843, "%00000733"), Attrs([]), + Int(1,1), Direct(Tid(1_136, "%00000470")))])), Blk(Tid(723, "%000002d3"), + Attrs([Attr("address","0x6F8")]), Phis([]), Defs([]), +Jmps([Call(Tid(731, "%000002db"), Attrs([Attr("address","0x6F8"), +Attr("insn","ret")]), Int(1,1), (Indirect(Var("R30",Imm(64))),))])), +Blk(Tid(1_136, "%00000470"), Attrs([Attr("address","0x6F0")]), Phis([]), +Defs([Def(Tid(1_140, "%00000474"), Attrs([Attr("address","0x6F0"), +Attr("insn","mov x16, x2")]), Var("R16",Imm(64)), Var("R2",Imm(64)))]), +Jmps([Call(Tid(1_145, "%00000479"), Attrs([Attr("address","0x6F4"), +Attr("insn","br x16")]), Int(1,1), +(Indirect(Var("R16",Imm(64))),))]))]))]))) \ No newline at end of file diff --git a/src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic.bir b/src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic.bir new file mode 100755 index 000000000..4329d89ad --- /dev/null +++ b/src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic.bir @@ -0,0 +1,279 @@ +00000715: program +000006fd: sub __cxa_finalize(__cxa_finalize_result) +00000716: __cxa_finalize_result :: out u32 = low:32[R0] + +00000459: +00000561: R16 := 0x1F000 +00000568: R17 := mem[R16 + 0xFB0, el]:u64 +0000056e: R16 := R16 + 0xFB0 +00000573: call R17 with noreturn + +000006fe: sub __do_global_dtors_aux(__do_global_dtors_aux_result) +00000717: __do_global_dtors_aux_result :: out u32 = low:32[R0] + +000002df: +000002e3: #3 := R31 - 0x20 +000002e9: mem := mem with [#3, el]:u64 <- R29 +000002ef: mem := mem with [#3 + 8, el]:u64 <- R30 +000002f3: R31 := #3 +000002f9: R29 := R31 +00000301: mem := mem with [R31 + 0x10, el]:u64 <- R19 +00000306: R19 := 0x20000 +0000030d: R0 := pad:64[mem[R19 + 0x10]] +00000314: when 31:0[R0] <> 0 goto %00000312 +000006ff: goto %00000422 + +00000422: +00000425: R0 := 0x1F000 +0000042c: R0 := mem[R0 + 0xFE0, el]:u64 +00000432: when R0 = 0 goto %00000430 +00000700: goto %00000449 + +00000449: +0000044c: R0 := 0x20000 +00000453: R0 := mem[R0 + 8, el]:u64 +00000458: R30 := 0x730 +0000045b: call @__cxa_finalize with return %00000430 + +00000430: +00000438: R30 := 0x734 +0000043a: call @deregister_tm_clones with return %0000043c + +0000043c: +0000043f: R0 := 1 +00000447: mem := mem with [R19 + 0x10] <- 7:0[R0] +00000701: goto %00000312 + +00000312: +0000031c: R19 := mem[R31 + 0x10, el]:u64 +00000323: R29 := mem[R31, el]:u64 +00000328: R30 := mem[R31 + 8, el]:u64 +0000032c: R31 := R31 + 0x20 +00000331: call R30 with noreturn + +00000702: sub __libc_start_main(__libc_start_main_main, __libc_start_main_arg2, __libc_start_main_arg3, __libc_start_main_auxv, __libc_start_main_result) +00000718: __libc_start_main_main :: in u64 = R0 +00000719: __libc_start_main_arg2 :: in u32 = low:32[R1] +0000071a: __libc_start_main_arg3 :: in out u64 = R2 +0000071b: __libc_start_main_auxv :: in out u64 = R3 +0000071c: __libc_start_main_result :: out u32 = low:32[R0] + +00000238: +0000054b: R16 := 0x1F000 +00000552: R17 := mem[R16 + 0xFA8, el]:u64 +00000558: R16 := R16 + 0xFA8 +0000055d: call R17 with noreturn + +00000703: sub _fini(_fini_result) +0000071d: _fini_result :: out u32 = low:32[R0] + +00000034: +0000003a: #0 := R31 - 0x10 +00000040: mem := mem with [#0, el]:u64 <- R29 +00000046: mem := mem with [#0 + 8, el]:u64 <- R30 +0000004a: R31 := #0 +00000050: R29 := R31 +00000057: R29 := mem[R31, el]:u64 +0000005c: R30 := mem[R31 + 8, el]:u64 +00000060: R31 := R31 + 0x10 +00000065: call R30 with noreturn + +00000704: sub _init(_init_result) +0000071e: _init_result :: out u32 = low:32[R0] + +0000063c: +00000642: #6 := R31 - 0x10 +00000648: mem := mem with [#6, el]:u64 <- R29 +0000064e: mem := mem with [#6 + 8, el]:u64 <- R30 +00000652: R31 := #6 +00000658: R29 := R31 +0000065d: R30 := 0x5C8 +0000065f: call @call_weak_fn with return %00000661 + +00000661: +00000666: R29 := mem[R31, el]:u64 +0000066b: R30 := mem[R31 + 8, el]:u64 +0000066f: R31 := R31 + 0x10 +00000674: call R30 with noreturn + +00000705: sub _start(_start_result) +0000071f: _start_result :: out u32 = low:32[R0] + +000001f9: +000001fe: R29 := 0 +00000203: R30 := 0 +00000209: R5 := R0 +00000210: R1 := mem[R31, el]:u64 +00000216: R2 := R31 + 8 +0000021c: R6 := R31 +00000221: R0 := 0x1F000 +00000228: R0 := mem[R0 + 0xFF0, el]:u64 +0000022d: R3 := 0 +00000232: R4 := 0 +00000237: R30 := 0x670 +0000023a: call @__libc_start_main with return %0000023c + +0000023c: +0000023f: R30 := 0x674 +00000242: call @abort with return %00000706 + +00000706: +00000707: call @call_weak_fn with noreturn + +00000708: sub abort() + + +00000240: +000005a3: R16 := 0x1F000 +000005aa: R17 := mem[R16 + 0xFC8, el]:u64 +000005b0: R16 := R16 + 0xFC8 +000005b5: call R17 with noreturn + +00000709: sub call_weak_fn(call_weak_fn_result) +00000720: call_weak_fn_result :: out u32 = low:32[R0] + +00000244: +00000247: R0 := 0x1F000 +0000024e: R0 := mem[R0 + 0xFE8, el]:u64 +00000254: when R0 = 0 goto %00000252 +0000070a: goto %00000499 + +00000252: +0000025a: call R30 with noreturn + +00000499: +0000049c: goto @__gmon_start__ + +0000049a: +0000058d: R16 := 0x1F000 +00000594: R17 := mem[R16 + 0xFC0, el]:u64 +0000059a: R16 := R16 + 0xFC0 +0000059f: call R17 with noreturn + +0000070b: sub callee(callee_result) +00000721: callee_result :: out u32 = low:32[R0] + +0000033b: +0000033f: R31 := R31 - 0x20 +00000347: mem := mem with [R31 + 8, el]:u64 <- R0 +0000034e: R0 := mem[R31 + 8, el]:u64 +00000354: R0 := R0 + 0x10 +0000035c: mem := mem with [R31 + 0x18, el]:u64 <- R0 +00000363: R0 := mem[R31 + 0x18, el]:u64 +00000369: R31 := R31 + 0x20 +0000036e: call R30 with noreturn + +0000070c: sub deregister_tm_clones(deregister_tm_clones_result) +00000722: deregister_tm_clones_result :: out u32 = low:32[R0] + +00000260: +00000263: R0 := 0x20000 +00000269: R0 := R0 + 0x10 +0000026e: R1 := 0x20000 +00000274: R1 := R1 + 0x10 +0000027a: #1 := ~R0 +0000027f: #2 := R1 + ~R0 +00000285: VF := extend:65[#2 + 1] <> extend:65[R1] + extend:65[#1] + 1 +0000028b: CF := pad:65[#2 + 1] <> pad:65[R1] + pad:65[#1] + 1 +0000028f: ZF := #2 + 1 = 0 +00000293: NF := 63:63[#2 + 1] +00000299: when ZF goto %00000297 +0000070d: goto %0000047b + +0000047b: +0000047e: R1 := 0x1F000 +00000485: R1 := mem[R1 + 0xFD8, el]:u64 +0000048a: when R1 = 0 goto %00000297 +0000070e: goto %0000048e + +00000297: +0000029f: call R30 with noreturn + +0000048e: +00000492: R16 := R1 +00000497: call R16 with noreturn + +0000070f: sub frame_dummy(frame_dummy_result) +00000723: frame_dummy_result :: out u32 = low:32[R0] + +00000337: +00000339: call @register_tm_clones with noreturn + +00000710: sub main(main_argc, main_argv, main_result) +00000724: main_argc :: in u32 = low:32[R0] +00000725: main_argv :: in out u64 = R1 +00000726: main_result :: out u32 = low:32[R0] + +00000370: +00000374: #4 := R31 - 0x30 +0000037a: mem := mem with [#4, el]:u64 <- R29 +00000380: mem := mem with [#4 + 8, el]:u64 <- R30 +00000384: R31 := #4 +0000038a: R29 := R31 +0000038f: R0 := 0x14 +00000394: R30 := 0x784 +00000397: call @malloc with return %00000399 + +00000399: +0000039f: mem := mem with [R31 + 0x18, el]:u64 <- R0 +000003a6: R0 := mem[R31 + 0x18, el]:u64 +000003ab: R1 := 0xC +000003b3: mem := mem with [R0, el]:u32 <- 31:0[R1] +000003ba: R0 := mem[R31 + 0x18, el]:u64 +000003c0: R0 := R0 + 0x10 +000003c8: mem := mem with [R31 + 0x20, el]:u64 <- R0 +000003cf: R0 := mem[R31 + 0x20, el]:u64 +000003d4: R1 := 0xD +000003dc: mem := mem with [R0, el]:u32 <- 31:0[R1] +000003e3: R0 := mem[R31 + 0x20, el]:u64 +000003e8: R30 := 0x7B4 +000003ea: call @callee with return %000003ec + +000003ec: +000003f2: mem := mem with [R31 + 0x28, el]:u64 <- R0 +000003f9: R0 := mem[R31 + 0x28, el]:u64 +000003fe: R1 := 0xE +00000406: mem := mem with [R0, el]:u32 <- 31:0[R1] +0000040b: R0 := 0 +00000412: R29 := mem[R31, el]:u64 +00000417: R30 := mem[R31 + 8, el]:u64 +0000041b: R31 := R31 + 0x30 +00000420: call R30 with noreturn + +00000711: sub malloc(malloc_size, malloc_result) +00000727: malloc_size :: in u64 = R0 +00000728: malloc_result :: out u64 = R0 + +00000395: +00000577: R16 := 0x1F000 +0000057e: R17 := mem[R16 + 0xFB8, el]:u64 +00000584: R16 := R16 + 0xFB8 +00000589: call R17 with noreturn + +00000712: sub register_tm_clones(register_tm_clones_result) +00000729: register_tm_clones_result :: out u32 = low:32[R0] + +000002a1: +000002a4: R0 := 0x20000 +000002aa: R0 := R0 + 0x10 +000002af: R1 := 0x20000 +000002b5: R1 := R1 + 0x10 +000002bc: R1 := R1 + ~R0 + 1 +000002c2: R2 := 0.63:63[R1] +000002c9: R1 := R2 + (R1 ~>> 3) +000002cf: R1 := extend:64[63:1[R1]] +000002d5: when R1 = 0 goto %000002d3 +00000713: goto %0000045d + +0000045d: +00000460: R2 := 0x1F000 +00000467: R2 := mem[R2 + 0xFF8, el]:u64 +0000046c: when R2 = 0 goto %000002d3 +00000714: goto %00000470 + +000002d3: +000002db: call R30 with noreturn + +00000470: +00000474: R16 := R2 +00000479: call R16 with noreturn diff --git a/src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic.c b/src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic.c new file mode 100644 index 000000000..1d02bae06 --- /dev/null +++ b/src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic.c @@ -0,0 +1,14 @@ +#include +int* callee(int* arg) { + int* ret = arg + sizeof(int); // this is wrong + return ret; +} + +int main() { + int *bar = malloc(5 * sizeof(int)); + *bar = 12; + int* foo = bar + sizeof(int); + *foo = 13; + int* bat = callee(foo); + *bat = 14; +} diff --git a/src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic.relf b/src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic.relf new file mode 100755 index 000000000..3fb1fea4c --- /dev/null +++ b/src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic.relf @@ -0,0 +1,123 @@ + +Relocation section '.rela.dyn' at offset 0x480 contains 8 entries: + Offset Info Type Symbol's Value Symbol's Name + Addend +000000000001fd90 0000000000000403 R_AARCH64_RELATIVE 750 +000000000001fd98 0000000000000403 R_AARCH64_RELATIVE 700 +000000000001fff0 0000000000000403 R_AARCH64_RELATIVE 774 +0000000000020008 0000000000000403 R_AARCH64_RELATIVE 20008 +000000000001ffd8 0000000400000401 R_AARCH64_GLOB_DAT 0000000000000000 _ITM_deregisterTMCloneTable + 0 +000000000001ffe0 0000000500000401 R_AARCH64_GLOB_DAT 0000000000000000 __cxa_finalize@GLIBC_2.17 + 0 +000000000001ffe8 0000000700000401 R_AARCH64_GLOB_DAT 0000000000000000 __gmon_start__ + 0 +000000000001fff8 0000000900000401 R_AARCH64_GLOB_DAT 0000000000000000 _ITM_registerTMCloneTable + 0 + +Relocation section '.rela.plt' at offset 0x540 contains 5 entries: + Offset Info Type Symbol's Value Symbol's Name + Addend +000000000001ffa8 0000000300000402 R_AARCH64_JUMP_SLOT 0000000000000000 __libc_start_main@GLIBC_2.34 + 0 +000000000001ffb0 0000000500000402 R_AARCH64_JUMP_SLOT 0000000000000000 __cxa_finalize@GLIBC_2.17 + 0 +000000000001ffb8 0000000600000402 R_AARCH64_JUMP_SLOT 0000000000000000 malloc@GLIBC_2.17 + 0 +000000000001ffc0 0000000700000402 R_AARCH64_JUMP_SLOT 0000000000000000 __gmon_start__ + 0 +000000000001ffc8 0000000800000402 R_AARCH64_JUMP_SLOT 0000000000000000 abort@GLIBC_2.17 + 0 + +Symbol table '.dynsym' contains 10 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 00000000000005b8 0 SECTION LOCAL DEFAULT 11 .init + 2: 0000000000020000 0 SECTION LOCAL DEFAULT 22 .data + 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.34 (2) + 4: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTable + 5: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@GLIBC_2.17 (3) + 6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND malloc@GLIBC_2.17 (3) + 7: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__ + 8: 0000000000000000 0 FUNC GLOBAL DEFAULT UND abort@GLIBC_2.17 (3) + 9: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable + +Symbol table '.symtab' contains 88 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000000238 0 SECTION LOCAL DEFAULT 1 .interp + 2: 0000000000000254 0 SECTION LOCAL DEFAULT 2 .note.gnu.build-id + 3: 0000000000000278 0 SECTION LOCAL DEFAULT 3 .note.ABI-tag + 4: 0000000000000298 0 SECTION LOCAL DEFAULT 4 .gnu.hash + 5: 00000000000002b8 0 SECTION LOCAL DEFAULT 5 .dynsym + 6: 00000000000003a8 0 SECTION LOCAL DEFAULT 6 .dynstr + 7: 000000000000043c 0 SECTION LOCAL DEFAULT 7 .gnu.version + 8: 0000000000000450 0 SECTION LOCAL DEFAULT 8 .gnu.version_r + 9: 0000000000000480 0 SECTION LOCAL DEFAULT 9 .rela.dyn + 10: 0000000000000540 0 SECTION LOCAL DEFAULT 10 .rela.plt + 11: 00000000000005b8 0 SECTION LOCAL DEFAULT 11 .init + 12: 00000000000005d0 0 SECTION LOCAL DEFAULT 12 .plt + 13: 0000000000000640 0 SECTION LOCAL DEFAULT 13 .text + 14: 00000000000007d0 0 SECTION LOCAL DEFAULT 14 .fini + 15: 00000000000007e4 0 SECTION LOCAL DEFAULT 15 .rodata + 16: 00000000000007e8 0 SECTION LOCAL DEFAULT 16 .eh_frame_hdr + 17: 0000000000000830 0 SECTION LOCAL DEFAULT 17 .eh_frame + 18: 000000000001fd90 0 SECTION LOCAL DEFAULT 18 .init_array + 19: 000000000001fd98 0 SECTION LOCAL DEFAULT 19 .fini_array + 20: 000000000001fda0 0 SECTION LOCAL DEFAULT 20 .dynamic + 21: 000000000001ff90 0 SECTION LOCAL DEFAULT 21 .got + 22: 0000000000020000 0 SECTION LOCAL DEFAULT 22 .data + 23: 0000000000020010 0 SECTION LOCAL DEFAULT 23 .bss + 24: 0000000000000000 0 SECTION LOCAL DEFAULT 24 .comment + 25: 0000000000000000 0 FILE LOCAL DEFAULT ABS Scrt1.o + 26: 0000000000000278 0 NOTYPE LOCAL DEFAULT 3 $d + 27: 0000000000000278 32 OBJECT LOCAL DEFAULT 3 __abi_tag + 28: 0000000000000640 0 NOTYPE LOCAL DEFAULT 13 $x + 29: 0000000000000844 0 NOTYPE LOCAL DEFAULT 17 $d + 30: 00000000000007e4 0 NOTYPE LOCAL DEFAULT 15 $d + 31: 0000000000000000 0 FILE LOCAL DEFAULT ABS crti.o + 32: 0000000000000674 0 NOTYPE LOCAL DEFAULT 13 $x + 33: 0000000000000674 20 FUNC LOCAL DEFAULT 13 call_weak_fn + 34: 00000000000005b8 0 NOTYPE LOCAL DEFAULT 11 $x + 35: 00000000000007d0 0 NOTYPE LOCAL DEFAULT 14 $x + 36: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtn.o + 37: 00000000000005c8 0 NOTYPE LOCAL DEFAULT 11 $x + 38: 00000000000007dc 0 NOTYPE LOCAL DEFAULT 14 $x + 39: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c + 40: 0000000000000690 0 NOTYPE LOCAL DEFAULT 13 $x + 41: 0000000000000690 0 FUNC LOCAL DEFAULT 13 deregister_tm_clones + 42: 00000000000006c0 0 FUNC LOCAL DEFAULT 13 register_tm_clones + 43: 0000000000020008 0 NOTYPE LOCAL DEFAULT 22 $d + 44: 0000000000000700 0 FUNC LOCAL DEFAULT 13 __do_global_dtors_aux + 45: 0000000000020010 1 OBJECT LOCAL DEFAULT 23 completed.0 + 46: 000000000001fd98 0 NOTYPE LOCAL DEFAULT 19 $d + 47: 000000000001fd98 0 OBJECT LOCAL DEFAULT 19 __do_global_dtors_aux_fini_array_entry + 48: 0000000000000750 0 FUNC LOCAL DEFAULT 13 frame_dummy + 49: 000000000001fd90 0 NOTYPE LOCAL DEFAULT 18 $d + 50: 000000000001fd90 0 OBJECT LOCAL DEFAULT 18 __frame_dummy_init_array_entry + 51: 0000000000000858 0 NOTYPE LOCAL DEFAULT 17 $d + 52: 0000000000020010 0 NOTYPE LOCAL DEFAULT 23 $d + 53: 0000000000000000 0 FILE LOCAL DEFAULT ABS interproc_pointer_arithmetic.c + 54: 0000000000000754 0 NOTYPE LOCAL DEFAULT 13 $x + 55: 00000000000008b8 0 NOTYPE LOCAL DEFAULT 17 $d + 56: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c + 57: 00000000000008f0 0 NOTYPE LOCAL DEFAULT 17 $d + 58: 00000000000008f0 0 OBJECT LOCAL DEFAULT 17 __FRAME_END__ + 59: 0000000000000000 0 FILE LOCAL DEFAULT ABS + 60: 000000000001fda0 0 OBJECT LOCAL DEFAULT ABS _DYNAMIC + 61: 00000000000007e8 0 NOTYPE LOCAL DEFAULT 16 __GNU_EH_FRAME_HDR + 62: 000000000001ffd0 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ + 63: 00000000000005d0 0 NOTYPE LOCAL DEFAULT 12 $x + 64: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.34 + 65: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTable + 66: 0000000000020000 0 NOTYPE WEAK DEFAULT 22 data_start + 67: 0000000000020010 0 NOTYPE GLOBAL DEFAULT 23 __bss_start__ + 68: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@GLIBC_2.17 + 69: 0000000000020018 0 NOTYPE GLOBAL DEFAULT 23 _bss_end__ + 70: 0000000000020010 0 NOTYPE GLOBAL DEFAULT 22 _edata + 71: 00000000000007d0 0 FUNC GLOBAL HIDDEN 14 _fini + 72: 0000000000020018 0 NOTYPE GLOBAL DEFAULT 23 __bss_end__ + 73: 0000000000000000 0 FUNC GLOBAL DEFAULT UND malloc@GLIBC_2.17 + 74: 0000000000020000 0 NOTYPE GLOBAL DEFAULT 22 __data_start + 75: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__ + 76: 0000000000020008 0 OBJECT GLOBAL HIDDEN 22 __dso_handle + 77: 0000000000000000 0 FUNC GLOBAL DEFAULT UND abort@GLIBC_2.17 + 78: 00000000000007e4 4 OBJECT GLOBAL DEFAULT 15 _IO_stdin_used + 79: 0000000000020018 0 NOTYPE GLOBAL DEFAULT 23 _end + 80: 0000000000000640 52 FUNC GLOBAL DEFAULT 13 _start + 81: 0000000000020018 0 NOTYPE GLOBAL DEFAULT 23 __end__ + 82: 0000000000020010 0 NOTYPE GLOBAL DEFAULT 23 __bss_start + 83: 0000000000000774 92 FUNC GLOBAL DEFAULT 13 main + 84: 0000000000000754 32 FUNC GLOBAL DEFAULT 13 callee + 85: 0000000000020010 0 OBJECT GLOBAL HIDDEN 22 __TMC_END__ + 86: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable + 87: 00000000000005b8 0 FUNC GLOBAL HIDDEN 11 _init diff --git a/src/test/dsa/unsafe_pointer_arithmetic/unsafe_pointer_arithmetic.adt b/src/test/dsa/unsafe_pointer_arithmetic/unsafe_pointer_arithmetic.adt new file mode 100644 index 000000000..b112faabc --- /dev/null +++ b/src/test/dsa/unsafe_pointer_arithmetic/unsafe_pointer_arithmetic.adt @@ -0,0 +1,586 @@ +Project(Attrs([Attr("filename","unsafe_pointer_arithmetic.out"), +Attr("image-specification","(declare abi (name str))\n(declare arch (name str))\n(declare base-address (addr int))\n(declare bias (off int))\n(declare bits (size int))\n(declare code-region (addr int) (size int) (off int))\n(declare code-start (addr int))\n(declare entry-point (addr int))\n(declare external-reference (addr int) (name str))\n(declare format (name str))\n(declare is-executable (flag bool))\n(declare is-little-endian (flag bool))\n(declare llvm:base-address (addr int))\n(declare llvm:code-entry (name str) (off int) (size int))\n(declare llvm:coff-import-library (name str))\n(declare llvm:coff-virtual-section-header (name str) (addr int) (size int))\n(declare llvm:elf-program-header (name str) (off int) (size int))\n(declare llvm:elf-program-header-flags (name str) (ld bool) (r bool) \n (w bool) (x bool))\n(declare llvm:elf-virtual-program-header (name str) (addr int) (size int))\n(declare llvm:entry-point (addr int))\n(declare llvm:macho-symbol (name str) (value int))\n(declare llvm:name-reference (at int) (name str))\n(declare llvm:relocation (at int) (addr int))\n(declare llvm:section-entry (name str) (addr int) (size int) (off int))\n(declare llvm:section-flags (name str) (r bool) (w bool) (x bool))\n(declare llvm:segment-command (name str) (off int) (size int))\n(declare llvm:segment-command-flags (name str) (r bool) (w bool) (x bool))\n(declare llvm:symbol-entry (name str) (addr int) (size int) (off int)\n (value int))\n(declare llvm:virtual-segment-command (name str) (addr int) (size int))\n(declare mapped (addr int) (size int) (off int))\n(declare named-region (addr int) (size int) (name str))\n(declare named-symbol (addr int) (name str))\n(declare require (name str))\n(declare section (addr int) (size int))\n(declare segment (addr int) (size int) (r bool) (w bool) (x bool))\n(declare subarch (name str))\n(declare symbol-chunk (addr int) (size int) (root int))\n(declare symbol-value (addr int) (value int))\n(declare system (name str))\n(declare vendor (name str))\n\n(abi unknown)\n(arch aarch64)\n(base-address 0)\n(bias 0)\n(bits 64)\n(code-region 1976 20 1976)\n(code-region 1600 376 1600)\n(code-region 1488 112 1488)\n(code-region 1464 24 1464)\n(code-start 1652)\n(code-start 1600)\n(code-start 1876)\n(entry-point 1600)\n(external-reference 131032 _ITM_deregisterTMCloneTable)\n(external-reference 131040 __cxa_finalize)\n(external-reference 131048 __gmon_start__)\n(external-reference 131064 _ITM_registerTMCloneTable)\n(external-reference 130984 __libc_start_main)\n(external-reference 130992 __cxa_finalize)\n(external-reference 131000 malloc)\n(external-reference 131008 __gmon_start__)\n(external-reference 131016 abort)\n(format elf)\n(is-executable true)\n(is-little-endian true)\n(llvm:base-address 0)\n(llvm:code-entry abort 0 0)\n(llvm:code-entry malloc 0 0)\n(llvm:code-entry __cxa_finalize 0 0)\n(llvm:code-entry __libc_start_main 0 0)\n(llvm:code-entry _init 1464 0)\n(llvm:code-entry main 1876 100)\n(llvm:code-entry _start 1600 52)\n(llvm:code-entry abort@GLIBC_2.17 0 0)\n(llvm:code-entry malloc@GLIBC_2.17 0 0)\n(llvm:code-entry _fini 1976 0)\n(llvm:code-entry __cxa_finalize@GLIBC_2.17 0 0)\n(llvm:code-entry __libc_start_main@GLIBC_2.34 0 0)\n(llvm:code-entry frame_dummy 1872 0)\n(llvm:code-entry __do_global_dtors_aux 1792 0)\n(llvm:code-entry register_tm_clones 1728 0)\n(llvm:code-entry deregister_tm_clones 1680 0)\n(llvm:code-entry call_weak_fn 1652 20)\n(llvm:code-entry .fini 1976 20)\n(llvm:code-entry .text 1600 376)\n(llvm:code-entry .plt 1488 112)\n(llvm:code-entry .init 1464 24)\n(llvm:elf-program-header 08 64912 624)\n(llvm:elf-program-header 07 0 0)\n(llvm:elf-program-header 06 2000 60)\n(llvm:elf-program-header 05 596 68)\n(llvm:elf-program-header 04 64928 496)\n(llvm:elf-program-header 03 64912 640)\n(llvm:elf-program-header 02 0 2236)\n(llvm:elf-program-header 01 568 27)\n(llvm:elf-program-header 00 64 504)\n(llvm:elf-program-header-flags 08 false true false false)\n(llvm:elf-program-header-flags 07 false true true false)\n(llvm:elf-program-header-flags 06 false true false false)\n(llvm:elf-program-header-flags 05 false true false false)\n(llvm:elf-program-header-flags 04 false true true false)\n(llvm:elf-program-header-flags 03 true true true false)\n(llvm:elf-program-header-flags 02 true true false true)\n(llvm:elf-program-header-flags 01 false true false false)\n(llvm:elf-program-header-flags 00 false true false false)\n(llvm:elf-virtual-program-header 08 130448 624)\n(llvm:elf-virtual-program-header 07 0 0)\n(llvm:elf-virtual-program-header 06 2000 60)\n(llvm:elf-virtual-program-header 05 596 68)\n(llvm:elf-virtual-program-header 04 130464 496)\n(llvm:elf-virtual-program-header 03 130448 648)\n(llvm:elf-virtual-program-header 02 0 2236)\n(llvm:elf-virtual-program-header 01 568 27)\n(llvm:elf-virtual-program-header 00 64 504)\n(llvm:entry-point 1600)\n(llvm:name-reference 131016 abort)\n(llvm:name-reference 131008 __gmon_start__)\n(llvm:name-reference 131000 malloc)\n(llvm:name-reference 130992 __cxa_finalize)\n(llvm:name-reference 130984 __libc_start_main)\n(llvm:name-reference 131064 _ITM_registerTMCloneTable)\n(llvm:name-reference 131048 __gmon_start__)\n(llvm:name-reference 131040 __cxa_finalize)\n(llvm:name-reference 131032 _ITM_deregisterTMCloneTable)\n(llvm:section-entry .shstrtab 0 250 68267)\n(llvm:section-entry .strtab 0 579 67688)\n(llvm:section-entry .symtab 0 2088 65600)\n(llvm:section-entry .comment 0 43 65552)\n(llvm:section-entry .bss 131088 8 65552)\n(llvm:section-entry .data 131072 16 65536)\n(llvm:section-entry .got 130960 112 65424)\n(llvm:section-entry .dynamic 130464 496 64928)\n(llvm:section-entry .fini_array 130456 8 64920)\n(llvm:section-entry .init_array 130448 8 64912)\n(llvm:section-entry .eh_frame 2064 172 2064)\n(llvm:section-entry .eh_frame_hdr 2000 60 2000)\n(llvm:section-entry .rodata 1996 4 1996)\n(llvm:section-entry .fini 1976 20 1976)\n(llvm:section-entry .text 1600 376 1600)\n(llvm:section-entry .plt 1488 112 1488)\n(llvm:section-entry .init 1464 24 1464)\n(llvm:section-entry .rela.plt 1344 120 1344)\n(llvm:section-entry .rela.dyn 1152 192 1152)\n(llvm:section-entry .gnu.version_r 1104 48 1104)\n(llvm:section-entry .gnu.version 1084 20 1084)\n(llvm:section-entry .dynstr 936 148 936)\n(llvm:section-entry .dynsym 696 240 696)\n(llvm:section-entry .gnu.hash 664 28 664)\n(llvm:section-entry .note.ABI-tag 632 32 632)\n(llvm:section-entry .note.gnu.build-id 596 36 596)\n(llvm:section-entry .interp 568 27 568)\n(llvm:section-flags .shstrtab true false false)\n(llvm:section-flags .strtab true false false)\n(llvm:section-flags .symtab true false false)\n(llvm:section-flags .comment true false false)\n(llvm:section-flags .bss true true false)\n(llvm:section-flags .data true true false)\n(llvm:section-flags .got true true false)\n(llvm:section-flags .dynamic true true false)\n(llvm:section-flags .fini_array true true false)\n(llvm:section-flags .init_array true true false)\n(llvm:section-flags .eh_frame true false false)\n(llvm:section-flags .eh_frame_hdr true false false)\n(llvm:section-flags .rodata true false false)\n(llvm:section-flags .fini true false true)\n(llvm:section-flags .text true false true)\n(llvm:section-flags .plt true false true)\n(llvm:section-flags .init true false true)\n(llvm:section-flags .rela.plt true false false)\n(llvm:section-flags .rela.dyn true false false)\n(llvm:section-flags .gnu.version_r true false false)\n(llvm:section-flags .gnu.version true false false)\n(llvm:section-flags .dynstr true false false)\n(llvm:section-flags .dynsym true false false)\n(llvm:section-flags .gnu.hash true false false)\n(llvm:section-flags .note.ABI-tag true false false)\n(llvm:section-flags .note.gnu.build-id true false false)\n(llvm:section-flags .interp true false false)\n(llvm:symbol-entry abort 0 0 0 0)\n(llvm:symbol-entry malloc 0 0 0 0)\n(llvm:symbol-entry __cxa_finalize 0 0 0 0)\n(llvm:symbol-entry __libc_start_main 0 0 0 0)\n(llvm:symbol-entry _init 1464 0 1464 1464)\n(llvm:symbol-entry main 1876 100 1876 1876)\n(llvm:symbol-entry _start 1600 52 1600 1600)\n(llvm:symbol-entry abort@GLIBC_2.17 0 0 0 0)\n(llvm:symbol-entry malloc@GLIBC_2.17 0 0 0 0)\n(llvm:symbol-entry _fini 1976 0 1976 1976)\n(llvm:symbol-entry __cxa_finalize@GLIBC_2.17 0 0 0 0)\n(llvm:symbol-entry __libc_start_main@GLIBC_2.34 0 0 0 0)\n(llvm:symbol-entry frame_dummy 1872 0 1872 1872)\n(llvm:symbol-entry __do_global_dtors_aux 1792 0 1792 1792)\n(llvm:symbol-entry register_tm_clones 1728 0 1728 1728)\n(llvm:symbol-entry deregister_tm_clones 1680 0 1680 1680)\n(llvm:symbol-entry call_weak_fn 1652 20 1652 1652)\n(mapped 0 2236 0)\n(mapped 130448 640 64912)\n(named-region 0 2236 02)\n(named-region 130448 648 03)\n(named-region 568 27 .interp)\n(named-region 596 36 .note.gnu.build-id)\n(named-region 632 32 .note.ABI-tag)\n(named-region 664 28 .gnu.hash)\n(named-region 696 240 .dynsym)\n(named-region 936 148 .dynstr)\n(named-region 1084 20 .gnu.version)\n(named-region 1104 48 .gnu.version_r)\n(named-region 1152 192 .rela.dyn)\n(named-region 1344 120 .rela.plt)\n(named-region 1464 24 .init)\n(named-region 1488 112 .plt)\n(named-region 1600 376 .text)\n(named-region 1976 20 .fini)\n(named-region 1996 4 .rodata)\n(named-region 2000 60 .eh_frame_hdr)\n(named-region 2064 172 .eh_frame)\n(named-region 130448 8 .init_array)\n(named-region 130456 8 .fini_array)\n(named-region 130464 496 .dynamic)\n(named-region 130960 112 .got)\n(named-region 131072 16 .data)\n(named-region 131088 8 .bss)\n(named-region 0 43 .comment)\n(named-region 0 2088 .symtab)\n(named-region 0 579 .strtab)\n(named-region 0 250 .shstrtab)\n(named-symbol 1652 call_weak_fn)\n(named-symbol 1680 deregister_tm_clones)\n(named-symbol 1728 register_tm_clones)\n(named-symbol 1792 __do_global_dtors_aux)\n(named-symbol 1872 frame_dummy)\n(named-symbol 0 __libc_start_main@GLIBC_2.34)\n(named-symbol 0 __cxa_finalize@GLIBC_2.17)\n(named-symbol 1976 _fini)\n(named-symbol 0 malloc@GLIBC_2.17)\n(named-symbol 0 abort@GLIBC_2.17)\n(named-symbol 1600 _start)\n(named-symbol 1876 main)\n(named-symbol 1464 _init)\n(named-symbol 0 __libc_start_main)\n(named-symbol 0 __cxa_finalize)\n(named-symbol 0 malloc)\n(named-symbol 0 abort)\n(require libc.so.6)\n(section 568 27)\n(section 596 36)\n(section 632 32)\n(section 664 28)\n(section 696 240)\n(section 936 148)\n(section 1084 20)\n(section 1104 48)\n(section 1152 192)\n(section 1344 120)\n(section 1464 24)\n(section 1488 112)\n(section 1600 376)\n(section 1976 20)\n(section 1996 4)\n(section 2000 60)\n(section 2064 172)\n(section 130448 8)\n(section 130456 8)\n(section 130464 496)\n(section 130960 112)\n(section 131072 16)\n(section 131088 8)\n(section 0 43)\n(section 0 2088)\n(section 0 579)\n(section 0 250)\n(segment 0 2236 true false true)\n(segment 130448 648 true true false)\n(subarch v8)\n(symbol-chunk 1652 20 1652)\n(symbol-chunk 1600 52 1600)\n(symbol-chunk 1876 100 1876)\n(symbol-value 1652 1652)\n(symbol-value 1680 1680)\n(symbol-value 1728 1728)\n(symbol-value 1792 1792)\n(symbol-value 1872 1872)\n(symbol-value 1976 1976)\n(symbol-value 1600 1600)\n(symbol-value 1876 1876)\n(symbol-value 1464 1464)\n(symbol-value 0 0)\n(system \"\")\n(vendor \"\")\n"), +Attr("abi-name","aarch64-linux-gnu-elf")]), +Sections([Section(".shstrtab", 0x0, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7\x00\x01\x00\x00\x00\x40\x06\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xa8\x0b\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x38\x00\x09\x00\x40\x00\x1c\x00\x1b\x00\x06\x00\x00\x00\x04\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbc\x08\x00\x00\x00\x00\x00\x00\xbc\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x00\x00\x06\x00\x00\x00\x90\xfd\x00\x00\x00\x00\x00\x00\x90\xfd"), +Section(".strtab", 0x0, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7\x00\x01\x00\x00\x00\x40\x06\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xa8\x0b\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x38\x00\x09\x00\x40\x00\x1c\x00\x1b\x00\x06\x00\x00\x00\x04\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbc\x08\x00\x00\x00\x00\x00\x00\xbc\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x00\x00\x06\x00\x00\x00\x90\xfd\x00\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x80\x02\x00\x00\x00\x00\x00\x00\x88\x02\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x02\x00\x00\x00\x06\x00\x00\x00\xa0\xfd\x00\x00\x00\x00\x00\x00\xa0\xfd\x01\x00\x00\x00\x00\x00\xa0\xfd\x01\x00\x00\x00\x00\x00\xf0\x01\x00\x00\x00\x00\x00\x00\xf0\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x50\xe5\x74\x64\x04\x00\x00\x00\xd0\x07\x00\x00\x00\x00\x00\x00\xd0\x07\x00\x00\x00\x00\x00\x00\xd0\x07\x00\x00\x00\x00\x00\x00\x3c\x00\x00\x00\x00\x00\x00\x00\x3c\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x51\xe5\x74\x64\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x52\xe5\x74\x64\x04\x00\x00\x00\x90\xfd\x00\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x70\x02\x00\x00\x00\x00\x00\x00\x70\x02\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x2f\x6c\x69\x62\x2f\x6c\x64\x2d\x6c\x69\x6e"), +Section(".symtab", 0x0, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7\x00\x01\x00\x00\x00\x40\x06\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xa8\x0b\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x38\x00\x09\x00\x40\x00\x1c\x00\x1b\x00\x06\x00\x00\x00\x04\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\xf8\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x38\x02\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbc\x08\x00\x00\x00\x00\x00\x00\xbc\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x00\x00\x06\x00\x00\x00\x90\xfd\x00\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x80\x02\x00\x00\x00\x00\x00\x00\x88\x02\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x02\x00\x00\x00\x06\x00\x00\x00\xa0\xfd\x00\x00\x00\x00\x00\x00\xa0\xfd\x01\x00\x00\x00\x00\x00\xa0\xfd\x01\x00\x00\x00\x00\x00\xf0\x01\x00\x00\x00\x00\x00\x00\xf0\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x54\x02\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x50\xe5\x74\x64\x04\x00\x00\x00\xd0\x07\x00\x00\x00\x00\x00\x00\xd0\x07\x00\x00\x00\x00\x00\x00\xd0\x07\x00\x00\x00\x00\x00\x00\x3c\x00\x00\x00\x00\x00\x00\x00\x3c\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x51\xe5\x74\x64\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x52\xe5\x74\x64\x04\x00\x00\x00\x90\xfd\x00\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x70\x02\x00\x00\x00\x00\x00\x00\x70\x02\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x2f\x6c\x69\x62\x2f\x6c\x64\x2d\x6c\x69\x6e\x75\x78\x2d\x61\x61\x72\x63\x68\x36\x34\x2e\x73\x6f\x2e\x31\x00\x00\x04\x00\x00\x00\x14\x00\x00\x00\x03\x00\x00\x00\x47\x4e\x55\x00\xe7\x83\xd0\x0b\x65\xff\x69\x99\x15\x9f\x13\x77\x3c\xa9\xc0\x82\xdf\x41\xac\xfa\x04\x00\x00\x00\x10\x00\x00\x00\x01\x00\x00\x00\x47\x4e\x55\x00\x00\x00\x00\x00\x03\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x0b\x00\xb8\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x16\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4f\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6b\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x29\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7a\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6d\x61\x6c\x6c\x6f\x63\x00\x5f\x5f\x6c\x69\x62\x63\x5f\x73\x74\x61\x72\x74\x5f\x6d\x61\x69\x6e\x00\x5f\x5f\x63\x78\x61\x5f\x66\x69\x6e\x61\x6c\x69\x7a\x65\x00\x61\x62\x6f\x72\x74\x00\x6c\x69\x62\x63\x2e\x73\x6f\x2e\x36\x00\x47\x4c\x49\x42\x43\x5f\x32\x2e\x31\x37\x00\x47\x4c\x49\x42\x43\x5f\x32\x2e\x33\x34\x00\x5f\x49\x54\x4d\x5f\x64\x65\x72\x65\x67\x69\x73\x74\x65\x72\x54\x4d\x43\x6c\x6f\x6e\x65\x54\x61\x62\x6c\x65\x00\x5f\x5f\x67\x6d\x6f\x6e\x5f\x73\x74\x61\x72\x74\x5f\x5f\x00\x5f\x49\x54\x4d\x5f\x72\x65\x67\x69\x73\x74\x65\x72\x54\x4d\x43\x6c\x6f\x6e\x65\x54\x61\x62\x6c\x65\x00\x00\x00\x00\x00\x00\x00\x02\x00\x01\x00\x03\x00\x03\x00\x01\x00\x03\x00\x01\x00\x01\x00\x02\x00\x2f\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x97\x91\x96\x06\x00\x00\x03\x00\x39\x00\x00\x00\x10\x00\x00\x00\xb4\x91\x96\x06\x00\x00\x02\x00\x44\x00\x00\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x50\x07\x00\x00\x00\x00\x00\x00\x98\xfd\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\xf0\xff\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x54\x07\x00\x00\x00\x00\x00\x00\x08\x00\x02\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x08\x00\x02\x00\x00\x00\x00\x00\xd8\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe8\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa8\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb0\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb8\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc8\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x20\x03\xd5\xfd\x7b\xbf\xa9\xfd\x03\x00\x91\x2c\x00\x00\x94\xfd\x7b\xc1\xa8\xc0\x03\x5f\xd6\xf0\x7b\xbf\xa9\xf0\x00\x00\xf0\x11\xd2\x47\xf9\x10\x82\x3e\x91\x20\x02\x1f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x1f\x20\x03\xd5\xf0\x00\x00\xf0\x11\xd6\x47\xf9\x10\xa2\x3e\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xda\x47\xf9\x10\xc2\x3e\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xde\x47\xf9\x10\xe2\x3e\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xe2\x47\xf9\x10\x02\x3f\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xe6\x47\xf9\x10\x22\x3f\x91\x20\x02\x1f\xd6\x1f\x20\x03\xd5\x1d\x00\x80\xd2\x1e\x00\x80\xd2\xe5\x03\x00\xaa\xe1\x03\x40\xf9\xe2\x23\x00\x91\xe6\x03\x00\x91\xe0\x00\x00\xf0\x00\xf8\x47\xf9\x03\x00\x80\xd2\x04\x00\x80\xd2\xe1\xff\xff\x97\xf0\xff\xff\x97\xe0\x00\x00\xf0\x00\xf4\x47\xf9\x40\x00\x00\xb4\xe8\xff\xff\x17\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x00\x01\x00\x90\x00\x40\x00\x91\x01\x01\x00\x90\x21\x40\x00\x91\x3f\x00\x00\xeb\xc0\x00\x00\x54\xe1\x00\x00\xf0\x21\xec\x47\xf9\x61\x00\x00\xb4\xf0\x03\x01\xaa\x00\x02\x1f\xd6\xc0\x03\x5f\xd6\x00\x01\x00\x90\x00\x40\x00\x91\x01\x01\x00\x90\x21\x40\x00\x91\x21\x00\x00\xcb\x22\xfc\x7f\xd3\x41\x0c\x81\x8b\x21\xfc\x41\x93\xc1\x00\x00\xb4\xe2\x00\x00\xf0\x42\xfc\x47\xf9\x62\x00\x00\xb4\xf0\x03\x02\xaa\x00\x02\x1f\xd6\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\xfd\x7b\xbe\xa9\xfd\x03\x00\x91\xf3\x0b\x00\xf9\x13\x01\x00\x90\x60\x42\x40\x39\x40\x01\x00\x35\xe0\x00\x00\xf0\x00\xf0\x47\xf9\x80\x00\x00\xb4\x00\x01\x00\x90\x00\x04\x40\xf9\xb5\xff\xff\x97\xd8\xff\xff\x97\x20\x00\x80\x52\x60\x42\x00\x39\xf3\x0b\x40\xf9\xfd\x7b\xc2\xa8\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\xdc\xff\xff\x17\xfd\x7b\xbc\xa9\xfd\x03\x00\x91\x80\x02\x80\xd2\xac\xff\xff\x97\xe0\x0f\x00\xf9\xe0\x0f\x40\xf9\x81\x01\x80\x52\x01\x00\x00\xb9\xe0\x0f\x40\xf9\xe0\x13\x00\xf9\xe0\x13\x40\xf9\x00\x04\x00\x91\xe0\x17\x00\xf9\x00\x01\x80\xd2\xa1\xff\xff\x97\xe0\x1b\x00\xf9\xe0\x1b\x40\xf9\xe1\x17\x40\xf9\x01\x00\x00\xf9\xe0\x1b\x40\xf9\x00\x00\x40\xf9\xe0\x1f\x00\xf9\x00\x00\x80\x52\xfd\x7b\xc4\xa8\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\xfd\x7b\xbf\xa9\xfd\x03\x00\x91\xfd\x7b\xc1\xa8\xc0\x03\x5f\xd6\x01\x00\x02\x00\x01\x1b\x03\x3b\x3c\x00\x00\x00\x06\x00\x00\x00\x70\xfe\xff\xff\x54\x00\x00\x00\xc0\xfe\xff\xff\x68\x00\x00\x00\xf0\xfe\xff\xff\x7c\x00\x00\x00\x30\xff\xff\xff\x90\x00\x00\x00\x80\xff\xff\xff\xb4\x00\x00\x00\x84\xff\xff\xff\xc8\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x01\x7a\x52\x00\x04\x78\x1e\x01\x1b\x0c\x1f\x00\x10\x00\x00\x00"), +Section(".comment", 0x0, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7\x00\x01\x00\x00\x00\x40\x06\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\xa8\x0b\x01"), +Section(".interp", 0x238, "\x2f\x6c\x69\x62\x2f\x6c\x64\x2d\x6c\x69\x6e\x75\x78\x2d\x61\x61\x72\x63\x68\x36\x34\x2e\x73\x6f\x2e\x31\x00"), +Section(".note.gnu.build-id", 0x254, "\x04\x00\x00\x00\x14\x00\x00\x00\x03\x00\x00\x00\x47\x4e\x55\x00\xe7\x83\xd0\x0b\x65\xff\x69\x99\x15\x9f\x13\x77\x3c\xa9\xc0\x82\xdf\x41\xac\xfa"), +Section(".note.ABI-tag", 0x278, "\x04\x00\x00\x00\x10\x00\x00\x00\x01\x00\x00\x00\x47\x4e\x55\x00\x00\x00\x00\x00\x03\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00"), +Section(".gnu.hash", 0x298, "\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".dynsym", 0x2B8, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x0b\x00\xb8\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x16\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4f\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6b\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x29\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7a\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".dynstr", 0x3A8, "\x00\x6d\x61\x6c\x6c\x6f\x63\x00\x5f\x5f\x6c\x69\x62\x63\x5f\x73\x74\x61\x72\x74\x5f\x6d\x61\x69\x6e\x00\x5f\x5f\x63\x78\x61\x5f\x66\x69\x6e\x61\x6c\x69\x7a\x65\x00\x61\x62\x6f\x72\x74\x00\x6c\x69\x62\x63\x2e\x73\x6f\x2e\x36\x00\x47\x4c\x49\x42\x43\x5f\x32\x2e\x31\x37\x00\x47\x4c\x49\x42\x43\x5f\x32\x2e\x33\x34\x00\x5f\x49\x54\x4d\x5f\x64\x65\x72\x65\x67\x69\x73\x74\x65\x72\x54\x4d\x43\x6c\x6f\x6e\x65\x54\x61\x62\x6c\x65\x00\x5f\x5f\x67\x6d\x6f\x6e\x5f\x73\x74\x61\x72\x74\x5f\x5f\x00\x5f\x49\x54\x4d\x5f\x72\x65\x67\x69\x73\x74\x65\x72\x54\x4d\x43\x6c\x6f\x6e\x65\x54\x61\x62\x6c\x65\x00"), +Section(".gnu.version", 0x43C, "\x00\x00\x00\x00\x00\x00\x02\x00\x01\x00\x03\x00\x03\x00\x01\x00\x03\x00\x01\x00"), +Section(".gnu.version_r", 0x450, "\x01\x00\x02\x00\x2f\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x97\x91\x96\x06\x00\x00\x03\x00\x39\x00\x00\x00\x10\x00\x00\x00\xb4\x91\x96\x06\x00\x00\x02\x00\x44\x00\x00\x00\x00\x00\x00\x00"), +Section(".rela.dyn", 0x480, "\x90\xfd\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x50\x07\x00\x00\x00\x00\x00\x00\x98\xfd\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\xf0\xff\x01\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x54\x07\x00\x00\x00\x00\x00\x00\x08\x00\x02\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00\x08\x00\x02\x00\x00\x00\x00\x00\xd8\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe8\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\xff\x01\x00\x00\x00\x00\x00\x01\x04\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".rela.plt", 0x540, "\xa8\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb0\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb8\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc8\xff\x01\x00\x00\x00\x00\x00\x02\x04\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".init", 0x5B8, "\x1f\x20\x03\xd5\xfd\x7b\xbf\xa9\xfd\x03\x00\x91\x2c\x00\x00\x94\xfd\x7b\xc1\xa8\xc0\x03\x5f\xd6"), +Section(".plt", 0x5D0, "\xf0\x7b\xbf\xa9\xf0\x00\x00\xf0\x11\xd2\x47\xf9\x10\x82\x3e\x91\x20\x02\x1f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x1f\x20\x03\xd5\xf0\x00\x00\xf0\x11\xd6\x47\xf9\x10\xa2\x3e\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xda\x47\xf9\x10\xc2\x3e\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xde\x47\xf9\x10\xe2\x3e\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xe2\x47\xf9\x10\x02\x3f\x91\x20\x02\x1f\xd6\xf0\x00\x00\xf0\x11\xe6\x47\xf9\x10\x22\x3f\x91\x20\x02\x1f\xd6"), +Section(".fini", 0x7B8, "\x1f\x20\x03\xd5\xfd\x7b\xbf\xa9\xfd\x03\x00\x91\xfd\x7b\xc1\xa8\xc0\x03\x5f\xd6"), +Section(".rodata", 0x7CC, "\x01\x00\x02\x00"), +Section(".eh_frame_hdr", 0x7D0, "\x01\x1b\x03\x3b\x3c\x00\x00\x00\x06\x00\x00\x00\x70\xfe\xff\xff\x54\x00\x00\x00\xc0\xfe\xff\xff\x68\x00\x00\x00\xf0\xfe\xff\xff\x7c\x00\x00\x00\x30\xff\xff\xff\x90\x00\x00\x00\x80\xff\xff\xff\xb4\x00\x00\x00\x84\xff\xff\xff\xc8\x00\x00\x00"), +Section(".eh_frame", 0x810, "\x10\x00\x00\x00\x00\x00\x00\x00\x01\x7a\x52\x00\x04\x78\x1e\x01\x1b\x0c\x1f\x00\x10\x00\x00\x00\x18\x00\x00\x00\x14\xfe\xff\xff\x34\x00\x00\x00\x00\x41\x07\x1e\x10\x00\x00\x00\x2c\x00\x00\x00\x50\xfe\xff\xff\x30\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x40\x00\x00\x00\x6c\xfe\xff\xff\x3c\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x54\x00\x00\x00\x98\xfe\xff\xff\x48\x00\x00\x00\x00\x41\x0e\x20\x9d\x04\x9e\x03\x42\x93\x02\x4e\xde\xdd\xd3\x0e\x00\x00\x00\x00\x10\x00\x00\x00\x78\x00\x00\x00\xc4\xfe\xff\xff\x04\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x8c\x00\x00\x00\xb4\xfe\xff\xff\x64\x00\x00\x00\x00\x41\x0e\x40\x9d\x08\x9e\x07\x57\xde\xdd\x0e\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".fini_array", 0x1FD98, "\x00\x07\x00\x00\x00\x00\x00\x00"), +Section(".dynamic", 0x1FDA0, "\x01\x00\x00\x00\x00\x00\x00\x00\x2f\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x00\x00\xb8\x05\x00\x00\x00\x00\x00\x00\x0d\x00\x00\x00\x00\x00\x00\x00\xb8\x07\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\x90\xfd\x01\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00\x00\x00\x00\x00\x98\xfd\x01\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\xf5\xfe\xff\x6f\x00\x00\x00\x00\x98\x02\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\xa8\x03\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\xb8\x02\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x94\x00\x00\x00\x00\x00\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x15\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x90\xff\x01\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x78\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x17\x00\x00\x00\x00\x00\x00\x00\x40\x05\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x80\x04\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\xc0\x00\x00\x00\x00\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\xfb\xff\xff\x6f\x00\x00\x00\x00\x01\x00\x00\x08\x00\x00\x00\x00\xfe\xff\xff\x6f\x00\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x00\xff\xff\xff\x6f\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\xf0\xff\xff\x6f\x00\x00\x00\x00\x3c\x04\x00\x00\x00\x00\x00\x00\xf9\xff\xff\x6f\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".got", 0x1FF90, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd0\x05\x00\x00\x00\x00\x00\x00\xd0\x05\x00\x00\x00\x00\x00\x00\xd0\x05\x00\x00\x00\x00\x00\x00\xd0\x05\x00\x00\x00\x00\x00\x00\xd0\x05\x00\x00\x00\x00\x00\x00\xa0\xfd\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x54\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), +Section(".data", 0x20000, "\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x02\x00\x00\x00\x00\x00"), +Section(".init_array", 0x1FD90, "\x50\x07\x00\x00\x00\x00\x00\x00"), +Section(".text", 0x640, "\x1f\x20\x03\xd5\x1d\x00\x80\xd2\x1e\x00\x80\xd2\xe5\x03\x00\xaa\xe1\x03\x40\xf9\xe2\x23\x00\x91\xe6\x03\x00\x91\xe0\x00\x00\xf0\x00\xf8\x47\xf9\x03\x00\x80\xd2\x04\x00\x80\xd2\xe1\xff\xff\x97\xf0\xff\xff\x97\xe0\x00\x00\xf0\x00\xf4\x47\xf9\x40\x00\x00\xb4\xe8\xff\xff\x17\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\x00\x01\x00\x90\x00\x40\x00\x91\x01\x01\x00\x90\x21\x40\x00\x91\x3f\x00\x00\xeb\xc0\x00\x00\x54\xe1\x00\x00\xf0\x21\xec\x47\xf9\x61\x00\x00\xb4\xf0\x03\x01\xaa\x00\x02\x1f\xd6\xc0\x03\x5f\xd6\x00\x01\x00\x90\x00\x40\x00\x91\x01\x01\x00\x90\x21\x40\x00\x91\x21\x00\x00\xcb\x22\xfc\x7f\xd3\x41\x0c\x81\x8b\x21\xfc\x41\x93\xc1\x00\x00\xb4\xe2\x00\x00\xf0\x42\xfc\x47\xf9\x62\x00\x00\xb4\xf0\x03\x02\xaa\x00\x02\x1f\xd6\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\xfd\x7b\xbe\xa9\xfd\x03\x00\x91\xf3\x0b\x00\xf9\x13\x01\x00\x90\x60\x42\x40\x39\x40\x01\x00\x35\xe0\x00\x00\xf0\x00\xf0\x47\xf9\x80\x00\x00\xb4\x00\x01\x00\x90\x00\x04\x40\xf9\xb5\xff\xff\x97\xd8\xff\xff\x97\x20\x00\x80\x52\x60\x42\x00\x39\xf3\x0b\x40\xf9\xfd\x7b\xc2\xa8\xc0\x03\x5f\xd6\x1f\x20\x03\xd5\x1f\x20\x03\xd5\xdc\xff\xff\x17\xfd\x7b\xbc\xa9\xfd\x03\x00\x91\x80\x02\x80\xd2\xac\xff\xff\x97\xe0\x0f\x00\xf9\xe0\x0f\x40\xf9\x81\x01\x80\x52\x01\x00\x00\xb9\xe0\x0f\x40\xf9\xe0\x13\x00\xf9\xe0\x13\x40\xf9\x00\x04\x00\x91\xe0\x17\x00\xf9\x00\x01\x80\xd2\xa1\xff\xff\x97\xe0\x1b\x00\xf9\xe0\x1b\x40\xf9\xe1\x17\x40\xf9\x01\x00\x00\xf9\xe0\x1b\x40\xf9\x00\x00\x40\xf9\xe0\x1f\x00\xf9\x00\x00\x80\x52\xfd\x7b\xc4\xa8\xc0\x03\x5f\xd6")]), +Memmap([Annotation(Region(0x0,0x8BB), Attr("segment","02 0 2236")), +Annotation(Region(0x640,0x673), Attr("symbol","_start")), +Annotation(Region(0x0,0xF9), Attr("section",".shstrtab")), +Annotation(Region(0x0,0x242), Attr("section",".strtab")), +Annotation(Region(0x0,0x827), Attr("section",".symtab")), +Annotation(Region(0x0,0x2A), Attr("section",".comment")), +Annotation(Region(0x238,0x252), Attr("section",".interp")), +Annotation(Region(0x254,0x277), Attr("section",".note.gnu.build-id")), +Annotation(Region(0x278,0x297), Attr("section",".note.ABI-tag")), +Annotation(Region(0x298,0x2B3), Attr("section",".gnu.hash")), +Annotation(Region(0x2B8,0x3A7), Attr("section",".dynsym")), +Annotation(Region(0x3A8,0x43B), Attr("section",".dynstr")), +Annotation(Region(0x43C,0x44F), Attr("section",".gnu.version")), +Annotation(Region(0x450,0x47F), Attr("section",".gnu.version_r")), +Annotation(Region(0x480,0x53F), Attr("section",".rela.dyn")), +Annotation(Region(0x540,0x5B7), Attr("section",".rela.plt")), +Annotation(Region(0x5B8,0x5CF), Attr("section",".init")), +Annotation(Region(0x5D0,0x63F), Attr("section",".plt")), +Annotation(Region(0x5B8,0x5CF), Attr("code-region","()")), +Annotation(Region(0x5D0,0x63F), Attr("code-region","()")), +Annotation(Region(0x640,0x673), Attr("symbol-info","_start 0x640 52")), +Annotation(Region(0x674,0x687), Attr("symbol","call_weak_fn")), +Annotation(Region(0x674,0x687), Attr("symbol-info","call_weak_fn 0x674 20")), +Annotation(Region(0x754,0x7B7), Attr("symbol","main")), +Annotation(Region(0x754,0x7B7), Attr("symbol-info","main 0x754 100")), +Annotation(Region(0x7B8,0x7CB), Attr("section",".fini")), +Annotation(Region(0x7CC,0x7CF), Attr("section",".rodata")), +Annotation(Region(0x7D0,0x80B), Attr("section",".eh_frame_hdr")), +Annotation(Region(0x810,0x8BB), Attr("section",".eh_frame")), +Annotation(Region(0x1FD90,0x2000F), Attr("segment","03 0x1FD90 648")), +Annotation(Region(0x1FD98,0x1FD9F), Attr("section",".fini_array")), +Annotation(Region(0x1FDA0,0x1FF8F), Attr("section",".dynamic")), +Annotation(Region(0x1FF90,0x1FFFF), Attr("section",".got")), +Annotation(Region(0x20000,0x2000F), Attr("section",".data")), +Annotation(Region(0x1FD90,0x1FD97), Attr("section",".init_array")), +Annotation(Region(0x640,0x7B7), Attr("section",".text")), +Annotation(Region(0x640,0x7B7), Attr("code-region","()")), +Annotation(Region(0x7B8,0x7CB), Attr("code-region","()"))]), +Program(Tid(1_768, "%000006e8"), Attrs([]), + Subs([Sub(Tid(1_715, "@__cxa_finalize"), Attrs([Attr("address","0x600"), +Attr("stub","()"), Attr("c.proto","signed (*)(void)")]), "__cxa_finalize", + Args([Arg(Tid(1_769, "%000006e9"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("__cxa_finalize_result",Imm(32)), LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(1_051, "@__cxa_finalize"), Attrs([Attr("address","0x600")]), + Phis([]), Defs([Def(Tid(1_315, "%00000523"), Attrs([Attr("address","0x600"), +Attr("insn","adrp x16, #126976")]), Var("R16",Imm(64)), Int(126976,64)), +Def(Tid(1_322, "%0000052a"), Attrs([Attr("address","0x604"), +Attr("insn","ldr x17, [x16, #0xfb0]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R16",Imm(64)),Int(4016,64)),LittleEndian(),64)), +Def(Tid(1_328, "%00000530"), Attrs([Attr("address","0x608"), +Attr("insn","add x16, x16, #0xfb0")]), Var("R16",Imm(64)), +PLUS(Var("R16",Imm(64)),Int(4016,64)))]), Jmps([Call(Tid(1_333, "%00000535"), + Attrs([Attr("address","0x60C"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), +Sub(Tid(1_716, "@__do_global_dtors_aux"), Attrs([Attr("address","0x700"), +Attr("c.proto","signed (*)(void)")]), "__do_global_dtors_aux", + Args([Arg(Tid(1_770, "%000006ea"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("__do_global_dtors_aux_result",Imm(32)), LOW(32,Var("R0",Imm(64))), +Out())]), Blks([Blk(Tid(709, "@__do_global_dtors_aux"), + Attrs([Attr("address","0x700")]), Phis([]), Defs([Def(Tid(713, "%000002c9"), + Attrs([Attr("address","0x700"), +Attr("insn","stp x29, x30, [sp, #-0x20]!")]), Var("#3",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(18446744073709551584,64))), +Def(Tid(719, "%000002cf"), Attrs([Attr("address","0x700"), +Attr("insn","stp x29, x30, [sp, #-0x20]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("#3",Imm(64)),Var("R29",Imm(64)),LittleEndian(),64)), +Def(Tid(725, "%000002d5"), Attrs([Attr("address","0x700"), +Attr("insn","stp x29, x30, [sp, #-0x20]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("#3",Imm(64)),Int(8,64)),Var("R30",Imm(64)),LittleEndian(),64)), +Def(Tid(729, "%000002d9"), Attrs([Attr("address","0x700"), +Attr("insn","stp x29, x30, [sp, #-0x20]!")]), Var("R31",Imm(64)), +Var("#3",Imm(64))), Def(Tid(735, "%000002df"), + Attrs([Attr("address","0x704"), Attr("insn","mov x29, sp")]), + Var("R29",Imm(64)), Var("R31",Imm(64))), Def(Tid(743, "%000002e7"), + Attrs([Attr("address","0x708"), Attr("insn","str x19, [sp, #0x10]")]), + Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(16,64)),Var("R19",Imm(64)),LittleEndian(),64)), +Def(Tid(748, "%000002ec"), Attrs([Attr("address","0x70C"), +Attr("insn","adrp x19, #131072")]), Var("R19",Imm(64)), Int(131072,64)), +Def(Tid(755, "%000002f3"), Attrs([Attr("address","0x710"), +Attr("insn","ldrb w0, [x19, #0x10]")]), Var("R0",Imm(64)), +UNSIGNED(64,Load(Var("mem",Mem(64,8)),PLUS(Var("R19",Imm(64)),Int(16,64)),LittleEndian(),8)))]), +Jmps([Goto(Tid(762, "%000002fa"), Attrs([Attr("address","0x714"), +Attr("insn","cbnz w0, #0x28")]), + NEQ(Extract(31,0,Var("R0",Imm(64))),Int(0,32)), +Direct(Tid(760, "%000002f8"))), Goto(Tid(1_758, "%000006de"), Attrs([]), + Int(1,1), Direct(Tid(996, "%000003e4")))])), Blk(Tid(996, "%000003e4"), + Attrs([Attr("address","0x718")]), Phis([]), Defs([Def(Tid(999, "%000003e7"), + Attrs([Attr("address","0x718"), Attr("insn","adrp x0, #126976")]), + Var("R0",Imm(64)), Int(126976,64)), Def(Tid(1_006, "%000003ee"), + Attrs([Attr("address","0x71C"), Attr("insn","ldr x0, [x0, #0xfe0]")]), + Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R0",Imm(64)),Int(4064,64)),LittleEndian(),64))]), +Jmps([Goto(Tid(1_012, "%000003f4"), Attrs([Attr("address","0x720"), +Attr("insn","cbz x0, #0x10")]), EQ(Var("R0",Imm(64)),Int(0,64)), +Direct(Tid(1_010, "%000003f2"))), Goto(Tid(1_759, "%000006df"), Attrs([]), + Int(1,1), Direct(Tid(1_035, "%0000040b")))])), Blk(Tid(1_035, "%0000040b"), + Attrs([Attr("address","0x724")]), Phis([]), +Defs([Def(Tid(1_038, "%0000040e"), Attrs([Attr("address","0x724"), +Attr("insn","adrp x0, #131072")]), Var("R0",Imm(64)), Int(131072,64)), +Def(Tid(1_045, "%00000415"), Attrs([Attr("address","0x728"), +Attr("insn","ldr x0, [x0, #0x8]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R0",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(1_050, "%0000041a"), Attrs([Attr("address","0x72C"), +Attr("insn","bl #-0x12c")]), Var("R30",Imm(64)), Int(1840,64))]), +Jmps([Call(Tid(1_053, "%0000041d"), Attrs([Attr("address","0x72C"), +Attr("insn","bl #-0x12c")]), Int(1,1), +(Direct(Tid(1_715, "@__cxa_finalize")),Direct(Tid(1_010, "%000003f2"))))])), +Blk(Tid(1_010, "%000003f2"), Attrs([Attr("address","0x730")]), Phis([]), +Defs([Def(Tid(1_018, "%000003fa"), Attrs([Attr("address","0x730"), +Attr("insn","bl #-0xa0")]), Var("R30",Imm(64)), Int(1844,64))]), +Jmps([Call(Tid(1_020, "%000003fc"), Attrs([Attr("address","0x730"), +Attr("insn","bl #-0xa0")]), Int(1,1), +(Direct(Tid(1_729, "@deregister_tm_clones")),Direct(Tid(1_022, "%000003fe"))))])), +Blk(Tid(1_022, "%000003fe"), Attrs([Attr("address","0x734")]), Phis([]), +Defs([Def(Tid(1_025, "%00000401"), Attrs([Attr("address","0x734"), +Attr("insn","mov w0, #0x1")]), Var("R0",Imm(64)), Int(1,64)), +Def(Tid(1_033, "%00000409"), Attrs([Attr("address","0x738"), +Attr("insn","strb w0, [x19, #0x10]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R19",Imm(64)),Int(16,64)),Extract(7,0,Var("R0",Imm(64))),LittleEndian(),8))]), +Jmps([Goto(Tid(1_760, "%000006e0"), Attrs([]), Int(1,1), +Direct(Tid(760, "%000002f8")))])), Blk(Tid(760, "%000002f8"), + Attrs([Attr("address","0x73C")]), Phis([]), Defs([Def(Tid(770, "%00000302"), + Attrs([Attr("address","0x73C"), Attr("insn","ldr x19, [sp, #0x10]")]), + Var("R19",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(16,64)),LittleEndian(),64)), +Def(Tid(777, "%00000309"), Attrs([Attr("address","0x740"), +Attr("insn","ldp x29, x30, [sp], #0x20")]), Var("R29",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(782, "%0000030e"), Attrs([Attr("address","0x740"), +Attr("insn","ldp x29, x30, [sp], #0x20")]), Var("R30",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(786, "%00000312"), Attrs([Attr("address","0x740"), +Attr("insn","ldp x29, x30, [sp], #0x20")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(32,64)))]), Jmps([Call(Tid(791, "%00000317"), + Attrs([Attr("address","0x744"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))])), Sub(Tid(1_720, "@__libc_start_main"), + Attrs([Attr("address","0x5F0"), Attr("stub","()"), +Attr("c.proto","signed (*)(signed (*)(signed , char** , char** );* main, signed , char** , \nvoid* auxv)")]), + "__libc_start_main", Args([Arg(Tid(1_771, "%000006eb"), + Attrs([Attr("c.data","Top:u64 ptr ptr"), +Attr("c.layout","**[ : 64]"), +Attr("c.type","signed (*)(signed , char** , char** );*")]), + Var("__libc_start_main_main",Imm(64)), Var("R0",Imm(64)), In()), +Arg(Tid(1_772, "%000006ec"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("__libc_start_main_arg2",Imm(32)), LOW(32,Var("R1",Imm(64))), In()), +Arg(Tid(1_773, "%000006ed"), Attrs([Attr("c.data","Top:u8 ptr ptr"), +Attr("c.layout","**[char : 8]"), Attr("c.type","char**")]), + Var("__libc_start_main_arg3",Imm(64)), Var("R2",Imm(64)), Both()), +Arg(Tid(1_774, "%000006ee"), Attrs([Attr("c.data","{} ptr"), +Attr("c.layout","*[ : 8]"), Attr("c.type","void*")]), + Var("__libc_start_main_auxv",Imm(64)), Var("R3",Imm(64)), Both()), +Arg(Tid(1_775, "%000006ef"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("__libc_start_main_result",Imm(32)), LOW(32,Var("R0",Imm(64))), +Out())]), Blks([Blk(Tid(542, "@__libc_start_main"), + Attrs([Attr("address","0x5F0")]), Phis([]), +Defs([Def(Tid(1_293, "%0000050d"), Attrs([Attr("address","0x5F0"), +Attr("insn","adrp x16, #126976")]), Var("R16",Imm(64)), Int(126976,64)), +Def(Tid(1_300, "%00000514"), Attrs([Attr("address","0x5F4"), +Attr("insn","ldr x17, [x16, #0xfa8]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R16",Imm(64)),Int(4008,64)),LittleEndian(),64)), +Def(Tid(1_306, "%0000051a"), Attrs([Attr("address","0x5F8"), +Attr("insn","add x16, x16, #0xfa8")]), Var("R16",Imm(64)), +PLUS(Var("R16",Imm(64)),Int(4008,64)))]), Jmps([Call(Tid(1_311, "%0000051f"), + Attrs([Attr("address","0x5FC"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), Sub(Tid(1_721, "@_fini"), + Attrs([Attr("address","0x7B8"), Attr("c.proto","signed (*)(void)")]), + "_fini", Args([Arg(Tid(1_776, "%000006f0"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("_fini_result",Imm(32)), LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(50, "@_fini"), Attrs([Attr("address","0x7B8")]), Phis([]), +Defs([Def(Tid(56, "%00000038"), Attrs([Attr("address","0x7BC"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("#0",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(18446744073709551600,64))), +Def(Tid(62, "%0000003e"), Attrs([Attr("address","0x7BC"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("#0",Imm(64)),Var("R29",Imm(64)),LittleEndian(),64)), +Def(Tid(68, "%00000044"), Attrs([Attr("address","0x7BC"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("#0",Imm(64)),Int(8,64)),Var("R30",Imm(64)),LittleEndian(),64)), +Def(Tid(72, "%00000048"), Attrs([Attr("address","0x7BC"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("R31",Imm(64)), +Var("#0",Imm(64))), Def(Tid(78, "%0000004e"), Attrs([Attr("address","0x7C0"), +Attr("insn","mov x29, sp")]), Var("R29",Imm(64)), Var("R31",Imm(64))), +Def(Tid(85, "%00000055"), Attrs([Attr("address","0x7C4"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R29",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(90, "%0000005a"), Attrs([Attr("address","0x7C4"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R30",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(94, "%0000005e"), Attrs([Attr("address","0x7C4"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(16,64)))]), Jmps([Call(Tid(99, "%00000063"), + Attrs([Attr("address","0x7C8"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))])), Sub(Tid(1_722, "@_init"), + Attrs([Attr("address","0x5B8"), Attr("c.proto","signed (*)(void)")]), + "_init", Args([Arg(Tid(1_777, "%000006f1"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("_init_result",Imm(32)), LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(1_528, "@_init"), Attrs([Attr("address","0x5B8")]), Phis([]), +Defs([Def(Tid(1_534, "%000005fe"), Attrs([Attr("address","0x5BC"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("#6",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(18446744073709551600,64))), +Def(Tid(1_540, "%00000604"), Attrs([Attr("address","0x5BC"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("#6",Imm(64)),Var("R29",Imm(64)),LittleEndian(),64)), +Def(Tid(1_546, "%0000060a"), Attrs([Attr("address","0x5BC"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("#6",Imm(64)),Int(8,64)),Var("R30",Imm(64)),LittleEndian(),64)), +Def(Tid(1_550, "%0000060e"), Attrs([Attr("address","0x5BC"), +Attr("insn","stp x29, x30, [sp, #-0x10]!")]), Var("R31",Imm(64)), +Var("#6",Imm(64))), Def(Tid(1_556, "%00000614"), + Attrs([Attr("address","0x5C0"), Attr("insn","mov x29, sp")]), + Var("R29",Imm(64)), Var("R31",Imm(64))), Def(Tid(1_561, "%00000619"), + Attrs([Attr("address","0x5C4"), Attr("insn","bl #0xb0")]), + Var("R30",Imm(64)), Int(1480,64))]), Jmps([Call(Tid(1_563, "%0000061b"), + Attrs([Attr("address","0x5C4"), Attr("insn","bl #0xb0")]), Int(1,1), +(Direct(Tid(1_727, "@call_weak_fn")),Direct(Tid(1_565, "%0000061d"))))])), +Blk(Tid(1_565, "%0000061d"), Attrs([Attr("address","0x5C8")]), Phis([]), +Defs([Def(Tid(1_570, "%00000622"), Attrs([Attr("address","0x5C8"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R29",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(1_575, "%00000627"), Attrs([Attr("address","0x5C8"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R30",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(1_579, "%0000062b"), Attrs([Attr("address","0x5C8"), +Attr("insn","ldp x29, x30, [sp], #0x10")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(16,64)))]), Jmps([Call(Tid(1_584, "%00000630"), + Attrs([Attr("address","0x5CC"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))])), Sub(Tid(1_723, "@_start"), + Attrs([Attr("address","0x640"), Attr("stub","()"), Attr("entry-point","()"), +Attr("c.proto","signed (*)(void)")]), "_start", + Args([Arg(Tid(1_778, "%000006f2"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("_start_result",Imm(32)), LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(479, "@_start"), Attrs([Attr("address","0x640")]), Phis([]), +Defs([Def(Tid(484, "%000001e4"), Attrs([Attr("address","0x644"), +Attr("insn","mov x29, #0x0")]), Var("R29",Imm(64)), Int(0,64)), +Def(Tid(489, "%000001e9"), Attrs([Attr("address","0x648"), +Attr("insn","mov x30, #0x0")]), Var("R30",Imm(64)), Int(0,64)), +Def(Tid(495, "%000001ef"), Attrs([Attr("address","0x64C"), +Attr("insn","mov x5, x0")]), Var("R5",Imm(64)), Var("R0",Imm(64))), +Def(Tid(502, "%000001f6"), Attrs([Attr("address","0x650"), +Attr("insn","ldr x1, [sp]")]), Var("R1",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(508, "%000001fc"), Attrs([Attr("address","0x654"), +Attr("insn","add x2, sp, #0x8")]), Var("R2",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(8,64))), Def(Tid(514, "%00000202"), + Attrs([Attr("address","0x658"), Attr("insn","mov x6, sp")]), + Var("R6",Imm(64)), Var("R31",Imm(64))), Def(Tid(519, "%00000207"), + Attrs([Attr("address","0x65C"), Attr("insn","adrp x0, #126976")]), + Var("R0",Imm(64)), Int(126976,64)), Def(Tid(526, "%0000020e"), + Attrs([Attr("address","0x660"), Attr("insn","ldr x0, [x0, #0xff0]")]), + Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R0",Imm(64)),Int(4080,64)),LittleEndian(),64)), +Def(Tid(531, "%00000213"), Attrs([Attr("address","0x664"), +Attr("insn","mov x3, #0x0")]), Var("R3",Imm(64)), Int(0,64)), +Def(Tid(536, "%00000218"), Attrs([Attr("address","0x668"), +Attr("insn","mov x4, #0x0")]), Var("R4",Imm(64)), Int(0,64)), +Def(Tid(541, "%0000021d"), Attrs([Attr("address","0x66C"), +Attr("insn","bl #-0x7c")]), Var("R30",Imm(64)), Int(1648,64))]), +Jmps([Call(Tid(544, "%00000220"), Attrs([Attr("address","0x66C"), +Attr("insn","bl #-0x7c")]), Int(1,1), +(Direct(Tid(1_720, "@__libc_start_main")),Direct(Tid(546, "%00000222"))))])), +Blk(Tid(546, "%00000222"), Attrs([Attr("address","0x670")]), Phis([]), +Defs([Def(Tid(549, "%00000225"), Attrs([Attr("address","0x670"), +Attr("insn","bl #-0x40")]), Var("R30",Imm(64)), Int(1652,64))]), +Jmps([Call(Tid(552, "%00000228"), Attrs([Attr("address","0x670"), +Attr("insn","bl #-0x40")]), Int(1,1), +(Direct(Tid(1_726, "@abort")),Direct(Tid(1_761, "%000006e1"))))])), +Blk(Tid(1_761, "%000006e1"), Attrs([]), Phis([]), Defs([]), +Jmps([Call(Tid(1_762, "%000006e2"), Attrs([]), Int(1,1), +(Direct(Tid(1_727, "@call_weak_fn")),))]))])), Sub(Tid(1_726, "@abort"), + Attrs([Attr("address","0x630"), Attr("stub","()"), Attr("noreturn","()"), +Attr("c.proto","void (*)(void)")]), "abort", Args([]), +Blks([Blk(Tid(550, "@abort"), Attrs([Attr("address","0x630")]), Phis([]), +Defs([Def(Tid(1_381, "%00000565"), Attrs([Attr("address","0x630"), +Attr("insn","adrp x16, #126976")]), Var("R16",Imm(64)), Int(126976,64)), +Def(Tid(1_388, "%0000056c"), Attrs([Attr("address","0x634"), +Attr("insn","ldr x17, [x16, #0xfc8]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R16",Imm(64)),Int(4040,64)),LittleEndian(),64)), +Def(Tid(1_394, "%00000572"), Attrs([Attr("address","0x638"), +Attr("insn","add x16, x16, #0xfc8")]), Var("R16",Imm(64)), +PLUS(Var("R16",Imm(64)),Int(4040,64)))]), Jmps([Call(Tid(1_399, "%00000577"), + Attrs([Attr("address","0x63C"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), Sub(Tid(1_727, "@call_weak_fn"), + Attrs([Attr("address","0x674"), Attr("c.proto","signed (*)(void)")]), + "call_weak_fn", Args([Arg(Tid(1_779, "%000006f3"), + Attrs([Attr("c.data","Top:u32"), Attr("c.layout","[signed : 32]"), +Attr("c.type","signed")]), Var("call_weak_fn_result",Imm(32)), +LOW(32,Var("R0",Imm(64))), Out())]), Blks([Blk(Tid(554, "@call_weak_fn"), + Attrs([Attr("address","0x674")]), Phis([]), Defs([Def(Tid(557, "%0000022d"), + Attrs([Attr("address","0x674"), Attr("insn","adrp x0, #126976")]), + Var("R0",Imm(64)), Int(126976,64)), Def(Tid(564, "%00000234"), + Attrs([Attr("address","0x678"), Attr("insn","ldr x0, [x0, #0xfe8]")]), + Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R0",Imm(64)),Int(4072,64)),LittleEndian(),64))]), +Jmps([Goto(Tid(570, "%0000023a"), Attrs([Attr("address","0x67C"), +Attr("insn","cbz x0, #0x8")]), EQ(Var("R0",Imm(64)),Int(0,64)), +Direct(Tid(568, "%00000238"))), Goto(Tid(1_763, "%000006e3"), Attrs([]), + Int(1,1), Direct(Tid(1_115, "%0000045b")))])), Blk(Tid(568, "%00000238"), + Attrs([Attr("address","0x684")]), Phis([]), Defs([]), +Jmps([Call(Tid(576, "%00000240"), Attrs([Attr("address","0x684"), +Attr("insn","ret")]), Int(1,1), (Indirect(Var("R30",Imm(64))),))])), +Blk(Tid(1_115, "%0000045b"), Attrs([Attr("address","0x680")]), Phis([]), +Defs([]), Jmps([Goto(Tid(1_118, "%0000045e"), Attrs([Attr("address","0x680"), +Attr("insn","b #-0x60")]), Int(1,1), +Direct(Tid(1_116, "@__gmon_start__")))])), Blk(Tid(1_116, "@__gmon_start__"), + Attrs([Attr("address","0x620")]), Phis([]), +Defs([Def(Tid(1_359, "%0000054f"), Attrs([Attr("address","0x620"), +Attr("insn","adrp x16, #126976")]), Var("R16",Imm(64)), Int(126976,64)), +Def(Tid(1_366, "%00000556"), Attrs([Attr("address","0x624"), +Attr("insn","ldr x17, [x16, #0xfc0]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R16",Imm(64)),Int(4032,64)),LittleEndian(),64)), +Def(Tid(1_372, "%0000055c"), Attrs([Attr("address","0x628"), +Attr("insn","add x16, x16, #0xfc0")]), Var("R16",Imm(64)), +PLUS(Var("R16",Imm(64)),Int(4032,64)))]), Jmps([Call(Tid(1_377, "%00000561"), + Attrs([Attr("address","0x62C"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), +Sub(Tid(1_729, "@deregister_tm_clones"), Attrs([Attr("address","0x690"), +Attr("c.proto","signed (*)(void)")]), "deregister_tm_clones", + Args([Arg(Tid(1_780, "%000006f4"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("deregister_tm_clones_result",Imm(32)), LOW(32,Var("R0",Imm(64))), +Out())]), Blks([Blk(Tid(582, "@deregister_tm_clones"), + Attrs([Attr("address","0x690")]), Phis([]), Defs([Def(Tid(585, "%00000249"), + Attrs([Attr("address","0x690"), Attr("insn","adrp x0, #131072")]), + Var("R0",Imm(64)), Int(131072,64)), Def(Tid(591, "%0000024f"), + Attrs([Attr("address","0x694"), Attr("insn","add x0, x0, #0x10")]), + Var("R0",Imm(64)), PLUS(Var("R0",Imm(64)),Int(16,64))), +Def(Tid(596, "%00000254"), Attrs([Attr("address","0x698"), +Attr("insn","adrp x1, #131072")]), Var("R1",Imm(64)), Int(131072,64)), +Def(Tid(602, "%0000025a"), Attrs([Attr("address","0x69C"), +Attr("insn","add x1, x1, #0x10")]), Var("R1",Imm(64)), +PLUS(Var("R1",Imm(64)),Int(16,64))), Def(Tid(608, "%00000260"), + Attrs([Attr("address","0x6A0"), Attr("insn","cmp x1, x0")]), + Var("#1",Imm(64)), NOT(Var("R0",Imm(64)))), Def(Tid(613, "%00000265"), + Attrs([Attr("address","0x6A0"), Attr("insn","cmp x1, x0")]), + Var("#2",Imm(64)), PLUS(Var("R1",Imm(64)),NOT(Var("R0",Imm(64))))), +Def(Tid(619, "%0000026b"), Attrs([Attr("address","0x6A0"), +Attr("insn","cmp x1, x0")]), Var("VF",Imm(1)), +NEQ(SIGNED(65,PLUS(Var("#2",Imm(64)),Int(1,64))),PLUS(PLUS(SIGNED(65,Var("R1",Imm(64))),SIGNED(65,Var("#1",Imm(64)))),Int(1,65)))), +Def(Tid(625, "%00000271"), Attrs([Attr("address","0x6A0"), +Attr("insn","cmp x1, x0")]), Var("CF",Imm(1)), +NEQ(UNSIGNED(65,PLUS(Var("#2",Imm(64)),Int(1,64))),PLUS(PLUS(UNSIGNED(65,Var("R1",Imm(64))),UNSIGNED(65,Var("#1",Imm(64)))),Int(1,65)))), +Def(Tid(629, "%00000275"), Attrs([Attr("address","0x6A0"), +Attr("insn","cmp x1, x0")]), Var("ZF",Imm(1)), +EQ(PLUS(Var("#2",Imm(64)),Int(1,64)),Int(0,64))), Def(Tid(633, "%00000279"), + Attrs([Attr("address","0x6A0"), Attr("insn","cmp x1, x0")]), + Var("NF",Imm(1)), Extract(63,63,PLUS(Var("#2",Imm(64)),Int(1,64))))]), +Jmps([Goto(Tid(639, "%0000027f"), Attrs([Attr("address","0x6A4"), +Attr("insn","b.eq #0x18")]), EQ(Var("ZF",Imm(1)),Int(1,1)), +Direct(Tid(637, "%0000027d"))), Goto(Tid(1_764, "%000006e4"), Attrs([]), + Int(1,1), Direct(Tid(1_085, "%0000043d")))])), Blk(Tid(1_085, "%0000043d"), + Attrs([Attr("address","0x6A8")]), Phis([]), +Defs([Def(Tid(1_088, "%00000440"), Attrs([Attr("address","0x6A8"), +Attr("insn","adrp x1, #126976")]), Var("R1",Imm(64)), Int(126976,64)), +Def(Tid(1_095, "%00000447"), Attrs([Attr("address","0x6AC"), +Attr("insn","ldr x1, [x1, #0xfd8]")]), Var("R1",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R1",Imm(64)),Int(4056,64)),LittleEndian(),64))]), +Jmps([Goto(Tid(1_100, "%0000044c"), Attrs([Attr("address","0x6B0"), +Attr("insn","cbz x1, #0xc")]), EQ(Var("R1",Imm(64)),Int(0,64)), +Direct(Tid(637, "%0000027d"))), Goto(Tid(1_765, "%000006e5"), Attrs([]), + Int(1,1), Direct(Tid(1_104, "%00000450")))])), Blk(Tid(637, "%0000027d"), + Attrs([Attr("address","0x6BC")]), Phis([]), Defs([]), +Jmps([Call(Tid(645, "%00000285"), Attrs([Attr("address","0x6BC"), +Attr("insn","ret")]), Int(1,1), (Indirect(Var("R30",Imm(64))),))])), +Blk(Tid(1_104, "%00000450"), Attrs([Attr("address","0x6B4")]), Phis([]), +Defs([Def(Tid(1_108, "%00000454"), Attrs([Attr("address","0x6B4"), +Attr("insn","mov x16, x1")]), Var("R16",Imm(64)), Var("R1",Imm(64)))]), +Jmps([Call(Tid(1_113, "%00000459"), Attrs([Attr("address","0x6B8"), +Attr("insn","br x16")]), Int(1,1), (Indirect(Var("R16",Imm(64))),))]))])), +Sub(Tid(1_732, "@frame_dummy"), Attrs([Attr("address","0x750"), +Attr("c.proto","signed (*)(void)")]), "frame_dummy", + Args([Arg(Tid(1_781, "%000006f5"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("frame_dummy_result",Imm(32)), LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(797, "@frame_dummy"), Attrs([Attr("address","0x750")]), + Phis([]), Defs([]), Jmps([Call(Tid(799, "%0000031f"), + Attrs([Attr("address","0x750"), Attr("insn","b #-0x90")]), Int(1,1), +(Direct(Tid(1_735, "@register_tm_clones")),))]))])), Sub(Tid(1_733, "@main"), + Attrs([Attr("address","0x754"), +Attr("c.proto","signed (*)(signed argc, const char** argv)")]), "main", + Args([Arg(Tid(1_782, "%000006f6"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("main_argc",Imm(32)), LOW(32,Var("R0",Imm(64))), In()), +Arg(Tid(1_783, "%000006f7"), Attrs([Attr("c.data","Top:u8 ptr ptr"), +Attr("c.layout","**[char : 8]"), Attr("c.type"," const char**")]), + Var("main_argv",Imm(64)), Var("R1",Imm(64)), Both()), +Arg(Tid(1_784, "%000006f8"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("main_result",Imm(32)), LOW(32,Var("R0",Imm(64))), Out())]), +Blks([Blk(Tid(801, "@main"), Attrs([Attr("address","0x754")]), Phis([]), +Defs([Def(Tid(805, "%00000325"), Attrs([Attr("address","0x754"), +Attr("insn","stp x29, x30, [sp, #-0x40]!")]), Var("#4",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(18446744073709551552,64))), +Def(Tid(811, "%0000032b"), Attrs([Attr("address","0x754"), +Attr("insn","stp x29, x30, [sp, #-0x40]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("#4",Imm(64)),Var("R29",Imm(64)),LittleEndian(),64)), +Def(Tid(817, "%00000331"), Attrs([Attr("address","0x754"), +Attr("insn","stp x29, x30, [sp, #-0x40]!")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("#4",Imm(64)),Int(8,64)),Var("R30",Imm(64)),LittleEndian(),64)), +Def(Tid(821, "%00000335"), Attrs([Attr("address","0x754"), +Attr("insn","stp x29, x30, [sp, #-0x40]!")]), Var("R31",Imm(64)), +Var("#4",Imm(64))), Def(Tid(827, "%0000033b"), + Attrs([Attr("address","0x758"), Attr("insn","mov x29, sp")]), + Var("R29",Imm(64)), Var("R31",Imm(64))), Def(Tid(832, "%00000340"), + Attrs([Attr("address","0x75C"), Attr("insn","mov x0, #0x14")]), + Var("R0",Imm(64)), Int(20,64)), Def(Tid(837, "%00000345"), + Attrs([Attr("address","0x760"), Attr("insn","bl #-0x150")]), + Var("R30",Imm(64)), Int(1892,64))]), Jmps([Call(Tid(840, "%00000348"), + Attrs([Attr("address","0x760"), Attr("insn","bl #-0x150")]), Int(1,1), +(Direct(Tid(1_734, "@malloc")),Direct(Tid(842, "%0000034a"))))])), +Blk(Tid(842, "%0000034a"), Attrs([Attr("address","0x764")]), Phis([]), +Defs([Def(Tid(848, "%00000350"), Attrs([Attr("address","0x764"), +Attr("insn","str x0, [sp, #0x18]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(24,64)),Var("R0",Imm(64)),LittleEndian(),64)), +Def(Tid(855, "%00000357"), Attrs([Attr("address","0x768"), +Attr("insn","ldr x0, [sp, #0x18]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(24,64)),LittleEndian(),64)), +Def(Tid(860, "%0000035c"), Attrs([Attr("address","0x76C"), +Attr("insn","mov w1, #0xc")]), Var("R1",Imm(64)), Int(12,64)), +Def(Tid(868, "%00000364"), Attrs([Attr("address","0x770"), +Attr("insn","str w1, [x0]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("R0",Imm(64)),Extract(31,0,Var("R1",Imm(64))),LittleEndian(),32)), +Def(Tid(875, "%0000036b"), Attrs([Attr("address","0x774"), +Attr("insn","ldr x0, [sp, #0x18]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(24,64)),LittleEndian(),64)), +Def(Tid(883, "%00000373"), Attrs([Attr("address","0x778"), +Attr("insn","str x0, [sp, #0x20]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(32,64)),Var("R0",Imm(64)),LittleEndian(),64)), +Def(Tid(890, "%0000037a"), Attrs([Attr("address","0x77C"), +Attr("insn","ldr x0, [sp, #0x20]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(32,64)),LittleEndian(),64)), +Def(Tid(896, "%00000380"), Attrs([Attr("address","0x780"), +Attr("insn","add x0, x0, #0x1")]), Var("R0",Imm(64)), +PLUS(Var("R0",Imm(64)),Int(1,64))), Def(Tid(904, "%00000388"), + Attrs([Attr("address","0x784"), Attr("insn","str x0, [sp, #0x28]")]), + Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(40,64)),Var("R0",Imm(64)),LittleEndian(),64)), +Def(Tid(909, "%0000038d"), Attrs([Attr("address","0x788"), +Attr("insn","mov x0, #0x8")]), Var("R0",Imm(64)), Int(8,64)), +Def(Tid(914, "%00000392"), Attrs([Attr("address","0x78C"), +Attr("insn","bl #-0x17c")]), Var("R30",Imm(64)), Int(1936,64))]), +Jmps([Call(Tid(916, "%00000394"), Attrs([Attr("address","0x78C"), +Attr("insn","bl #-0x17c")]), Int(1,1), +(Direct(Tid(1_734, "@malloc")),Direct(Tid(918, "%00000396"))))])), +Blk(Tid(918, "%00000396"), Attrs([Attr("address","0x790")]), Phis([]), +Defs([Def(Tid(924, "%0000039c"), Attrs([Attr("address","0x790"), +Attr("insn","str x0, [sp, #0x30]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(48,64)),Var("R0",Imm(64)),LittleEndian(),64)), +Def(Tid(931, "%000003a3"), Attrs([Attr("address","0x794"), +Attr("insn","ldr x0, [sp, #0x30]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(48,64)),LittleEndian(),64)), +Def(Tid(938, "%000003aa"), Attrs([Attr("address","0x798"), +Attr("insn","ldr x1, [sp, #0x28]")]), Var("R1",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(40,64)),LittleEndian(),64)), +Def(Tid(946, "%000003b2"), Attrs([Attr("address","0x79C"), +Attr("insn","str x1, [x0]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),Var("R0",Imm(64)),Var("R1",Imm(64)),LittleEndian(),64)), +Def(Tid(953, "%000003b9"), Attrs([Attr("address","0x7A0"), +Attr("insn","ldr x0, [sp, #0x30]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(48,64)),LittleEndian(),64)), +Def(Tid(960, "%000003c0"), Attrs([Attr("address","0x7A4"), +Attr("insn","ldr x0, [x0]")]), Var("R0",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R0",Imm(64)),LittleEndian(),64)), +Def(Tid(968, "%000003c8"), Attrs([Attr("address","0x7A8"), +Attr("insn","str x0, [sp, #0x38]")]), Var("mem",Mem(64,8)), +Store(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(56,64)),Var("R0",Imm(64)),LittleEndian(),64)), +Def(Tid(973, "%000003cd"), Attrs([Attr("address","0x7AC"), +Attr("insn","mov w0, #0x0")]), Var("R0",Imm(64)), Int(0,64)), +Def(Tid(980, "%000003d4"), Attrs([Attr("address","0x7B0"), +Attr("insn","ldp x29, x30, [sp], #0x40")]), Var("R29",Imm(64)), +Load(Var("mem",Mem(64,8)),Var("R31",Imm(64)),LittleEndian(),64)), +Def(Tid(985, "%000003d9"), Attrs([Attr("address","0x7B0"), +Attr("insn","ldp x29, x30, [sp], #0x40")]), Var("R30",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R31",Imm(64)),Int(8,64)),LittleEndian(),64)), +Def(Tid(989, "%000003dd"), Attrs([Attr("address","0x7B0"), +Attr("insn","ldp x29, x30, [sp], #0x40")]), Var("R31",Imm(64)), +PLUS(Var("R31",Imm(64)),Int(64,64)))]), Jmps([Call(Tid(994, "%000003e2"), + Attrs([Attr("address","0x7B4"), Attr("insn","ret")]), Int(1,1), +(Indirect(Var("R30",Imm(64))),))]))])), Sub(Tid(1_734, "@malloc"), + Attrs([Attr("address","0x610"), Attr("stub","()"), Attr("malloc","()"), +Attr("c.proto","void* (*)(unsigned long size)")]), "malloc", + Args([Arg(Tid(1_785, "%000006f9"), Attrs([Attr("alloc-size","()"), +Attr("c.data","Top:u64"), Attr("c.layout","[unsigned long : 64]"), +Attr("c.type","unsigned long")]), Var("malloc_size",Imm(64)), +Var("R0",Imm(64)), In()), Arg(Tid(1_786, "%000006fa"), + Attrs([Attr("warn-unused","()"), Attr("c.data","{} ptr"), +Attr("c.layout","*[ : 8]"), Attr("c.type","void*")]), + Var("malloc_result",Imm(64)), Var("R0",Imm(64)), Out())]), +Blks([Blk(Tid(838, "@malloc"), Attrs([Attr("address","0x610")]), Phis([]), +Defs([Def(Tid(1_337, "%00000539"), Attrs([Attr("address","0x610"), +Attr("insn","adrp x16, #126976")]), Var("R16",Imm(64)), Int(126976,64)), +Def(Tid(1_344, "%00000540"), Attrs([Attr("address","0x614"), +Attr("insn","ldr x17, [x16, #0xfb8]")]), Var("R17",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R16",Imm(64)),Int(4024,64)),LittleEndian(),64)), +Def(Tid(1_350, "%00000546"), Attrs([Attr("address","0x618"), +Attr("insn","add x16, x16, #0xfb8")]), Var("R16",Imm(64)), +PLUS(Var("R16",Imm(64)),Int(4024,64)))]), Jmps([Call(Tid(1_355, "%0000054b"), + Attrs([Attr("address","0x61C"), Attr("insn","br x17")]), Int(1,1), +(Indirect(Var("R17",Imm(64))),))]))])), +Sub(Tid(1_735, "@register_tm_clones"), Attrs([Attr("address","0x6C0"), +Attr("c.proto","signed (*)(void)")]), "register_tm_clones", + Args([Arg(Tid(1_787, "%000006fb"), Attrs([Attr("c.data","Top:u32"), +Attr("c.layout","[signed : 32]"), Attr("c.type","signed")]), + Var("register_tm_clones_result",Imm(32)), LOW(32,Var("R0",Imm(64))), +Out())]), Blks([Blk(Tid(647, "@register_tm_clones"), + Attrs([Attr("address","0x6C0")]), Phis([]), Defs([Def(Tid(650, "%0000028a"), + Attrs([Attr("address","0x6C0"), Attr("insn","adrp x0, #131072")]), + Var("R0",Imm(64)), Int(131072,64)), Def(Tid(656, "%00000290"), + Attrs([Attr("address","0x6C4"), Attr("insn","add x0, x0, #0x10")]), + Var("R0",Imm(64)), PLUS(Var("R0",Imm(64)),Int(16,64))), +Def(Tid(661, "%00000295"), Attrs([Attr("address","0x6C8"), +Attr("insn","adrp x1, #131072")]), Var("R1",Imm(64)), Int(131072,64)), +Def(Tid(667, "%0000029b"), Attrs([Attr("address","0x6CC"), +Attr("insn","add x1, x1, #0x10")]), Var("R1",Imm(64)), +PLUS(Var("R1",Imm(64)),Int(16,64))), Def(Tid(674, "%000002a2"), + Attrs([Attr("address","0x6D0"), Attr("insn","sub x1, x1, x0")]), + Var("R1",Imm(64)), +PLUS(PLUS(Var("R1",Imm(64)),NOT(Var("R0",Imm(64)))),Int(1,64))), +Def(Tid(680, "%000002a8"), Attrs([Attr("address","0x6D4"), +Attr("insn","lsr x2, x1, #63")]), Var("R2",Imm(64)), +Concat(Int(0,63),Extract(63,63,Var("R1",Imm(64))))), +Def(Tid(687, "%000002af"), Attrs([Attr("address","0x6D8"), +Attr("insn","add x1, x2, x1, asr #3")]), Var("R1",Imm(64)), +PLUS(Var("R2",Imm(64)),ARSHIFT(Var("R1",Imm(64)),Int(3,3)))), +Def(Tid(693, "%000002b5"), Attrs([Attr("address","0x6DC"), +Attr("insn","asr x1, x1, #1")]), Var("R1",Imm(64)), +SIGNED(64,Extract(63,1,Var("R1",Imm(64)))))]), +Jmps([Goto(Tid(699, "%000002bb"), Attrs([Attr("address","0x6E0"), +Attr("insn","cbz x1, #0x18")]), EQ(Var("R1",Imm(64)),Int(0,64)), +Direct(Tid(697, "%000002b9"))), Goto(Tid(1_766, "%000006e6"), Attrs([]), + Int(1,1), Direct(Tid(1_055, "%0000041f")))])), Blk(Tid(1_055, "%0000041f"), + Attrs([Attr("address","0x6E4")]), Phis([]), +Defs([Def(Tid(1_058, "%00000422"), Attrs([Attr("address","0x6E4"), +Attr("insn","adrp x2, #126976")]), Var("R2",Imm(64)), Int(126976,64)), +Def(Tid(1_065, "%00000429"), Attrs([Attr("address","0x6E8"), +Attr("insn","ldr x2, [x2, #0xff8]")]), Var("R2",Imm(64)), +Load(Var("mem",Mem(64,8)),PLUS(Var("R2",Imm(64)),Int(4088,64)),LittleEndian(),64))]), +Jmps([Goto(Tid(1_070, "%0000042e"), Attrs([Attr("address","0x6EC"), +Attr("insn","cbz x2, #0xc")]), EQ(Var("R2",Imm(64)),Int(0,64)), +Direct(Tid(697, "%000002b9"))), Goto(Tid(1_767, "%000006e7"), Attrs([]), + Int(1,1), Direct(Tid(1_074, "%00000432")))])), Blk(Tid(697, "%000002b9"), + Attrs([Attr("address","0x6F8")]), Phis([]), Defs([]), +Jmps([Call(Tid(705, "%000002c1"), Attrs([Attr("address","0x6F8"), +Attr("insn","ret")]), Int(1,1), (Indirect(Var("R30",Imm(64))),))])), +Blk(Tid(1_074, "%00000432"), Attrs([Attr("address","0x6F0")]), Phis([]), +Defs([Def(Tid(1_078, "%00000436"), Attrs([Attr("address","0x6F0"), +Attr("insn","mov x16, x2")]), Var("R16",Imm(64)), Var("R2",Imm(64)))]), +Jmps([Call(Tid(1_083, "%0000043b"), Attrs([Attr("address","0x6F4"), +Attr("insn","br x16")]), Int(1,1), +(Indirect(Var("R16",Imm(64))),))]))]))]))) \ No newline at end of file diff --git a/src/test/dsa/unsafe_pointer_arithmetic/unsafe_pointer_arithmetic.bir b/src/test/dsa/unsafe_pointer_arithmetic/unsafe_pointer_arithmetic.bir new file mode 100644 index 000000000..3b2746f07 --- /dev/null +++ b/src/test/dsa/unsafe_pointer_arithmetic/unsafe_pointer_arithmetic.bir @@ -0,0 +1,268 @@ +000006ca: program +000006b3: sub __cxa_finalize(__cxa_finalize_result) +000006cb: __cxa_finalize_result :: out u32 = low:32[R0] + +0000041b: +00000523: R16 := 0x1F000 +0000052a: R17 := mem[R16 + 0xFB0, el]:u64 +00000530: R16 := R16 + 0xFB0 +00000535: call R17 with noreturn + +000006b4: sub __do_global_dtors_aux(__do_global_dtors_aux_result) +000006cc: __do_global_dtors_aux_result :: out u32 = low:32[R0] + +000002c5: +000002c9: #3 := R31 - 0x20 +000002cf: mem := mem with [#3, el]:u64 <- R29 +000002d5: mem := mem with [#3 + 8, el]:u64 <- R30 +000002d9: R31 := #3 +000002df: R29 := R31 +000002e7: mem := mem with [R31 + 0x10, el]:u64 <- R19 +000002ec: R19 := 0x20000 +000002f3: R0 := pad:64[mem[R19 + 0x10]] +000002fa: when 31:0[R0] <> 0 goto %000002f8 +000006b5: goto %000003e4 + +000003e4: +000003e7: R0 := 0x1F000 +000003ee: R0 := mem[R0 + 0xFE0, el]:u64 +000003f4: when R0 = 0 goto %000003f2 +000006b6: goto %0000040b + +0000040b: +0000040e: R0 := 0x20000 +00000415: R0 := mem[R0 + 8, el]:u64 +0000041a: R30 := 0x730 +0000041d: call @__cxa_finalize with return %000003f2 + +000003f2: +000003fa: R30 := 0x734 +000003fc: call @deregister_tm_clones with return %000003fe + +000003fe: +00000401: R0 := 1 +00000409: mem := mem with [R19 + 0x10] <- 7:0[R0] +000006b7: goto %000002f8 + +000002f8: +00000302: R19 := mem[R31 + 0x10, el]:u64 +00000309: R29 := mem[R31, el]:u64 +0000030e: R30 := mem[R31 + 8, el]:u64 +00000312: R31 := R31 + 0x20 +00000317: call R30 with noreturn + +000006b8: sub __libc_start_main(__libc_start_main_main, __libc_start_main_arg2, __libc_start_main_arg3, __libc_start_main_auxv, __libc_start_main_result) +000006cd: __libc_start_main_main :: in u64 = R0 +000006ce: __libc_start_main_arg2 :: in u32 = low:32[R1] +000006cf: __libc_start_main_arg3 :: in out u64 = R2 +000006d0: __libc_start_main_auxv :: in out u64 = R3 +000006d1: __libc_start_main_result :: out u32 = low:32[R0] + +0000021e: +0000050d: R16 := 0x1F000 +00000514: R17 := mem[R16 + 0xFA8, el]:u64 +0000051a: R16 := R16 + 0xFA8 +0000051f: call R17 with noreturn + +000006b9: sub _fini(_fini_result) +000006d2: _fini_result :: out u32 = low:32[R0] + +00000032: +00000038: #0 := R31 - 0x10 +0000003e: mem := mem with [#0, el]:u64 <- R29 +00000044: mem := mem with [#0 + 8, el]:u64 <- R30 +00000048: R31 := #0 +0000004e: R29 := R31 +00000055: R29 := mem[R31, el]:u64 +0000005a: R30 := mem[R31 + 8, el]:u64 +0000005e: R31 := R31 + 0x10 +00000063: call R30 with noreturn + +000006ba: sub _init(_init_result) +000006d3: _init_result :: out u32 = low:32[R0] + +000005f8: +000005fe: #6 := R31 - 0x10 +00000604: mem := mem with [#6, el]:u64 <- R29 +0000060a: mem := mem with [#6 + 8, el]:u64 <- R30 +0000060e: R31 := #6 +00000614: R29 := R31 +00000619: R30 := 0x5C8 +0000061b: call @call_weak_fn with return %0000061d + +0000061d: +00000622: R29 := mem[R31, el]:u64 +00000627: R30 := mem[R31 + 8, el]:u64 +0000062b: R31 := R31 + 0x10 +00000630: call R30 with noreturn + +000006bb: sub _start(_start_result) +000006d4: _start_result :: out u32 = low:32[R0] + +000001df: +000001e4: R29 := 0 +000001e9: R30 := 0 +000001ef: R5 := R0 +000001f6: R1 := mem[R31, el]:u64 +000001fc: R2 := R31 + 8 +00000202: R6 := R31 +00000207: R0 := 0x1F000 +0000020e: R0 := mem[R0 + 0xFF0, el]:u64 +00000213: R3 := 0 +00000218: R4 := 0 +0000021d: R30 := 0x670 +00000220: call @__libc_start_main with return %00000222 + +00000222: +00000225: R30 := 0x674 +00000228: call @abort with return %000006bc + +000006bc: +000006bd: call @call_weak_fn with noreturn + +000006be: sub abort() + + +00000226: +00000565: R16 := 0x1F000 +0000056c: R17 := mem[R16 + 0xFC8, el]:u64 +00000572: R16 := R16 + 0xFC8 +00000577: call R17 with noreturn + +000006bf: sub call_weak_fn(call_weak_fn_result) +000006d5: call_weak_fn_result :: out u32 = low:32[R0] + +0000022a: +0000022d: R0 := 0x1F000 +00000234: R0 := mem[R0 + 0xFE8, el]:u64 +0000023a: when R0 = 0 goto %00000238 +000006c0: goto %0000045b + +00000238: +00000240: call R30 with noreturn + +0000045b: +0000045e: goto @__gmon_start__ + +0000045c: +0000054f: R16 := 0x1F000 +00000556: R17 := mem[R16 + 0xFC0, el]:u64 +0000055c: R16 := R16 + 0xFC0 +00000561: call R17 with noreturn + +000006c1: sub deregister_tm_clones(deregister_tm_clones_result) +000006d6: deregister_tm_clones_result :: out u32 = low:32[R0] + +00000246: +00000249: R0 := 0x20000 +0000024f: R0 := R0 + 0x10 +00000254: R1 := 0x20000 +0000025a: R1 := R1 + 0x10 +00000260: #1 := ~R0 +00000265: #2 := R1 + ~R0 +0000026b: VF := extend:65[#2 + 1] <> extend:65[R1] + extend:65[#1] + 1 +00000271: CF := pad:65[#2 + 1] <> pad:65[R1] + pad:65[#1] + 1 +00000275: ZF := #2 + 1 = 0 +00000279: NF := 63:63[#2 + 1] +0000027f: when ZF goto %0000027d +000006c2: goto %0000043d + +0000043d: +00000440: R1 := 0x1F000 +00000447: R1 := mem[R1 + 0xFD8, el]:u64 +0000044c: when R1 = 0 goto %0000027d +000006c3: goto %00000450 + +0000027d: +00000285: call R30 with noreturn + +00000450: +00000454: R16 := R1 +00000459: call R16 with noreturn + +000006c4: sub frame_dummy(frame_dummy_result) +000006d7: frame_dummy_result :: out u32 = low:32[R0] + +0000031d: +0000031f: call @register_tm_clones with noreturn + +000006c5: sub main(main_argc, main_argv, main_result) +000006d8: main_argc :: in u32 = low:32[R0] +000006d9: main_argv :: in out u64 = R1 +000006da: main_result :: out u32 = low:32[R0] + +00000321: +00000325: #4 := R31 - 0x40 +0000032b: mem := mem with [#4, el]:u64 <- R29 +00000331: mem := mem with [#4 + 8, el]:u64 <- R30 +00000335: R31 := #4 +0000033b: R29 := R31 +00000340: R0 := 0x14 +00000345: R30 := 0x764 +00000348: call @malloc with return %0000034a + +0000034a: +00000350: mem := mem with [R31 + 0x18, el]:u64 <- R0 +00000357: R0 := mem[R31 + 0x18, el]:u64 +0000035c: R1 := 0xC +00000364: mem := mem with [R0, el]:u32 <- 31:0[R1] +0000036b: R0 := mem[R31 + 0x18, el]:u64 +00000373: mem := mem with [R31 + 0x20, el]:u64 <- R0 +0000037a: R0 := mem[R31 + 0x20, el]:u64 +00000380: R0 := R0 + 1 +00000388: mem := mem with [R31 + 0x28, el]:u64 <- R0 +0000038d: R0 := 8 +00000392: R30 := 0x790 +00000394: call @malloc with return %00000396 + +00000396: +0000039c: mem := mem with [R31 + 0x30, el]:u64 <- R0 +000003a3: R0 := mem[R31 + 0x30, el]:u64 +000003aa: R1 := mem[R31 + 0x28, el]:u64 +000003b2: mem := mem with [R0, el]:u64 <- R1 +000003b9: R0 := mem[R31 + 0x30, el]:u64 +000003c0: R0 := mem[R0, el]:u64 +000003c8: mem := mem with [R31 + 0x38, el]:u64 <- R0 +000003cd: R0 := 0 +000003d4: R29 := mem[R31, el]:u64 +000003d9: R30 := mem[R31 + 8, el]:u64 +000003dd: R31 := R31 + 0x40 +000003e2: call R30 with noreturn + +000006c6: sub malloc(malloc_size, malloc_result) +000006db: malloc_size :: in u64 = R0 +000006dc: malloc_result :: out u64 = R0 + +00000346: +00000539: R16 := 0x1F000 +00000540: R17 := mem[R16 + 0xFB8, el]:u64 +00000546: R16 := R16 + 0xFB8 +0000054b: call R17 with noreturn + +000006c7: sub register_tm_clones(register_tm_clones_result) +000006dd: register_tm_clones_result :: out u32 = low:32[R0] + +00000287: +0000028a: R0 := 0x20000 +00000290: R0 := R0 + 0x10 +00000295: R1 := 0x20000 +0000029b: R1 := R1 + 0x10 +000002a2: R1 := R1 + ~R0 + 1 +000002a8: R2 := 0.63:63[R1] +000002af: R1 := R2 + (R1 ~>> 3) +000002b5: R1 := extend:64[63:1[R1]] +000002bb: when R1 = 0 goto %000002b9 +000006c8: goto %0000041f + +0000041f: +00000422: R2 := 0x1F000 +00000429: R2 := mem[R2 + 0xFF8, el]:u64 +0000042e: when R2 = 0 goto %000002b9 +000006c9: goto %00000432 + +000002b9: +000002c1: call R30 with noreturn + +00000432: +00000436: R16 := R2 +0000043b: call R16 with noreturn diff --git a/src/test/dsa/unsafe_pointer_arithmetic/unsafe_pointer_arithmetic.c b/src/test/dsa/unsafe_pointer_arithmetic/unsafe_pointer_arithmetic.c new file mode 100644 index 000000000..d3c43c655 --- /dev/null +++ b/src/test/dsa/unsafe_pointer_arithmetic/unsafe_pointer_arithmetic.c @@ -0,0 +1,12 @@ +#include + + +int main() { + int *bar = malloc(5 * sizeof(int)); + *bar = 12; + void * car = (void*) bar; + int* foo = (int*) (car + 1); + int ** tar = malloc(sizeof(int*)); + *tar = foo; + int *bat = *tar; +} diff --git a/src/test/dsa/unsafe_pointer_arithmetic/unsafe_pointer_arithmetic.relf b/src/test/dsa/unsafe_pointer_arithmetic/unsafe_pointer_arithmetic.relf new file mode 100644 index 000000000..ee608ea91 --- /dev/null +++ b/src/test/dsa/unsafe_pointer_arithmetic/unsafe_pointer_arithmetic.relf @@ -0,0 +1,122 @@ + +Relocation section '.rela.dyn' at offset 0x480 contains 8 entries: + Offset Info Type Symbol's Value Symbol's Name + Addend +000000000001fd90 0000000000000403 R_AARCH64_RELATIVE 750 +000000000001fd98 0000000000000403 R_AARCH64_RELATIVE 700 +000000000001fff0 0000000000000403 R_AARCH64_RELATIVE 754 +0000000000020008 0000000000000403 R_AARCH64_RELATIVE 20008 +000000000001ffd8 0000000400000401 R_AARCH64_GLOB_DAT 0000000000000000 _ITM_deregisterTMCloneTable + 0 +000000000001ffe0 0000000500000401 R_AARCH64_GLOB_DAT 0000000000000000 __cxa_finalize@GLIBC_2.17 + 0 +000000000001ffe8 0000000700000401 R_AARCH64_GLOB_DAT 0000000000000000 __gmon_start__ + 0 +000000000001fff8 0000000900000401 R_AARCH64_GLOB_DAT 0000000000000000 _ITM_registerTMCloneTable + 0 + +Relocation section '.rela.plt' at offset 0x540 contains 5 entries: + Offset Info Type Symbol's Value Symbol's Name + Addend +000000000001ffa8 0000000300000402 R_AARCH64_JUMP_SLOT 0000000000000000 __libc_start_main@GLIBC_2.34 + 0 +000000000001ffb0 0000000500000402 R_AARCH64_JUMP_SLOT 0000000000000000 __cxa_finalize@GLIBC_2.17 + 0 +000000000001ffb8 0000000600000402 R_AARCH64_JUMP_SLOT 0000000000000000 malloc@GLIBC_2.17 + 0 +000000000001ffc0 0000000700000402 R_AARCH64_JUMP_SLOT 0000000000000000 __gmon_start__ + 0 +000000000001ffc8 0000000800000402 R_AARCH64_JUMP_SLOT 0000000000000000 abort@GLIBC_2.17 + 0 + +Symbol table '.dynsym' contains 10 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 00000000000005b8 0 SECTION LOCAL DEFAULT 11 .init + 2: 0000000000020000 0 SECTION LOCAL DEFAULT 22 .data + 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.34 (2) + 4: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTable + 5: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@GLIBC_2.17 (3) + 6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND malloc@GLIBC_2.17 (3) + 7: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__ + 8: 0000000000000000 0 FUNC GLOBAL DEFAULT UND abort@GLIBC_2.17 (3) + 9: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable + +Symbol table '.symtab' contains 87 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000000238 0 SECTION LOCAL DEFAULT 1 .interp + 2: 0000000000000254 0 SECTION LOCAL DEFAULT 2 .note.gnu.build-id + 3: 0000000000000278 0 SECTION LOCAL DEFAULT 3 .note.ABI-tag + 4: 0000000000000298 0 SECTION LOCAL DEFAULT 4 .gnu.hash + 5: 00000000000002b8 0 SECTION LOCAL DEFAULT 5 .dynsym + 6: 00000000000003a8 0 SECTION LOCAL DEFAULT 6 .dynstr + 7: 000000000000043c 0 SECTION LOCAL DEFAULT 7 .gnu.version + 8: 0000000000000450 0 SECTION LOCAL DEFAULT 8 .gnu.version_r + 9: 0000000000000480 0 SECTION LOCAL DEFAULT 9 .rela.dyn + 10: 0000000000000540 0 SECTION LOCAL DEFAULT 10 .rela.plt + 11: 00000000000005b8 0 SECTION LOCAL DEFAULT 11 .init + 12: 00000000000005d0 0 SECTION LOCAL DEFAULT 12 .plt + 13: 0000000000000640 0 SECTION LOCAL DEFAULT 13 .text + 14: 00000000000007b8 0 SECTION LOCAL DEFAULT 14 .fini + 15: 00000000000007cc 0 SECTION LOCAL DEFAULT 15 .rodata + 16: 00000000000007d0 0 SECTION LOCAL DEFAULT 16 .eh_frame_hdr + 17: 0000000000000810 0 SECTION LOCAL DEFAULT 17 .eh_frame + 18: 000000000001fd90 0 SECTION LOCAL DEFAULT 18 .init_array + 19: 000000000001fd98 0 SECTION LOCAL DEFAULT 19 .fini_array + 20: 000000000001fda0 0 SECTION LOCAL DEFAULT 20 .dynamic + 21: 000000000001ff90 0 SECTION LOCAL DEFAULT 21 .got + 22: 0000000000020000 0 SECTION LOCAL DEFAULT 22 .data + 23: 0000000000020010 0 SECTION LOCAL DEFAULT 23 .bss + 24: 0000000000000000 0 SECTION LOCAL DEFAULT 24 .comment + 25: 0000000000000000 0 FILE LOCAL DEFAULT ABS Scrt1.o + 26: 0000000000000278 0 NOTYPE LOCAL DEFAULT 3 $d + 27: 0000000000000278 32 OBJECT LOCAL DEFAULT 3 __abi_tag + 28: 0000000000000640 0 NOTYPE LOCAL DEFAULT 13 $x + 29: 0000000000000824 0 NOTYPE LOCAL DEFAULT 17 $d + 30: 00000000000007cc 0 NOTYPE LOCAL DEFAULT 15 $d + 31: 0000000000000000 0 FILE LOCAL DEFAULT ABS crti.o + 32: 0000000000000674 0 NOTYPE LOCAL DEFAULT 13 $x + 33: 0000000000000674 20 FUNC LOCAL DEFAULT 13 call_weak_fn + 34: 00000000000005b8 0 NOTYPE LOCAL DEFAULT 11 $x + 35: 00000000000007b8 0 NOTYPE LOCAL DEFAULT 14 $x + 36: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtn.o + 37: 00000000000005c8 0 NOTYPE LOCAL DEFAULT 11 $x + 38: 00000000000007c4 0 NOTYPE LOCAL DEFAULT 14 $x + 39: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c + 40: 0000000000000690 0 NOTYPE LOCAL DEFAULT 13 $x + 41: 0000000000000690 0 FUNC LOCAL DEFAULT 13 deregister_tm_clones + 42: 00000000000006c0 0 FUNC LOCAL DEFAULT 13 register_tm_clones + 43: 0000000000020008 0 NOTYPE LOCAL DEFAULT 22 $d + 44: 0000000000000700 0 FUNC LOCAL DEFAULT 13 __do_global_dtors_aux + 45: 0000000000020010 1 OBJECT LOCAL DEFAULT 23 completed.0 + 46: 000000000001fd98 0 NOTYPE LOCAL DEFAULT 19 $d + 47: 000000000001fd98 0 OBJECT LOCAL DEFAULT 19 __do_global_dtors_aux_fini_array_entry + 48: 0000000000000750 0 FUNC LOCAL DEFAULT 13 frame_dummy + 49: 000000000001fd90 0 NOTYPE LOCAL DEFAULT 18 $d + 50: 000000000001fd90 0 OBJECT LOCAL DEFAULT 18 __frame_dummy_init_array_entry + 51: 0000000000000838 0 NOTYPE LOCAL DEFAULT 17 $d + 52: 0000000000020010 0 NOTYPE LOCAL DEFAULT 23 $d + 53: 0000000000000000 0 FILE LOCAL DEFAULT ABS unsafe_pointer_arithmetic.c + 54: 0000000000000754 0 NOTYPE LOCAL DEFAULT 13 $x + 55: 0000000000000898 0 NOTYPE LOCAL DEFAULT 17 $d + 56: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c + 57: 00000000000008b8 0 NOTYPE LOCAL DEFAULT 17 $d + 58: 00000000000008b8 0 OBJECT LOCAL DEFAULT 17 __FRAME_END__ + 59: 0000000000000000 0 FILE LOCAL DEFAULT ABS + 60: 000000000001fda0 0 OBJECT LOCAL DEFAULT ABS _DYNAMIC + 61: 00000000000007d0 0 NOTYPE LOCAL DEFAULT 16 __GNU_EH_FRAME_HDR + 62: 000000000001ffd0 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ + 63: 00000000000005d0 0 NOTYPE LOCAL DEFAULT 12 $x + 64: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.34 + 65: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTable + 66: 0000000000020000 0 NOTYPE WEAK DEFAULT 22 data_start + 67: 0000000000020010 0 NOTYPE GLOBAL DEFAULT 23 __bss_start__ + 68: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@GLIBC_2.17 + 69: 0000000000020018 0 NOTYPE GLOBAL DEFAULT 23 _bss_end__ + 70: 0000000000020010 0 NOTYPE GLOBAL DEFAULT 22 _edata + 71: 00000000000007b8 0 FUNC GLOBAL HIDDEN 14 _fini + 72: 0000000000020018 0 NOTYPE GLOBAL DEFAULT 23 __bss_end__ + 73: 0000000000000000 0 FUNC GLOBAL DEFAULT UND malloc@GLIBC_2.17 + 74: 0000000000020000 0 NOTYPE GLOBAL DEFAULT 22 __data_start + 75: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__ + 76: 0000000000020008 0 OBJECT GLOBAL HIDDEN 22 __dso_handle + 77: 0000000000000000 0 FUNC GLOBAL DEFAULT UND abort@GLIBC_2.17 + 78: 00000000000007cc 4 OBJECT GLOBAL DEFAULT 15 _IO_stdin_used + 79: 0000000000020018 0 NOTYPE GLOBAL DEFAULT 23 _end + 80: 0000000000000640 52 FUNC GLOBAL DEFAULT 13 _start + 81: 0000000000020018 0 NOTYPE GLOBAL DEFAULT 23 __end__ + 82: 0000000000020010 0 NOTYPE GLOBAL DEFAULT 23 __bss_start + 83: 0000000000000754 100 FUNC GLOBAL DEFAULT 13 main + 84: 0000000000020010 0 OBJECT GLOBAL HIDDEN 22 __TMC_END__ + 85: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable + 86: 00000000000005b8 0 FUNC GLOBAL HIDDEN 11 _init diff --git a/src/test/incorrect/basicassign/clang/basicassign.expected b/src/test/incorrect/basicassign/clang/basicassign.expected index 9ec8af73d..02b8d1f0e 100644 --- a/src/test/incorrect/basicassign/clang/basicassign.expected +++ b/src/test/incorrect/basicassign/clang/basicassign.expected @@ -1,4 +1,14 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); @@ -6,30 +16,17 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69692bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +46,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -82,65 +72,60 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R11, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R11, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1888bv64) == 1bv8); - free requires (memory_load8_le(mem, 1889bv64) == 0bv8); - free requires (memory_load8_le(mem, 1890bv64) == 2bv8); - free requires (memory_load8_le(mem, 1891bv64) == 0bv8); + free requires (memory_load32_le(mem, 1888bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_3: bool; - var Gamma_R11_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_2: bool; - var R10_3: bv64; - var R11_2: bv64; - var R8_3: bv64; - var R9_2: bv32; lmain: + assume {:captureState "lmain"} true; + R10, Gamma_R10 := 69632bv64, true; call rely(); - R9_2, Gamma_R9_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R10, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R10, 52bv64)) || L(mem, bvadd64(R10, 52bv64))); + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R9_2); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R9_2), gamma_store32(Gamma_mem, 69688bv64, Gamma_R9_2); + assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R9); + assume {:captureState "%000002f9"} true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 0bv32), gamma_store32(Gamma_mem, 69688bv64, true); + assert (L(mem, bvadd64(R8, 56bv64)) ==> true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); + assume {:captureState "%00000305"} true; call rely(); - R11_2, Gamma_R11_2 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R11, Gamma_R11 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69692bv64) ==> Gamma_R11_2); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, R11_2[32:0]), gamma_store32(Gamma_mem, 69692bv64, Gamma_R11_2); + assert (L(mem, bvadd64(R9, 60bv64)) ==> Gamma_R11); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 60bv64), R11[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 60bv64), Gamma_R11); + assume {:captureState "%00000319"} true; call rely(); - R10_3, Gamma_R10_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, bvadd64(R10, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R10, 52bv64)) || L(mem, bvadd64(R10, 52bv64))); call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R10_3); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R10_3[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R10_3); + assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R10); + assume {:captureState "%00000328"} true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); call rely(); - assert (L(mem, 69692bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69692bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 60bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 60bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 60bv64), Gamma_R8); + assume {:captureState "%00000337"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R8_out, R9_out := 0bv64, R10_3, R11_2, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_3, Gamma_R11_2, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign/clang/basicassign_gtirb.expected b/src/test/incorrect/basicassign/clang/basicassign_gtirb.expected index 760d55f22..563cb3087 100644 --- a/src/test/incorrect/basicassign/clang/basicassign_gtirb.expected +++ b/src/test/incorrect/basicassign/clang/basicassign_gtirb.expected @@ -1,4 +1,14 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); @@ -6,30 +16,17 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69692bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +37,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +46,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -82,65 +72,60 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R11, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R11, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1888bv64) == 1bv8); - free requires (memory_load8_le(mem, 1889bv64) == 0bv8); - free requires (memory_load8_le(mem, 1890bv64) == 2bv8); - free requires (memory_load8_le(mem, 1891bv64) == 0bv8); + free requires (memory_load32_le(mem, 1888bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1888bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1889bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1890bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1891bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1888bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_3: bool; - var Gamma_R11_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_2: bool; - var R10_3: bv64; - var R11_2: bv64; - var R8_3: bv64; - var R9_2: bv64; $main$__0__$5TUZGs9lQbqOTt1I7Z4dfw: + assume {:captureState "$main$__0__$5TUZGs9lQbqOTt1I7Z4dfw"} true; + R10, Gamma_R10 := 69632bv64, true; call rely(); - R9_2, Gamma_R9_2 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R10, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R10, 52bv64)) || L(mem, bvadd64(R10, 52bv64))); + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R9_2); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R9_2[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R9_2); + assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R9); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, 0bv32), gamma_store32(Gamma_mem, 69688bv64, true); + assert (L(mem, bvadd64(R8, 56bv64)) ==> true); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); + assume {:captureState "1832$0"} true; call rely(); - R11_2, Gamma_R11_2 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R11, Gamma_R11 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69692bv64) ==> Gamma_R11_2); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, R11_2[32:0]), gamma_store32(Gamma_mem, 69692bv64, Gamma_R11_2); + assert (L(mem, bvadd64(R9, 60bv64)) ==> Gamma_R11); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 60bv64), R11[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 60bv64), Gamma_R11); + assume {:captureState "1844$0"} true; call rely(); - R10_3, Gamma_R10_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, bvadd64(R10, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R10, 52bv64)) || L(mem, bvadd64(R10, 52bv64))); call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R10_3); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R10_3[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R10_3); + assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R10); + assume {:captureState "1852$0"} true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); call rely(); - assert (L(mem, 69692bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69692bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 60bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 60bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 60bv64), Gamma_R8); + assume {:captureState "1860$0"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R8_out, R9_out := 0bv64, R10_3, R11_2, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_3, Gamma_R11_2, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign/clang_O2/basicassign.expected b/src/test/incorrect/basicassign/clang_O2/basicassign.expected index 80b3708bc..8b0e755c9 100644 --- a/src/test/incorrect/basicassign/clang_O2/basicassign.expected +++ b/src/test/incorrect/basicassign/clang_O2/basicassign.expected @@ -1,4 +1,12 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); @@ -6,30 +14,17 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69692bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +35,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +44,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1864bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1865bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1866bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1867bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1864bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -82,44 +70,42 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1864bv64) == 1bv8); - free requires (memory_load8_le(mem, 1865bv64) == 0bv8); - free requires (memory_load8_le(mem, 1866bv64) == 2bv8); - free requires (memory_load8_le(mem, 1867bv64) == 0bv8); + free requires (memory_load32_le(mem, 1864bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1864bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1865bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1866bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1867bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1864bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var R8_3: bv64; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R10, Gamma_R10 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%000002eb"} true; call rely(); - assert (L(mem, 69692bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69692bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R10, 60bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 60bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R10, 60bv64), Gamma_R8); + assume {:captureState "%000002f3"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R8_out, R9_out := 0bv64, 69632bv64, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign/clang_O2/basicassign_gtirb.expected b/src/test/incorrect/basicassign/clang_O2/basicassign_gtirb.expected index bf69fc090..abae7f906 100644 --- a/src/test/incorrect/basicassign/clang_O2/basicassign_gtirb.expected +++ b/src/test/incorrect/basicassign/clang_O2/basicassign_gtirb.expected @@ -1,4 +1,12 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); @@ -6,30 +14,17 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69692bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +35,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +44,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1864bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1865bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1866bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1867bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1864bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -82,44 +70,42 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1864bv64) == 1bv8); - free requires (memory_load8_le(mem, 1865bv64) == 0bv8); - free requires (memory_load8_le(mem, 1866bv64) == 2bv8); - free requires (memory_load8_le(mem, 1867bv64) == 0bv8); + free requires (memory_load32_le(mem, 1864bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1864bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1865bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1866bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1867bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1864bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var R8_3: bv64; $main$__0__$u9YlOfvWQuymdyQoiJ6f2w: + assume {:captureState "$main$__0__$u9YlOfvWQuymdyQoiJ6f2w"} true; + R8, Gamma_R8 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R10, Gamma_R10 := 69632bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "1832$0"} true; call rely(); - assert (L(mem, 69692bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, 69692bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69692bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R10, 60bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 60bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R10, 60bv64), Gamma_R8); + assume {:captureState "1836$0"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R8_out, R9_out := 0bv64, 69632bv64, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R8_out, Gamma_R9_out := true, true, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign/clang_pic/basicassign.expected b/src/test/incorrect/basicassign/clang_pic/basicassign.expected index 64fc2fbbe..df8da4c63 100644 --- a/src/test/incorrect/basicassign/clang_pic/basicassign.expected +++ b/src/test/incorrect/basicassign/clang_pic/basicassign.expected @@ -1,4 +1,14 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); @@ -6,20 +16,11 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69692bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +30,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,12 +41,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,17 +50,14 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69040bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69560bv64) == 69692bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69560bv64) == 69692bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -89,83 +79,72 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R11, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R11, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69048bv64) == 1792bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); free requires (memory_load64_le(mem, 69040bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69048bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69560bv64) == 69692bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69560bv64) == 69692bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69040bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69560bv64) == 69692bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69560bv64) == 69692bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_3: bool; - var Gamma_R10_4: bool; - var Gamma_R11_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R9_2: bool; - var Gamma_R9_4: bool; - var R10_3: bv64; - var R10_4: bv64; - var R11_2: bv64; - var R8_3: bv64; - var R8_4: bv64; - var R9_2: bv32; - var R9_4: bv64; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); + R10, Gamma_R10 := 65536bv64, true; call rely(); - R10_3, Gamma_R10_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R10, Gamma_R10 := memory_load64_le(mem, bvadd64(R10, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R10, 4048bv64)) || L(mem, bvadd64(R10, 4048bv64))); call rely(); - R9_2, Gamma_R9_2 := memory_load32_le(mem, R10_3), (gamma_load32(Gamma_mem, R10_3) || L(mem, R10_3)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, R10)), (gamma_load32(Gamma_mem, R10) || L(mem, R10)); call rely(); - assert (L(mem, R8_3) ==> Gamma_R9_2); - mem, Gamma_mem := memory_store32_le(mem, R8_3, R9_2), gamma_store32(Gamma_mem, R8_3, Gamma_R9_2); + assert (L(mem, R8) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, R8, R9[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R9); + assume {:captureState "%00000313"} true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, R8_3) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R8_3, 0bv32), gamma_store32(Gamma_mem, R8_3, true); + assert (L(mem, R8) ==> true); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); + assume {:captureState "%0000031f"} true; call rely(); - R11_2, Gamma_R11_2 := zero_extend32_32(memory_load32_le(mem, R8_3)), (gamma_load32(Gamma_mem, R8_3) || L(mem, R8_3)); + R11, Gamma_R11 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_4, Gamma_R9_4 := memory_load64_le(mem, 69560bv64), (gamma_load64(Gamma_mem, 69560bv64) || L(mem, 69560bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4024bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4024bv64)) || L(mem, bvadd64(R9, 4024bv64))); call rely(); - assert (L(mem, R9_4) ==> Gamma_R11_2); - mem, Gamma_mem := memory_store32_le(mem, R9_4, R11_2[32:0]), gamma_store32(Gamma_mem, R9_4, Gamma_R11_2); + assert (L(mem, R9) ==> Gamma_R11); + mem, Gamma_mem := memory_store32_le(mem, R9, R11[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R11); + assume {:captureState "%0000033a"} true; call rely(); - R10_4, Gamma_R10_4 := zero_extend32_32(memory_load32_le(mem, R10_3)), (gamma_load32(Gamma_mem, R10_3) || L(mem, R10_3)); + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, R10)), (gamma_load32(Gamma_mem, R10) || L(mem, R10)); call rely(); - assert (L(mem, R8_3) ==> Gamma_R10_4); - mem, Gamma_mem := memory_store32_le(mem, R8_3, R10_4[32:0]), gamma_store32(Gamma_mem, R8_3, Gamma_R10_4); + assert (L(mem, R8) ==> Gamma_R10); + mem, Gamma_mem := memory_store32_le(mem, R8, R10[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R10); + assume {:captureState "%00000349"} true; call rely(); - R8_4, Gamma_R8_4 := zero_extend32_32(memory_load32_le(mem, R8_3)), (gamma_load32(Gamma_mem, R8_3) || L(mem, R8_3)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); call rely(); - assert (L(mem, R9_4) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store32_le(mem, R9_4, R8_4[32:0]), gamma_store32(Gamma_mem, R9_4, Gamma_R8_4); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000358"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R8_out, R9_out := 0bv64, R10_4, R11_2, R8_4, R9_4; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_4, Gamma_R11_2, Gamma_R8_4, Gamma_R9_4; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign/clang_pic/basicassign_gtirb.expected b/src/test/incorrect/basicassign/clang_pic/basicassign_gtirb.expected index 592b892b6..60c48f7f5 100644 --- a/src/test/incorrect/basicassign/clang_pic/basicassign_gtirb.expected +++ b/src/test/incorrect/basicassign/clang_pic/basicassign_gtirb.expected @@ -1,4 +1,14 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); @@ -6,20 +16,11 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69692bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +30,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,12 +41,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,17 +50,14 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69040bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69560bv64) == 69692bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69560bv64) == 69692bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -89,83 +79,72 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R11, Gamma_R8, Gamma_R9, Gamma_mem, R0, R10, R11, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69048bv64) == 1792bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); free requires (memory_load64_le(mem, 69040bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69048bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69560bv64) == 69692bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69560bv64) == 69692bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69040bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69048bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69560bv64) == 69692bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69560bv64) == 69692bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R10_in: bv64, Gamma_R10_in: bool, R11_in: bv64, Gamma_R11_in: bool, R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R11_out: bv64, Gamma_R11_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_3: bool; - var Gamma_R10_4: bool; - var Gamma_R11_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R9_2: bool; - var Gamma_R9_4: bool; - var R10_3: bv64; - var R10_4: bv64; - var R11_2: bv64; - var R8_3: bv64; - var R8_4: bv64; - var R9_2: bv64; - var R9_4: bv64; $main$__0__$fMW2XwMARUyjjFoB482nbQ: + assume {:captureState "$main$__0__$fMW2XwMARUyjjFoB482nbQ"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); + R10, Gamma_R10 := 65536bv64, true; call rely(); - R10_3, Gamma_R10_3 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R10, Gamma_R10 := memory_load64_le(mem, bvadd64(R10, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R10, 4048bv64)) || L(mem, bvadd64(R10, 4048bv64))); call rely(); - R9_2, Gamma_R9_2 := zero_extend32_32(memory_load32_le(mem, R10_3)), (gamma_load32(Gamma_mem, R10_3) || L(mem, R10_3)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, R10)), (gamma_load32(Gamma_mem, R10) || L(mem, R10)); call rely(); - assert (L(mem, R8_3) ==> Gamma_R9_2); - mem, Gamma_mem := memory_store32_le(mem, R8_3, R9_2[32:0]), gamma_store32(Gamma_mem, R8_3, Gamma_R9_2); + assert (L(mem, R8) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, R8, R9[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R9); + assume {:captureState "1896$0"} true; + R0, Gamma_R0 := 0bv64, true; call rely(); - assert (L(mem, R8_3) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R8_3, 0bv32), gamma_store32(Gamma_mem, R8_3, true); + assert (L(mem, R8) ==> true); + mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); + assume {:captureState "1904$0"} true; call rely(); - R11_2, Gamma_R11_2 := zero_extend32_32(memory_load32_le(mem, R8_3)), (gamma_load32(Gamma_mem, R8_3) || L(mem, R8_3)); + R11, Gamma_R11 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_4, Gamma_R9_4 := memory_load64_le(mem, 69560bv64), (gamma_load64(Gamma_mem, 69560bv64) || L(mem, 69560bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4024bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4024bv64)) || L(mem, bvadd64(R9, 4024bv64))); call rely(); - assert (L(mem, R9_4) ==> Gamma_R11_2); - mem, Gamma_mem := memory_store32_le(mem, R9_4, R11_2[32:0]), gamma_store32(Gamma_mem, R9_4, Gamma_R11_2); + assert (L(mem, R9) ==> Gamma_R11); + mem, Gamma_mem := memory_store32_le(mem, R9, R11[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R11); + assume {:captureState "1920$0"} true; call rely(); - R10_4, Gamma_R10_4 := zero_extend32_32(memory_load32_le(mem, R10_3)), (gamma_load32(Gamma_mem, R10_3) || L(mem, R10_3)); + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, R10)), (gamma_load32(Gamma_mem, R10) || L(mem, R10)); call rely(); - assert (L(mem, R8_3) ==> Gamma_R10_4); - mem, Gamma_mem := memory_store32_le(mem, R8_3, R10_4[32:0]), gamma_store32(Gamma_mem, R8_3, Gamma_R10_4); + assert (L(mem, R8) ==> Gamma_R10); + mem, Gamma_mem := memory_store32_le(mem, R8, R10[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R10); + assume {:captureState "1928$0"} true; call rely(); - R8_4, Gamma_R8_4 := zero_extend32_32(memory_load32_le(mem, R8_3)), (gamma_load32(Gamma_mem, R8_3) || L(mem, R8_3)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); call rely(); - assert (L(mem, R9_4) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store32_le(mem, R9_4, R8_4[32:0]), gamma_store32(Gamma_mem, R9_4, Gamma_R8_4); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1936$0"} true; goto main_basil_return; main_basil_return: - R0_out, R10_out, R11_out, R8_out, R9_out := 0bv64, R10_4, R11_2, R8_4, R9_4; - Gamma_R0_out, Gamma_R10_out, Gamma_R11_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_4, Gamma_R11_2, Gamma_R8_4, Gamma_R9_4; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign/gcc/basicassign.expected b/src/test/incorrect/basicassign/gcc/basicassign.expected index 8ed7c0fd0..94068d3c2 100644 --- a/src/test/incorrect/basicassign/gcc/basicassign.expected +++ b/src/test/incorrect/basicassign/gcc/basicassign.expected @@ -1,4 +1,8 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); @@ -6,30 +10,17 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +31,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +40,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1948bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1949bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1950bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1951bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1948bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -82,65 +66,75 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1948bv64) == 1bv8); - free requires (memory_load8_le(mem, 1949bv64) == 0bv8); - free requires (memory_load8_le(mem, 1950bv64) == 2bv8); - free requires (memory_load8_le(mem, 1951bv64) == 0bv8); + free requires (memory_load32_le(mem, 1948bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1948bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1949bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1950bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1951bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1948bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var R1_2: bv32; - var R1_3: bv32; - var R1_4: bv32; - var R1_5: bv64; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 28bv64), Gamma_R0; call rely(); - R1_2, Gamma_R1_2 := memory_load32_le(mem, 69660bv64), (gamma_load32(Gamma_mem, 69660bv64) || L(mem, 69660bv64)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_2), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000341"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> true); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, 0bv32), gamma_store32(Gamma_mem, 69652bv64, true); + assert (L(mem, R0) ==> true); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assume {:captureState "%00000353"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R1_3, Gamma_R1_3 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R1_3); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, R1_3), gamma_store32(Gamma_mem, 69656bv64, Gamma_R1_3); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000378"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 28bv64), Gamma_R0; call rely(); - R1_4, Gamma_R1_4 := memory_load32_le(mem, 69660bv64), (gamma_load32(Gamma_mem, 69660bv64) || L(mem, 69660bv64)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_4); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_4), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_4); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000039d"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R1_5, Gamma_R1_5 := zero_extend32_32(memory_load32_le(mem, 69652bv64)), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R1_5); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, R1_5[32:0]), gamma_store32(Gamma_mem, 69656bv64, Gamma_R1_5); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003c2"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_5; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign/gcc/basicassign_gtirb.expected b/src/test/incorrect/basicassign/gcc/basicassign_gtirb.expected index 5f9770acf..19dc9e4c2 100644 --- a/src/test/incorrect/basicassign/gcc/basicassign_gtirb.expected +++ b/src/test/incorrect/basicassign/gcc/basicassign_gtirb.expected @@ -1,4 +1,8 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); @@ -6,30 +10,17 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +31,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +40,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1948bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1949bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1950bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1951bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1948bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -82,92 +66,75 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1948bv64) == 1bv8); - free requires (memory_load8_le(mem, 1949bv64) == 0bv8); - free requires (memory_load8_le(mem, 1950bv64) == 2bv8); - free requires (memory_load8_le(mem, 1951bv64) == 0bv8); + free requires (memory_load32_le(mem, 1948bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1948bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1949bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1950bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1951bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1948bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_11: bool; - var Gamma_R0_13: bool; - var Gamma_R0_15: bool; - var Gamma_R0_17: bool; - var Gamma_R0_19: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_9: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var R0_11: bv64; - var R0_13: bv64; - var R0_15: bv64; - var R0_17: bv64; - var R0_19: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_9: bv64; - var R1_2: bv64; - var R1_3: bv64; - var R1_4: bv64; - var R1_5: bv64; $main$__0__$BKOmkvhNSN~7Fh58nX3c2Q: - R0_3, Gamma_R0_3 := 69660bv64, true; + assume {:captureState "$main$__0__$BKOmkvhNSN~7Fh58nX3c2Q"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 28bv64), Gamma_R0; call rely(); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(mem, R0_3)), (gamma_load32(Gamma_mem, R0_3) || L(mem, R0_3)); - R0_5, Gamma_R0_5 := 69652bv64, true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_2[32:0]), gamma_store32(Gamma_mem, R0_5, Gamma_R1_2); - R0_7, Gamma_R0_7 := 69652bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1832$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, R0_7) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_7, 0bv32), gamma_store32(Gamma_mem, R0_7, true); - R0_9, Gamma_R0_9 := 69652bv64, true; + assert (L(mem, R0) ==> true); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assume {:captureState "1844$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R1_3, Gamma_R1_3 := zero_extend32_32(memory_load32_le(mem, R0_9)), (gamma_load32(Gamma_mem, R0_9) || L(mem, R0_9)); - R0_11, Gamma_R0_11 := 69656bv64, true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, R0_11) ==> Gamma_R1_3); - mem, Gamma_mem := memory_store32_le(mem, R0_11, R1_3[32:0]), gamma_store32(Gamma_mem, R0_11, Gamma_R1_3); - R0_13, Gamma_R0_13 := 69660bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1868$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 28bv64), Gamma_R0; call rely(); - R1_4, Gamma_R1_4 := zero_extend32_32(memory_load32_le(mem, R0_13)), (gamma_load32(Gamma_mem, R0_13) || L(mem, R0_13)); - R0_15, Gamma_R0_15 := 69652bv64, true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - assert (L(mem, R0_15) ==> Gamma_R1_4); - mem, Gamma_mem := memory_store32_le(mem, R0_15, R1_4[32:0]), gamma_store32(Gamma_mem, R0_15, Gamma_R1_4); - R0_17, Gamma_R0_17 := 69652bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1892$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R1_5, Gamma_R1_5 := zero_extend32_32(memory_load32_le(mem, R0_17)), (gamma_load32(Gamma_mem, R0_17) || L(mem, R0_17)); - R0_19, Gamma_R0_19 := 69656bv64, true; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - assert (L(mem, R0_19) ==> Gamma_R1_5); - mem, Gamma_mem := memory_store32_le(mem, R0_19, R1_5[32:0]), gamma_store32(Gamma_mem, R0_19, Gamma_R1_5); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1916$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_5; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign/gcc_O2/basicassign.expected b/src/test/incorrect/basicassign/gcc_O2/basicassign.expected index 54eedf6a0..d330626d5 100644 --- a/src/test/incorrect/basicassign/gcc_O2/basicassign.expected +++ b/src/test/incorrect/basicassign/gcc_O2/basicassign.expected @@ -1,4 +1,10 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69652bv64); @@ -6,30 +12,17 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69660bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +33,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +42,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -82,44 +68,44 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R2_3: bool; - var R2_3: bv64; + var #1: bv64; + var Gamma_#1: bool; lmain: + assume {:captureState "lmain"} true; + R2, Gamma_R2 := 69632bv64, true; + R1, Gamma_R1 := bvadd64(R2, 20bv64), Gamma_R2; + R0, Gamma_R0 := 0bv64, true; call rely(); - R2_3, Gamma_R2_3 := zero_extend32_32(memory_load32_le(mem, 69652bv64)), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); + R2, Gamma_R2 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 20bv64)) || L(mem, bvadd64(R2, 20bv64))); + #1, Gamma_#1 := bvadd64(R1, 4bv64), Gamma_R1; call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store32_le(mem, 69656bv64, R2_3[32:0]), gamma_store32(Gamma_mem, 69656bv64, Gamma_R2_3); + assert (L(mem, #1) ==> Gamma_R2); + mem, Gamma_mem := memory_store32_le(mem, #1, R2[32:0]), gamma_store32(Gamma_mem, #1, Gamma_R2); + assume {:captureState "%000001c9"} true; call rely(); - assert (L(mem, 69660bv64) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store32_le(mem, 69660bv64, R2_3[32:0]), gamma_store32(Gamma_mem, 69660bv64, Gamma_R2_3); + assert (L(mem, bvadd64(#1, 4bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(#1, 4bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(#1, 4bv64), Gamma_R2); + assume {:captureState "%000001cf"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69652bv64, R2_3; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, Gamma_R2_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign/gcc_O2/basicassign_gtirb.expected b/src/test/incorrect/basicassign/gcc_O2/basicassign_gtirb.expected index 1a2a419af..48dec0790 100644 --- a/src/test/incorrect/basicassign/gcc_O2/basicassign_gtirb.expected +++ b/src/test/incorrect/basicassign/gcc_O2/basicassign_gtirb.expected @@ -1,4 +1,10 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69652bv64); @@ -6,30 +12,17 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69660bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,12 +33,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -53,10 +42,7 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -82,47 +68,44 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Cse0__5$1$4_1: bv64; - var Gamma_Cse0__5$1$4_1: bool; - var Gamma_R2_3: bool; - var R2_3: bv64; + var Cse0__5$1$4: bv64; + var Gamma_Cse0__5$1$4: bool; $main$__0__$10UzS393SWKTYt~mTNe_uw: + assume {:captureState "$main$__0__$10UzS393SWKTYt~mTNe_uw"} true; + R2, Gamma_R2 := 69632bv64, true; + R1, Gamma_R1 := bvadd64(R2, 20bv64), Gamma_R2; + R0, Gamma_R0 := 0bv64, true; call rely(); - R2_3, Gamma_R2_3 := zero_extend32_32(memory_load32_le(mem, 69652bv64)), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - Cse0__5$1$4_1, Gamma_Cse0__5$1$4_1 := 69656bv64, true; + R2, Gamma_R2 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 20bv64)) || L(mem, bvadd64(R2, 20bv64))); + Cse0__5$1$4, Gamma_Cse0__5$1$4 := bvadd64(R1, 4bv64), Gamma_R1; call rely(); - assert (L(mem, Cse0__5$1$4_1) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store32_le(mem, Cse0__5$1$4_1, R2_3[32:0]), gamma_store32(Gamma_mem, Cse0__5$1$4_1, Gamma_R2_3); + assert (L(mem, Cse0__5$1$4) ==> Gamma_R2); + mem, Gamma_mem := memory_store32_le(mem, Cse0__5$1$4, R2[32:0]), gamma_store32(Gamma_mem, Cse0__5$1$4, Gamma_R2); + assume {:captureState "1552$1"} true; call rely(); - assert (L(mem, bvadd64(Cse0__5$1$4_1, 4bv64)) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store32_le(mem, bvadd64(Cse0__5$1$4_1, 4bv64), R2_3[32:0]), gamma_store32(Gamma_mem, bvadd64(Cse0__5$1$4_1, 4bv64), Gamma_R2_3); + assert (L(mem, bvadd64(Cse0__5$1$4, 4bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(Cse0__5$1$4, 4bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(Cse0__5$1$4, 4bv64), Gamma_R2); + assume {:captureState "1552$2"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69652bv64, R2_3; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, Gamma_R2_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign/gcc_pic/basicassign.expected b/src/test/incorrect/basicassign/gcc_pic/basicassign.expected index 557f24c5b..e58a0dbe9 100644 --- a/src/test/incorrect/basicassign/gcc_pic/basicassign.expected +++ b/src/test/incorrect/basicassign/gcc_pic/basicassign.expected @@ -1,4 +1,8 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); @@ -6,20 +10,11 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +24,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,12 +35,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,17 +44,14 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 2012bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2013bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2014bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2015bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 2012bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69656bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -89,107 +73,90 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 2012bv64) == 1bv8); - free requires (memory_load8_le(mem, 2013bv64) == 0bv8); - free requires (memory_load8_le(mem, 2014bv64) == 2bv8); - free requires (memory_load8_le(mem, 2015bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69660bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 2012bv64) == 131073bv32); + free requires (memory_load64_le(mem, 68992bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69000bv64) == 1792bv64); free requires (memory_load64_le(mem, 69584bv64) == 69656bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1792bv64); - free requires (memory_load64_le(mem, 68992bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 2012bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2013bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2014bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2015bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69660bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 2012bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69656bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_11: bool; - var Gamma_R0_13: bool; - var Gamma_R0_15: bool; - var Gamma_R0_17: bool; - var Gamma_R0_19: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_9: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var R0_11: bv64; - var R0_13: bv64; - var R0_15: bv64; - var R0_17: bv64; - var R0_19: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_9: bv64; - var R1_2: bv32; - var R1_3: bv32; - var R1_4: bv32; - var R1_5: bv64; lmain: + assume {:captureState "lmain"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R1_2, Gamma_R1_2 := memory_load32_le(mem, R0_3), (gamma_load32(Gamma_mem, R0_3) || L(mem, R0_3)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_2), gamma_store32(Gamma_mem, R0_5, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000343"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_7) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_7, 0bv32), gamma_store32(Gamma_mem, R0_7, true); + assert (L(mem, R0) ==> true); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assume {:captureState "%00000356"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_9, Gamma_R0_9 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R1_3, Gamma_R1_3 := memory_load32_le(mem, R0_9), (gamma_load32(Gamma_mem, R0_9) || L(mem, R0_9)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_11, Gamma_R0_11 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - assert (L(mem, R0_11) ==> Gamma_R1_3); - mem, Gamma_mem := memory_store32_le(mem, R0_11, R1_3), gamma_store32(Gamma_mem, R0_11, Gamma_R1_3); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000037d"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_13, Gamma_R0_13 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R1_4, Gamma_R1_4 := memory_load32_le(mem, R0_13), (gamma_load32(Gamma_mem, R0_13) || L(mem, R0_13)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_15, Gamma_R0_15 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_15) ==> Gamma_R1_4); - mem, Gamma_mem := memory_store32_le(mem, R0_15, R1_4), gamma_store32(Gamma_mem, R0_15, Gamma_R1_4); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003a4"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_17, Gamma_R0_17 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R1_5, Gamma_R1_5 := zero_extend32_32(memory_load32_le(mem, R0_17)), (gamma_load32(Gamma_mem, R0_17) || L(mem, R0_17)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_19, Gamma_R0_19 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - assert (L(mem, R0_19) ==> Gamma_R1_5); - mem, Gamma_mem := memory_store32_le(mem, R0_19, R1_5[32:0]), gamma_store32(Gamma_mem, R0_19, Gamma_R1_5); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003cb"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_5; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign/gcc_pic/basicassign_gtirb.expected b/src/test/incorrect/basicassign/gcc_pic/basicassign_gtirb.expected index af4f512d5..79aaba0e7 100644 --- a/src/test/incorrect/basicassign/gcc_pic/basicassign_gtirb.expected +++ b/src/test/incorrect/basicassign/gcc_pic/basicassign_gtirb.expected @@ -1,4 +1,8 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); @@ -6,20 +10,11 @@ const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -29,11 +24,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -44,12 +35,8 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); @@ -57,17 +44,14 @@ procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); - free ensures (memory_load8_le(mem, 2012bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2013bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2014bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2015bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load32_le(mem, 2012bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69656bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; @@ -89,107 +73,90 @@ implementation {:extern} rely_reflexive() procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_mem, R0, R1, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 2012bv64) == 1bv8); - free requires (memory_load8_le(mem, 2013bv64) == 0bv8); - free requires (memory_load8_le(mem, 2014bv64) == 2bv8); - free requires (memory_load8_le(mem, 2015bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69660bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 2012bv64) == 131073bv32); + free requires (memory_load64_le(mem, 68992bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69000bv64) == 1792bv64); free requires (memory_load64_le(mem, 69584bv64) == 69656bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1792bv64); - free requires (memory_load64_le(mem, 68992bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 2012bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2013bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2014bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2015bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69660bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (memory_load32_le(mem, 2012bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69584bv64) == 69656bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1792bv64); - free ensures (memory_load64_le(mem, 68992bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69660bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R1_in: bv64, Gamma_R1_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool) +implementation main() { - var Gamma_R0_11: bool; - var Gamma_R0_13: bool; - var Gamma_R0_15: bool; - var Gamma_R0_17: bool; - var Gamma_R0_19: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_9: bool; - var Gamma_R1_2: bool; - var Gamma_R1_3: bool; - var Gamma_R1_4: bool; - var Gamma_R1_5: bool; - var R0_11: bv64; - var R0_13: bv64; - var R0_15: bv64; - var R0_17: bv64; - var R0_19: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_9: bv64; - var R1_2: bv64; - var R1_3: bv64; - var R1_4: bv64; - var R1_5: bv64; $main$__0__$yYC26iBgTbWc565tG_Ztxg: + assume {:captureState "$main$__0__$yYC26iBgTbWc565tG_Ztxg"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(mem, R0_3)), (gamma_load32(Gamma_mem, R0_3) || L(mem, R0_3)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_2[32:0]), gamma_store32(Gamma_mem, R0_5, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1896$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_7) ==> true); - mem, Gamma_mem := memory_store32_le(mem, R0_7, 0bv32), gamma_store32(Gamma_mem, R0_7, true); + assert (L(mem, R0) ==> true); + mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assume {:captureState "1908$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_9, Gamma_R0_9 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R1_3, Gamma_R1_3 := zero_extend32_32(memory_load32_le(mem, R0_9)), (gamma_load32(Gamma_mem, R0_9) || L(mem, R0_9)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_11, Gamma_R0_11 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - assert (L(mem, R0_11) ==> Gamma_R1_3); - mem, Gamma_mem := memory_store32_le(mem, R0_11, R1_3[32:0]), gamma_store32(Gamma_mem, R0_11, Gamma_R1_3); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1932$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_13, Gamma_R0_13 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R1_4, Gamma_R1_4 := zero_extend32_32(memory_load32_le(mem, R0_13)), (gamma_load32(Gamma_mem, R0_13) || L(mem, R0_13)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_15, Gamma_R0_15 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - assert (L(mem, R0_15) ==> Gamma_R1_4); - mem, Gamma_mem := memory_store32_le(mem, R0_15, R1_4[32:0]), gamma_store32(Gamma_mem, R0_15, Gamma_R1_4); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1956$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_17, Gamma_R0_17 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R1_5, Gamma_R1_5 := zero_extend32_32(memory_load32_le(mem, R0_17)), (gamma_load32(Gamma_mem, R0_17) || L(mem, R0_17)); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_19, Gamma_R0_19 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); call rely(); - assert (L(mem, R0_19) ==> Gamma_R1_5); - mem, Gamma_mem := memory_store32_le(mem, R0_19, R1_5[32:0]), gamma_store32(Gamma_mem, R0_19, Gamma_R1_5); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1980$0"} true; + R0, Gamma_R0 := 0bv64, true; goto main_basil_return; main_basil_return: - R0_out, R1_out := 0bv64, R1_5; - Gamma_R0_out, Gamma_R1_out := true, Gamma_R1_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign1/clang/basicassign1.expected b/src/test/incorrect/basicassign1/clang/basicassign1.expected index 0d8f48e88..248887914 100644 --- a/src/test/incorrect/basicassign1/clang/basicassign1.expected +++ b/src/test/incorrect/basicassign1/clang/basicassign1.expected @@ -1,33 +1,30 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,23 +35,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -62,8 +52,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -76,57 +66,55 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1892bv64) == 1bv8); - free requires (memory_load8_le(mem, 1893bv64) == 0bv8); - free requires (memory_load8_le(mem, 1894bv64) == 2bv8); - free requires (memory_load8_le(mem, 1895bv64) == 0bv8); + free requires (memory_load32_le(mem, 1892bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_1: bool; - var R10_1: bv64; - var R8_2: bv32; - var R8_3: bv64; - var R9_1: bv32; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R9_1, Gamma_R9_1 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R9_1), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R9_1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R9[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R9); + assume {:captureState "%000002fe"} true; + R0, Gamma_R0 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%0000030a"} true; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R10_1); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R10_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R10_1); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R10); + assume {:captureState "%0000031e"} true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R8_2), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R8_2); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%0000032d"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%0000033c"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign1/clang/basicassign1_gtirb.expected b/src/test/incorrect/basicassign1/clang/basicassign1_gtirb.expected index b9e970ece..faf8668f2 100644 --- a/src/test/incorrect/basicassign1/clang/basicassign1_gtirb.expected +++ b/src/test/incorrect/basicassign1/clang/basicassign1_gtirb.expected @@ -1,33 +1,30 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,23 +35,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -62,8 +52,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -76,57 +66,55 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1892bv64) == 1bv8); - free requires (memory_load8_le(mem, 1893bv64) == 0bv8); - free requires (memory_load8_le(mem, 1894bv64) == 2bv8); - free requires (memory_load8_le(mem, 1895bv64) == 0bv8); + free requires (memory_load32_le(mem, 1892bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_1: bool; - var R10_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R9_1: bv64; $main$__0__$DfHVfCMXSoudSko_BS89Jw: + assume {:captureState "$main$__0__$DfHVfCMXSoudSko_BS89Jw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R9_1, Gamma_R9_1 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R9_1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R9_1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R9[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R9); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1832$0"} true; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R10_1); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R10_1[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R10_1); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R10); + assume {:captureState "1844$0"} true; call rely(); - R8_2, Gamma_R8_2 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R8_2[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R8_2); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1852$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "1860$0"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign1/clang_O2/basicassign1.expected b/src/test/incorrect/basicassign1/clang_O2/basicassign1.expected index 29ab8c1bf..646c9e583 100644 --- a/src/test/incorrect/basicassign1/clang_O2/basicassign1.expected +++ b/src/test/incorrect/basicassign1/clang_O2/basicassign1.expected @@ -1,31 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,23 +29,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -60,8 +46,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -74,41 +60,37 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var R8_3: bv64; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%000002de"} true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign1/clang_O2/basicassign1_gtirb.expected b/src/test/incorrect/basicassign1/clang_O2/basicassign1_gtirb.expected index 4d2dcbcce..82b0afd4c 100644 --- a/src/test/incorrect/basicassign1/clang_O2/basicassign1_gtirb.expected +++ b/src/test/incorrect/basicassign1/clang_O2/basicassign1_gtirb.expected @@ -1,31 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,23 +29,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -60,8 +46,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -74,41 +60,37 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var R8_3: bv64; $main$__0__$Od2M3mwNQ0~eUkXl2xVFHw: + assume {:captureState "$main$__0__$Od2M3mwNQ0~eUkXl2xVFHw"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store32_le(mem, 69688bv64, R8_3[32:0]), gamma_store32(Gamma_mem, 69688bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "1828$0"} true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign1/clang_pic/basicassign1.expected b/src/test/incorrect/basicassign1/clang_pic/basicassign1.expected index cada793b0..4764ea3d6 100644 --- a/src/test/incorrect/basicassign1/clang_pic/basicassign1.expected +++ b/src/test/incorrect/basicassign1/clang_pic/basicassign1.expected @@ -1,23 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +28,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,34 +39,27 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -82,69 +72,63 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R9_1: bool; - var Gamma_R9_3: bool; - var R10_1: bv64; - var R8_2: bv64; - var R8_3: bv32; - var R8_4: bv64; - var R9_1: bv32; - var R9_3: bv64; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - R9_1, Gamma_R9_1 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R9_1), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R9_1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R9[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R9); + assume {:captureState "%0000030d"} true; + R0, Gamma_R0 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000319"} true; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); call rely(); - assert (L(mem, R9_3) ==> Gamma_R10_1); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R10_1[32:0]), gamma_store32(Gamma_mem, R9_3, Gamma_R10_1); + assert (L(mem, R9) ==> Gamma_R10); + mem, Gamma_mem := memory_store32_le(mem, R9, R10[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R10); + assume {:captureState "%00000334"} true; call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R8_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R8_3); - R8_4, Gamma_R8_4 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000343"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R8_4[32:0]), gamma_store32(Gamma_mem, R9_3, Gamma_R8_4); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000352"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_4, R9_3; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_4, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign1/clang_pic/basicassign1_gtirb.expected b/src/test/incorrect/basicassign1/clang_pic/basicassign1_gtirb.expected index f1f986a0b..2afdf2baf 100644 --- a/src/test/incorrect/basicassign1/clang_pic/basicassign1_gtirb.expected +++ b/src/test/incorrect/basicassign1/clang_pic/basicassign1_gtirb.expected @@ -1,23 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +28,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,34 +39,27 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -82,69 +72,63 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R9_1: bool; - var Gamma_R9_3: bool; - var R10_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R8_4: bv64; - var R9_1: bv64; - var R9_3: bv64; $main$__0__$_~KgWfivQ2SPbqUNX0Vjkg: + assume {:captureState "$main$__0__$_~KgWfivQ2SPbqUNX0Vjkg"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - R9_1, Gamma_R9_1 := zero_extend32_32(memory_load32_le(mem, R8_2)), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R9_1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R9_1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R10_1, Gamma_R10_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R9[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R9); + assume {:captureState "1892$0"} true; + R0, Gamma_R0 := 0bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1900$0"} true; + R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); call rely(); - assert (L(mem, R9_3) ==> Gamma_R10_1); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R10_1[32:0]), gamma_store32(Gamma_mem, R9_3, Gamma_R10_1); + assert (L(mem, R9) ==> Gamma_R10); + mem, Gamma_mem := memory_store32_le(mem, R9, R10[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R10); + assume {:captureState "1916$0"} true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, R8_2)), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R8_3[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R8_3); - R8_4, Gamma_R8_4 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "1924$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store32_le(mem, R9_3, R8_4[32:0]), gamma_store32(Gamma_mem, R9_3, Gamma_R8_4); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1932$0"} true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_4, R9_3; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_4, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign1/gcc/basicassign1.expected b/src/test/incorrect/basicassign1/gcc/basicassign1.expected index 035f58763..d9baf8698 100644 --- a/src/test/incorrect/basicassign1/gcc/basicassign1.expected +++ b/src/test/incorrect/basicassign1/gcc/basicassign1.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,23 +31,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -62,8 +48,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -76,57 +62,61 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1916bv64) == 1bv8); - free requires (memory_load8_le(mem, 1917bv64) == 0bv8); - free requires (memory_load8_le(mem, 1918bv64) == 2bv8); - free requires (memory_load8_le(mem, 1919bv64) == 0bv8); + free requires (memory_load32_le(mem, 1916bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var R0_3: bv32; - var R0_8: bv32; - var R1_1: bv32; - var R1_2: bv64; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, 69656bv64), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R1_1, Gamma_R1_1 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000031c"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000323"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_1), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000033d"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_8, Gamma_R0_8 := memory_load32_le(mem, 69656bv64), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_8), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_8); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000357"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_2[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000371"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign1/gcc/basicassign1_gtirb.expected b/src/test/incorrect/basicassign1/gcc/basicassign1_gtirb.expected index 4970cd7a0..3e998dfcb 100644 --- a/src/test/incorrect/basicassign1/gcc/basicassign1_gtirb.expected +++ b/src/test/incorrect/basicassign1/gcc/basicassign1_gtirb.expected @@ -1,33 +1,26 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -38,23 +31,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -62,8 +48,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -76,69 +62,61 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1916bv64) == 1bv8); - free requires (memory_load8_le(mem, 1917bv64) == 0bv8); - free requires (memory_load8_le(mem, 1918bv64) == 2bv8); - free requires (memory_load8_le(mem, 1919bv64) == 0bv8); + free requires (memory_load32_le(mem, 1916bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var R0_10: bv64; - var R0_2: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_8: bv64; - var R1_1: bv64; - var R1_2: bv64; $main$__0__$nlp0Z6HpSoKsMKUhBvTrsQ: - R0_2, Gamma_R0_2 := 69656bv64, true; + assume {:captureState "$main$__0__$nlp0Z6HpSoKsMKUhBvTrsQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := zero_extend32_32(memory_load32_le(mem, R0_2)), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_3[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R0_5, Gamma_R0_5 := 69652bv64, true; - R1_1, Gamma_R1_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1828$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1832$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_1[32:0]), gamma_store32(Gamma_mem, R0_5, Gamma_R1_1); - R0_7, Gamma_R0_7 := 69656bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1848$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_8, Gamma_R0_8 := zero_extend32_32(memory_load32_le(mem, R0_7)), (gamma_load32(Gamma_mem, R0_7) || L(mem, R0_7)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_8); - R0_10, Gamma_R0_10 := 69652bv64, true; - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1864$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R0_10) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, R0_10, R1_2[32:0]), gamma_store32(Gamma_mem, R0_10, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1880$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign1/gcc_O2/basicassign1.expected b/src/test/incorrect/basicassign1/gcc_O2/basicassign1.expected index f7f6488cb..114827622 100644 --- a/src/test/incorrect/basicassign1/gcc_O2/basicassign1.expected +++ b/src/test/incorrect/basicassign1/gcc_O2/basicassign1.expected @@ -1,31 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,23 +29,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -60,8 +46,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -74,41 +60,37 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R2_3: bool; - var R2_3: bv64; lmain: + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R0, Gamma_R0 := 0bv64, true; call rely(); - R2_3, Gamma_R2_3 := zero_extend32_32(memory_load32_le(mem, 69656bv64)), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); + R2, Gamma_R2 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 4bv64)) || L(mem, bvadd64(R2, 4bv64))); call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R2_3[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R2_3); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); + assume {:captureState "%000001c5"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, R2_3; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, Gamma_R2_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign1/gcc_O2/basicassign1_gtirb.expected b/src/test/incorrect/basicassign1/gcc_O2/basicassign1_gtirb.expected index 6ef601020..391a905c7 100644 --- a/src/test/incorrect/basicassign1/gcc_O2/basicassign1_gtirb.expected +++ b/src/test/incorrect/basicassign1/gcc_O2/basicassign1_gtirb.expected @@ -1,31 +1,24 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,23 +29,16 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -60,8 +46,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -74,44 +60,37 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var R2_2: bv64; - var R2_3: bv64; $main$__0__$_PNx6V7gRVGINL2khXZ6vg: - R2_2, Gamma_R2_2 := 69652bv64, true; + assume {:captureState "$main$__0__$_PNx6V7gRVGINL2khXZ6vg"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; + R0, Gamma_R0 := 0bv64, true; call rely(); - R2_3, Gamma_R2_3 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2_2, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R2_2, 4bv64)) || L(mem, bvadd64(R2_2, 4bv64))); + R2, Gamma_R2 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 4bv64)) || L(mem, bvadd64(R2, 4bv64))); call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R2_3[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R2_3); + assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); + assume {:captureState "1552$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, R2_3; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, Gamma_R2_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign1/gcc_pic/basicassign1.expected b/src/test/incorrect/basicassign1/gcc_pic/basicassign1.expected index 4f8bcd044..13d8861f3 100644 --- a/src/test/incorrect/basicassign1/gcc_pic/basicassign1.expected +++ b/src/test/incorrect/basicassign1/gcc_pic/basicassign1.expected @@ -1,23 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +24,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,34 +35,27 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -82,77 +68,69 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1980bv64) == 1bv8); - free requires (memory_load8_le(mem, 1981bv64) == 0bv8); - free requires (memory_load8_le(mem, 1982bv64) == 2bv8); - free requires (memory_load8_le(mem, 1983bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1980bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var R0_10: bv64; - var R0_2: bv64; - var R0_3: bv32; - var R0_5: bv64; - var R0_7: bv64; - var R0_8: bv32; - var R1_1: bv32; - var R1_2: bv64; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load32_le(mem, R0_2), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_3), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000031d"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000324"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - R1_1, Gamma_R1_1 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_1), gamma_store32(Gamma_mem, R0_5, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000033f"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_8, Gamma_R0_8 := memory_load32_le(mem, R0_7), (gamma_load32(Gamma_mem, R0_7) || L(mem, R0_7)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_8), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_8); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000035a"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_10, Gamma_R0_10 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R0_10) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, R0_10, R1_2[32:0]), gamma_store32(Gamma_mem, R0_10, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000375"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign1/gcc_pic/basicassign1_gtirb.expected b/src/test/incorrect/basicassign1/gcc_pic/basicassign1_gtirb.expected index 5c934321f..207860a9c 100644 --- a/src/test/incorrect/basicassign1/gcc_pic/basicassign1_gtirb.expected +++ b/src/test/incorrect/basicassign1/gcc_pic/basicassign1_gtirb.expected @@ -1,23 +1,20 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -27,11 +24,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -42,34 +35,27 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -82,77 +68,69 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1980bv64) == 1bv8); - free requires (memory_load8_le(mem, 1981bv64) == 0bv8); - free requires (memory_load8_le(mem, 1982bv64) == 2bv8); - free requires (memory_load8_le(mem, 1983bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1980bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69652bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69656bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69652bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69656bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var R0_10: bv64; - var R0_2: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_8: bv64; - var R1_1: bv64; - var R1_2: bv64; $main$__0__$A8~XTH6JTGm30lc5MnGYaQ: + assume {:captureState "$main$__0__$A8~XTH6JTGm30lc5MnGYaQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_3, Gamma_R0_3 := zero_extend32_32(memory_load32_le(mem, R0_2)), (gamma_load32(Gamma_mem, R0_2) || L(mem, R0_2)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_3[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1892$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1896$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - R1_1, Gamma_R1_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, R0_5, R1_1[32:0]), gamma_store32(Gamma_mem, R0_5, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1912$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_8, Gamma_R0_8 := zero_extend32_32(memory_load32_le(mem, R0_7)), (gamma_load32(Gamma_mem, R0_7) || L(mem, R0_7)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_8); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1928$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_10, Gamma_R0_10 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - R1_2, Gamma_R1_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R0_10) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store32_le(mem, R0_10, R1_2[32:0]), gamma_store32(Gamma_mem, R0_10, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1944$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign2/clang/basicassign2.expected b/src/test/incorrect/basicassign2/clang/basicassign2.expected index 024996be5..df488c4d1 100644 --- a/src/test/incorrect/basicassign2/clang/basicassign2.expected +++ b/src/test/incorrect/basicassign2/clang/basicassign2.expected @@ -1,57 +1,51 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69696bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -59,8 +53,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -73,57 +67,55 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1892bv64) == 1bv8); - free requires (memory_load8_le(mem, 1893bv64) == 0bv8); - free requires (memory_load8_le(mem, 1894bv64) == 2bv8); - free requires (memory_load8_le(mem, 1895bv64) == 0bv8); + free requires (memory_load32_le(mem, 1892bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_1: bool; - var R10_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R9_1: bv64; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R9_1, Gamma_R9_1 := memory_load64_le(mem, 69688bv64), (gamma_load64(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R9_1), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R9_1); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R10_1, Gamma_R10_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R8, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R9), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R9); + assume {:captureState "%000002fe"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000305"} true; + R10, Gamma_R10 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69696bv64) ==> Gamma_R10_1); - mem, Gamma_mem := memory_store64_le(mem, 69696bv64, R10_1), gamma_store64(Gamma_mem, 69696bv64, Gamma_R10_1); + assert (L(mem, bvadd64(R9, 64bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 64bv64), R10), gamma_store64(Gamma_mem, bvadd64(R9, 64bv64), Gamma_R10); + assume {:captureState "%00000319"} true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69688bv64), (gamma_load64(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_2), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_2); - R8_3, Gamma_R8_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000328"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - assert (L(mem, 69696bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store64_le(mem, 69696bv64, R8_3), gamma_store64(Gamma_mem, 69696bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 64bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 64bv64), R8), gamma_store64(Gamma_mem, bvadd64(R9, 64bv64), Gamma_R8); + assume {:captureState "%00000337"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign2/clang/basicassign2_gtirb.expected b/src/test/incorrect/basicassign2/clang/basicassign2_gtirb.expected index 37241d54f..95de0c100 100644 --- a/src/test/incorrect/basicassign2/clang/basicassign2_gtirb.expected +++ b/src/test/incorrect/basicassign2/clang/basicassign2_gtirb.expected @@ -1,57 +1,51 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69696bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -59,8 +53,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -73,57 +67,55 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1892bv64) == 1bv8); - free requires (memory_load8_le(mem, 1893bv64) == 0bv8); - free requires (memory_load8_le(mem, 1894bv64) == 2bv8); - free requires (memory_load8_le(mem, 1895bv64) == 0bv8); + free requires (memory_load32_le(mem, 1892bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_1: bool; - var R10_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R9_1: bv64; $main$__0__$YYWIvImmSVCq8LWicwynYQ: + assume {:captureState "$main$__0__$YYWIvImmSVCq8LWicwynYQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R9_1, Gamma_R9_1 := memory_load64_le(mem, 69688bv64), (gamma_load64(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R9_1), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R9_1); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R10_1, Gamma_R10_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R8, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R9), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R9); + assume {:captureState "1824$0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "1828$0"} true; + R10, Gamma_R10 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69696bv64) ==> Gamma_R10_1); - mem, Gamma_mem := memory_store64_le(mem, 69696bv64, R10_1), gamma_store64(Gamma_mem, 69696bv64, Gamma_R10_1); + assert (L(mem, bvadd64(R9, 64bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 64bv64), R10), gamma_store64(Gamma_mem, bvadd64(R9, 64bv64), Gamma_R10); + assume {:captureState "1840$0"} true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69688bv64), (gamma_load64(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_2), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_2); - R8_3, Gamma_R8_3 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1848$0"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - assert (L(mem, 69696bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store64_le(mem, 69696bv64, R8_3), gamma_store64(Gamma_mem, 69696bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 64bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 64bv64), R8), gamma_store64(Gamma_mem, bvadd64(R9, 64bv64), Gamma_R8); + assume {:captureState "1856$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign2/clang_O2/basicassign2.expected b/src/test/incorrect/basicassign2/clang_O2/basicassign2.expected index fcf49f75c..55eab7986 100644 --- a/src/test/incorrect/basicassign2/clang_O2/basicassign2.expected +++ b/src/test/incorrect/basicassign2/clang_O2/basicassign2.expected @@ -1,55 +1,45 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69696bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -57,8 +47,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -71,41 +61,37 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var R8_3: bv64; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, 69688bv64), (gamma_load64(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); call rely(); - assert (L(mem, 69696bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store64_le(mem, 69696bv64, R8_3), gamma_store64(Gamma_mem, 69696bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 64bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 64bv64), R8), gamma_store64(Gamma_mem, bvadd64(R9, 64bv64), Gamma_R8); + assume {:captureState "%000002de"} true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign2/clang_O2/basicassign2_gtirb.expected b/src/test/incorrect/basicassign2/clang_O2/basicassign2_gtirb.expected index be3257a11..ce04d30cc 100644 --- a/src/test/incorrect/basicassign2/clang_O2/basicassign2_gtirb.expected +++ b/src/test/incorrect/basicassign2/clang_O2/basicassign2_gtirb.expected @@ -1,55 +1,45 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69696bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -57,8 +47,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -71,41 +61,37 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var R8_3: bv64; $main$__0__$NDJX6ve4TTG0FoXJqQLDfQ: + assume {:captureState "$main$__0__$NDJX6ve4TTG0FoXJqQLDfQ"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, 69688bv64), (gamma_load64(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); call rely(); - assert (L(mem, 69696bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store64_le(mem, 69696bv64, R8_3), gamma_store64(Gamma_mem, 69696bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 64bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 64bv64), R8), gamma_store64(Gamma_mem, bvadd64(R9, 64bv64), Gamma_R8); + assume {:captureState "1828$0"} true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign2/clang_pic/basicassign2.expected b/src/test/incorrect/basicassign2/clang_pic/basicassign2.expected index 61cb76c6d..e1615c0c2 100644 --- a/src/test/incorrect/basicassign2/clang_pic/basicassign2.expected +++ b/src/test/incorrect/basicassign2/clang_pic/basicassign2.expected @@ -1,68 +1,62 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69696bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69696bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -75,69 +69,63 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69696bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69696bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R9_1: bool; - var Gamma_R9_3: bool; - var R10_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R8_4: bv64; - var R9_1: bv64; - var R9_3: bv64; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - R9_1, Gamma_R9_1 := memory_load64_le(mem, R8_2), (gamma_load64(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R9_1), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R9_1); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R10_1, Gamma_R10_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R9, Gamma_R9 := memory_load64_le(mem, R8), (gamma_load64(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R9), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R9); + assume {:captureState "%0000030d"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000314"} true; + R10, Gamma_R10 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); call rely(); - assert (L(mem, R9_3) ==> Gamma_R10_1); - mem, Gamma_mem := memory_store64_le(mem, R9_3, R10_1), gamma_store64(Gamma_mem, R9_3, Gamma_R10_1); + assert (L(mem, R9) ==> Gamma_R10); + mem, Gamma_mem := memory_store64_le(mem, R9, R10), gamma_store64(Gamma_mem, R9, Gamma_R10); + assume {:captureState "%0000032f"} true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, R8_2), (gamma_load64(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_3), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_3); - R8_4, Gamma_R8_4 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R8, Gamma_R8 := memory_load64_le(mem, R8), (gamma_load64(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000033e"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store64_le(mem, R9_3, R8_4), gamma_store64(Gamma_mem, R9_3, Gamma_R8_4); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store64_le(mem, R9, R8), gamma_store64(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%0000034d"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_4, R9_3; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_4, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign2/clang_pic/basicassign2_gtirb.expected b/src/test/incorrect/basicassign2/clang_pic/basicassign2_gtirb.expected index 457440d8d..c17318876 100644 --- a/src/test/incorrect/basicassign2/clang_pic/basicassign2_gtirb.expected +++ b/src/test/incorrect/basicassign2/clang_pic/basicassign2_gtirb.expected @@ -1,68 +1,62 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69696bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69696bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -75,69 +69,63 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69696bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69688bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69696bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69688bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R9_1: bool; - var Gamma_R9_3: bool; - var R10_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R8_4: bv64; - var R9_1: bv64; - var R9_3: bv64; $main$__0__$BA9VRiRVRpCw4REE15gPpA: + assume {:captureState "$main$__0__$BA9VRiRVRpCw4REE15gPpA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - R9_1, Gamma_R9_1 := memory_load64_le(mem, R8_2), (gamma_load64(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R9_1), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R9_1); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R10_1, Gamma_R10_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R9, Gamma_R9 := memory_load64_le(mem, R8), (gamma_load64(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R9), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R9); + assume {:captureState "1892$0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "1896$0"} true; + R10, Gamma_R10 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); call rely(); - assert (L(mem, R9_3) ==> Gamma_R10_1); - mem, Gamma_mem := memory_store64_le(mem, R9_3, R10_1), gamma_store64(Gamma_mem, R9_3, Gamma_R10_1); + assert (L(mem, R9) ==> Gamma_R10); + mem, Gamma_mem := memory_store64_le(mem, R9, R10), gamma_store64(Gamma_mem, R9, Gamma_R10); + assume {:captureState "1912$0"} true; call rely(); - R8_3, Gamma_R8_3 := memory_load64_le(mem, R8_2), (gamma_load64(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R8_3), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R8_3); - R8_4, Gamma_R8_4 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R8, Gamma_R8 := memory_load64_le(mem, R8), (gamma_load64(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1920$0"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store64_le(mem, R9_3, R8_4), gamma_store64(Gamma_mem, R9_3, Gamma_R8_4); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store64_le(mem, R9, R8), gamma_store64(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1928$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_4, R9_3; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_4, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign2/gcc/basicassign2.expected b/src/test/incorrect/basicassign2/gcc/basicassign2.expected index f16f659bf..88af71796 100644 --- a/src/test/incorrect/basicassign2/gcc/basicassign2.expected +++ b/src/test/incorrect/basicassign2/gcc/basicassign2.expected @@ -1,57 +1,47 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69664bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -59,8 +49,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -73,57 +63,61 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1916bv64) == 1bv8); - free requires (memory_load8_le(mem, 1917bv64) == 0bv8); - free requires (memory_load8_le(mem, 1918bv64) == 2bv8); - free requires (memory_load8_le(mem, 1919bv64) == 0bv8); + free requires (memory_load32_le(mem, 1916bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var R0_3: bv64; - var R0_8: bv64; - var R1_1: bv64; - var R1_2: bv64; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69664bv64), (gamma_load64(Gamma_mem, 69664bv64) || L(mem, 69664bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_3), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R1_1, Gamma_R1_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000031c"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000323"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store64_le(mem, 69656bv64, R1_1), gamma_store64(Gamma_mem, 69656bv64, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000033d"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); - R0_8, Gamma_R0_8 := memory_load64_le(mem, 69664bv64), (gamma_load64(Gamma_mem, 69664bv64) || L(mem, 69664bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_8), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_8); - R1_2, Gamma_R1_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000357"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store64_le(mem, 69656bv64, R1_2), gamma_store64(Gamma_mem, 69656bv64, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000371"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign2/gcc/basicassign2_gtirb.expected b/src/test/incorrect/basicassign2/gcc/basicassign2_gtirb.expected index 2bb2561a7..9fe37828d 100644 --- a/src/test/incorrect/basicassign2/gcc/basicassign2_gtirb.expected +++ b/src/test/incorrect/basicassign2/gcc/basicassign2_gtirb.expected @@ -1,57 +1,47 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69664bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -59,8 +49,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -73,69 +63,61 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1916bv64) == 1bv8); - free requires (memory_load8_le(mem, 1917bv64) == 0bv8); - free requires (memory_load8_le(mem, 1918bv64) == 2bv8); - free requires (memory_load8_le(mem, 1919bv64) == 0bv8); + free requires (memory_load32_le(mem, 1916bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var R0_10: bv64; - var R0_2: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_8: bv64; - var R1_1: bv64; - var R1_2: bv64; $main$__0__$RSR08m7kSH6UIQCFKlRaqg: - R0_2, Gamma_R0_2 := 69664bv64, true; + assume {:captureState "$main$__0__$RSR08m7kSH6UIQCFKlRaqg"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, R0_2), (gamma_load64(Gamma_mem, R0_2) || L(mem, R0_2)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_3), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); - R0_5, Gamma_R0_5 := 69656bv64, true; - R1_1, Gamma_R1_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "1828$0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "1832$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store64_le(mem, R0_5, R1_1), gamma_store64(Gamma_mem, R0_5, Gamma_R1_1); - R0_7, Gamma_R0_7 := 69664bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1848$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); - R0_8, Gamma_R0_8 := memory_load64_le(mem, R0_7), (gamma_load64(Gamma_mem, R0_7) || L(mem, R0_7)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_8), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_8); - R0_10, Gamma_R0_10 := 69656bv64, true; - R1_2, Gamma_R1_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "1864$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; + R1, Gamma_R1 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - assert (L(mem, R0_10) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store64_le(mem, R0_10, R1_2), gamma_store64(Gamma_mem, R0_10, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1880$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign2/gcc_O2/basicassign2.expected b/src/test/incorrect/basicassign2/gcc_O2/basicassign2.expected index 9c7ffa048..af6252b59 100644 --- a/src/test/incorrect/basicassign2/gcc_O2/basicassign2.expected +++ b/src/test/incorrect/basicassign2/gcc_O2/basicassign2.expected @@ -1,55 +1,45 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69664bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -57,8 +47,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -71,41 +61,37 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R2_3: bool; - var R2_3: bv64; lmain: + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 24bv64), Gamma_R1; + R0, Gamma_R0 := 0bv64, true; call rely(); - R2_3, Gamma_R2_3 := memory_load64_le(mem, 69664bv64), (gamma_load64(Gamma_mem, 69664bv64) || L(mem, 69664bv64)); + R2, Gamma_R2 := memory_load64_le(mem, bvadd64(R2, 8bv64)), (gamma_load64(Gamma_mem, bvadd64(R2, 8bv64)) || L(mem, bvadd64(R2, 8bv64))); call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store64_le(mem, 69656bv64, R2_3), gamma_store64(Gamma_mem, 69656bv64, Gamma_R2_3); + assert (L(mem, bvadd64(R1, 24bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R1, 24bv64), R2), gamma_store64(Gamma_mem, bvadd64(R1, 24bv64), Gamma_R2); + assume {:captureState "%000001c5"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, R2_3; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, Gamma_R2_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign2/gcc_O2/basicassign2_gtirb.expected b/src/test/incorrect/basicassign2/gcc_O2/basicassign2_gtirb.expected index 4a4eac155..652073954 100644 --- a/src/test/incorrect/basicassign2/gcc_O2/basicassign2_gtirb.expected +++ b/src/test/incorrect/basicassign2/gcc_O2/basicassign2_gtirb.expected @@ -1,55 +1,45 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69664bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -57,8 +47,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -71,44 +61,37 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var R2_2: bv64; - var R2_3: bv64; $main$__0__$ebQhd7tnS62etDAtES6e5g: - R2_2, Gamma_R2_2 := 69656bv64, true; + assume {:captureState "$main$__0__$ebQhd7tnS62etDAtES6e5g"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 24bv64), Gamma_R1; + R0, Gamma_R0 := 0bv64, true; call rely(); - R2_3, Gamma_R2_3 := memory_load64_le(mem, bvadd64(R2_2, 8bv64)), (gamma_load64(Gamma_mem, bvadd64(R2_2, 8bv64)) || L(mem, bvadd64(R2_2, 8bv64))); + R2, Gamma_R2 := memory_load64_le(mem, bvadd64(R2, 8bv64)), (gamma_load64(Gamma_mem, bvadd64(R2, 8bv64)) || L(mem, bvadd64(R2, 8bv64))); call rely(); - assert (L(mem, 69656bv64) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store64_le(mem, 69656bv64, R2_3), gamma_store64(Gamma_mem, 69656bv64, Gamma_R2_3); + assert (L(mem, bvadd64(R1, 24bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store64_le(mem, bvadd64(R1, 24bv64), R2), gamma_store64(Gamma_mem, bvadd64(R1, 24bv64), Gamma_R2); + assume {:captureState "1552$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, R2_3; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, Gamma_R2_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign2/gcc_pic/basicassign2.expected b/src/test/incorrect/basicassign2/gcc_pic/basicassign2.expected index 5b6ffa8e6..20875ec1c 100644 --- a/src/test/incorrect/basicassign2/gcc_pic/basicassign2.expected +++ b/src/test/incorrect/basicassign2/gcc_pic/basicassign2.expected @@ -1,68 +1,58 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69664bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69664bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69664bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -75,77 +65,69 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1980bv64) == 1bv8); - free requires (memory_load8_le(mem, 1981bv64) == 0bv8); - free requires (memory_load8_le(mem, 1982bv64) == 2bv8); - free requires (memory_load8_le(mem, 1983bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69664bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1980bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69664bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69664bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69664bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var R0_10: bv64; - var R0_2: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_8: bv64; - var R1_1: bv64; - var R1_2: bv64; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, R0_2), (gamma_load64(Gamma_mem, R0_2) || L(mem, R0_2)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_3), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000031d"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000324"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - R1_1, Gamma_R1_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store64_le(mem, R0_5, R1_1), gamma_store64(Gamma_mem, R0_5, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000033f"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_8, Gamma_R0_8 := memory_load64_le(mem, R0_7), (gamma_load64(Gamma_mem, R0_7) || L(mem, R0_7)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_8), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_8); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000035a"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_10, Gamma_R0_10 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - R1_2, Gamma_R1_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - assert (L(mem, R0_10) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store64_le(mem, R0_10, R1_2), gamma_store64(Gamma_mem, R0_10, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000375"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign2/gcc_pic/basicassign2_gtirb.expected b/src/test/incorrect/basicassign2/gcc_pic/basicassign2_gtirb.expected index 0aa99fccc..cb8945060 100644 --- a/src/test/incorrect/basicassign2/gcc_pic/basicassign2_gtirb.expected +++ b/src/test/incorrect/basicassign2/gcc_pic/basicassign2_gtirb.expected @@ -1,68 +1,58 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69664bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69664bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69664bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -75,77 +65,69 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1980bv64) == 1bv8); - free requires (memory_load8_le(mem, 1981bv64) == 0bv8); - free requires (memory_load8_le(mem, 1982bv64) == 2bv8); - free requires (memory_load8_le(mem, 1983bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69664bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1980bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69664bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69664bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69664bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var R0_10: bv64; - var R0_2: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_8: bv64; - var R1_1: bv64; - var R1_2: bv64; $main$__0__$cAr~xZczTJ6UG_oTonnnNw: + assume {:captureState "$main$__0__$cAr~xZczTJ6UG_oTonnnNw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, R0_2), (gamma_load64(Gamma_mem, R0_2) || L(mem, R0_2)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_3), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), true); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "1892$0"} true; + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "1896$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - R1_1, Gamma_R1_1 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store64_le(mem, R0_5, R1_1), gamma_store64(Gamma_mem, R0_5, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1912$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_8, Gamma_R0_8 := memory_load64_le(mem, R0_7), (gamma_load64(Gamma_mem, R0_7) || L(mem, R0_7)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_8), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_8); + R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "1928$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_10, Gamma_R0_10 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - R1_2, Gamma_R1_2 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - assert (L(mem, R0_10) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store64_le(mem, R0_10, R1_2), gamma_store64(Gamma_mem, R0_10, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1944$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign3/clang/basicassign3.expected b/src/test/incorrect/basicassign3/clang/basicassign3.expected index b6c27f670..1ee2cd40f 100644 --- a/src/test/incorrect/basicassign3/clang/basicassign3.expected +++ b/src/test/incorrect/basicassign3/clang/basicassign3.expected @@ -1,12 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69681bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69682bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } @@ -19,6 +29,10 @@ function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) gammaMap[index := value] } +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) +} + function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -28,18 +42,15 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -47,8 +58,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -61,57 +72,55 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1892bv64) == 1bv8); - free requires (memory_load8_le(mem, 1893bv64) == 0bv8); - free requires (memory_load8_le(mem, 1894bv64) == 2bv8); - free requires (memory_load8_le(mem, 1895bv64) == 0bv8); + free requires (memory_load32_le(mem, 1892bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_1: bool; - var R10_1: bv64; - var R8_2: bv8; - var R8_3: bv64; - var R9_1: bv8; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R9_1, Gamma_R9_1 := memory_load8_le(mem, 69681bv64), (gamma_load8(Gamma_mem, 69681bv64) || L(mem, 69681bv64)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R9_1), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R9_1); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), true); - R10_1, Gamma_R10_1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R9, Gamma_R9 := zero_extend56_8(memory_load8_le(mem, bvadd64(R8, 49bv64))), (gamma_load8(Gamma_mem, bvadd64(R8, 49bv64)) || L(mem, bvadd64(R8, 49bv64))); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R9[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R9); + assume {:captureState "%000002fe"} true; + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "%00000305"} true; + R10, Gamma_R10 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69682bv64) ==> Gamma_R10_1); - mem, Gamma_mem := memory_store8_le(mem, 69682bv64, R10_1[8:0]), gamma_store8(Gamma_mem, 69682bv64, Gamma_R10_1); + assert (L(mem, bvadd64(R9, 50bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 50bv64), R10[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 50bv64), Gamma_R10); + assume {:captureState "%00000319"} true; call rely(); - R8_2, Gamma_R8_2 := memory_load8_le(mem, 69681bv64), (gamma_load8(Gamma_mem, 69681bv64) || L(mem, 69681bv64)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R8_2), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R8_2); - R8_3, Gamma_R8_3 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, bvadd64(R8, 49bv64))), (gamma_load8(Gamma_mem, bvadd64(R8, 49bv64)) || L(mem, bvadd64(R8, 49bv64))); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R8[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R8); + assume {:captureState "%00000328"} true; + R8, Gamma_R8 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); - assert (L(mem, 69682bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store8_le(mem, 69682bv64, R8_3[8:0]), gamma_store8(Gamma_mem, 69682bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 50bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 50bv64), R8[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 50bv64), Gamma_R8); + assume {:captureState "%00000337"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign3/clang/basicassign3_gtirb.expected b/src/test/incorrect/basicassign3/clang/basicassign3_gtirb.expected index af2d46f4d..dda4fe687 100644 --- a/src/test/incorrect/basicassign3/clang/basicassign3_gtirb.expected +++ b/src/test/incorrect/basicassign3/clang/basicassign3_gtirb.expected @@ -1,12 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69681bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69682bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } @@ -19,6 +29,10 @@ function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) gammaMap[index := value] } +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) +} + function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -28,18 +42,16 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -47,8 +59,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -61,57 +73,55 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1892bv64) == 1bv8); - free requires (memory_load8_le(mem, 1893bv64) == 0bv8); - free requires (memory_load8_le(mem, 1894bv64) == 2bv8); - free requires (memory_load8_le(mem, 1895bv64) == 0bv8); + free requires (memory_load32_le(mem, 1892bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1892bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1893bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1894bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1895bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1892bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R9_1: bool; - var R10_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R9_1: bv64; $main$__0__$MRIfZSIyTFWNRJjkc4x55g: + assume {:captureState "$main$__0__$MRIfZSIyTFWNRJjkc4x55g"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R9_1, Gamma_R9_1 := zero_extend56_8(memory_load8_le(mem, 69681bv64)), (gamma_load8(Gamma_mem, 69681bv64) || L(mem, 69681bv64)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R9_1[8:0]), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R9_1); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), true); - R10_1, Gamma_R10_1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R9, Gamma_R9 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, bvadd64(R8, 49bv64)))), (gamma_load8(Gamma_mem, bvadd64(R8, 49bv64)) || L(mem, bvadd64(R8, 49bv64))); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R9[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R9); + assume {:captureState "1824$0"} true; + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "1828$0"} true; + R10, Gamma_R10 := zero_extend32_32(zero_extend24_8(memory_load8_le(stack, bvadd64(R31, 15bv64)))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); + R9, Gamma_R9 := 69632bv64, true; call rely(); - assert (L(mem, 69682bv64) ==> Gamma_R10_1); - mem, Gamma_mem := memory_store8_le(mem, 69682bv64, R10_1[8:0]), gamma_store8(Gamma_mem, 69682bv64, Gamma_R10_1); + assert (L(mem, bvadd64(R9, 50bv64)) ==> Gamma_R10); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 50bv64), R10[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 50bv64), Gamma_R10); + assume {:captureState "1840$0"} true; call rely(); - R8_2, Gamma_R8_2 := zero_extend56_8(memory_load8_le(mem, 69681bv64)), (gamma_load8(Gamma_mem, 69681bv64) || L(mem, 69681bv64)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R8_2[8:0]), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R8_2); - R8_3, Gamma_R8_3 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R8, Gamma_R8 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, bvadd64(R8, 49bv64)))), (gamma_load8(Gamma_mem, bvadd64(R8, 49bv64)) || L(mem, bvadd64(R8, 49bv64))); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R8[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R8); + assume {:captureState "1848$0"} true; + R8, Gamma_R8 := zero_extend32_32(zero_extend24_8(memory_load8_le(stack, bvadd64(R31, 15bv64)))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); - assert (L(mem, 69682bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store8_le(mem, 69682bv64, R8_3[8:0]), gamma_store8(Gamma_mem, 69682bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 50bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 50bv64), R8[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 50bv64), Gamma_R8); + assume {:captureState "1856$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign3/clang_O2/basicassign3.expected b/src/test/incorrect/basicassign3/clang_O2/basicassign3.expected index 28391042a..900ca1cca 100644 --- a/src/test/incorrect/basicassign3/clang_O2/basicassign3.expected +++ b/src/test/incorrect/basicassign3/clang_O2/basicassign3.expected @@ -1,10 +1,16 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } @@ -17,6 +23,10 @@ function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) gammaMap[index := value] } +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) +} + function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -26,18 +36,15 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -45,8 +52,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -59,41 +66,37 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var R8_3: bv64; lmain: + assume {:captureState "lmain"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend56_8(memory_load8_le(mem, 69684bv64)), (gamma_load8(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, bvadd64(R8, 52bv64))), (gamma_load8(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store8_le(mem, 69688bv64, R8_3[8:0]), gamma_store8(Gamma_mem, 69688bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 56bv64), R8[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%000002de"} true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign3/clang_O2/basicassign3_gtirb.expected b/src/test/incorrect/basicassign3/clang_O2/basicassign3_gtirb.expected index a4a9e0465..715f96918 100644 --- a/src/test/incorrect/basicassign3/clang_O2/basicassign3_gtirb.expected +++ b/src/test/incorrect/basicassign3/clang_O2/basicassign3_gtirb.expected @@ -1,10 +1,16 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } @@ -17,6 +23,10 @@ function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) gammaMap[index := value] } +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) +} + function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -26,18 +36,16 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -45,8 +53,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -59,41 +67,37 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R8, Gamma_R9, Gamma_mem, R0, R8, R9, mem; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1856bv64) == 1bv8); - free requires (memory_load8_le(mem, 1857bv64) == 0bv8); - free requires (memory_load8_le(mem, 1858bv64) == 2bv8); - free requires (memory_load8_le(mem, 1859bv64) == 0bv8); + free requires (memory_load32_le(mem, 1856bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1856bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1857bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1858bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1859bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1856bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R8_in: bv64, Gamma_R8_in: bool, R9_in: bv64, Gamma_R9_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R8_3: bool; - var R8_3: bv64; $main$__0__$i980uv9RSgi73HJREH52Kw: + assume {:captureState "$main$__0__$i980uv9RSgi73HJREH52Kw"} true; + R8, Gamma_R8 := 69632bv64, true; + R9, Gamma_R9 := 69632bv64, true; + R0, Gamma_R0 := 0bv64, true; call rely(); - R8_3, Gamma_R8_3 := zero_extend56_8(memory_load8_le(mem, 69684bv64)), (gamma_load8(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); + R8, Gamma_R8 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, bvadd64(R8, 52bv64)))), (gamma_load8(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); call rely(); - assert (L(mem, 69688bv64) ==> Gamma_R8_3); - mem, Gamma_mem := memory_store8_le(mem, 69688bv64, R8_3[8:0]), gamma_store8(Gamma_mem, 69688bv64, Gamma_R8_3); + assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 56bv64), R8[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "1828$0"} true; goto main_basil_return; main_basil_return: - R0_out, R8_out, R9_out := 0bv64, R8_3, 69632bv64; - Gamma_R0_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R8_3, true; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign3/clang_pic/basicassign3.expected b/src/test/incorrect/basicassign3/clang_pic/basicassign3.expected index cdf27aee7..60ce354a8 100644 --- a/src/test/incorrect/basicassign3/clang_pic/basicassign3.expected +++ b/src/test/incorrect/basicassign3/clang_pic/basicassign3.expected @@ -1,12 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69681bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69682bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } @@ -23,6 +33,10 @@ function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) gammaMap[index := value] } +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) +} + function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -32,29 +46,26 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69681bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69682bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69681bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -67,69 +78,63 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69681bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69682bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69681bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69681bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69682bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69681bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R9_1: bool; - var Gamma_R9_3: bool; - var R10_1: bv64; - var R8_2: bv64; - var R8_3: bv8; - var R8_4: bv64; - var R9_1: bv8; - var R9_3: bv64; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - R9_1, Gamma_R9_1 := memory_load8_le(mem, R8_2), (gamma_load8(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R9_1), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R9_1); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), true); - R10_1, Gamma_R10_1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R9, Gamma_R9 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R9[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R9); + assume {:captureState "%0000030d"} true; + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "%00000314"} true; + R10, Gamma_R10 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); call rely(); - assert (L(mem, R9_3) ==> Gamma_R10_1); - mem, Gamma_mem := memory_store8_le(mem, R9_3, R10_1[8:0]), gamma_store8(Gamma_mem, R9_3, Gamma_R10_1); + assert (L(mem, R9) ==> Gamma_R10); + mem, Gamma_mem := memory_store8_le(mem, R9, R10[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R10); + assume {:captureState "%0000032f"} true; call rely(); - R8_3, Gamma_R8_3 := memory_load8_le(mem, R8_2), (gamma_load8(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R8_3), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R8_3); - R8_4, Gamma_R8_4 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R8[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R8); + assume {:captureState "%0000033e"} true; + R8, Gamma_R8 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store8_le(mem, R9_3, R8_4[8:0]), gamma_store8(Gamma_mem, R9_3, Gamma_R8_4); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%0000034d"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_4, R9_3; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_4, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign3/clang_pic/basicassign3_gtirb.expected b/src/test/incorrect/basicassign3/clang_pic/basicassign3_gtirb.expected index 152e468d8..c0e66711e 100644 --- a/src/test/incorrect/basicassign3/clang_pic/basicassign3_gtirb.expected +++ b/src/test/incorrect/basicassign3/clang_pic/basicassign3_gtirb.expected @@ -1,12 +1,22 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69681bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69682bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } @@ -23,6 +33,10 @@ function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) gammaMap[index := value] } +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) +} + function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -32,29 +46,27 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69681bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69682bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69681bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -67,69 +79,63 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R10, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_mem, Gamma_stack, R0, R10, R31, R8, R9, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load64_le(mem, 69584bv64) == 69681bv64); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69682bv64); + free requires (memory_load64_le(mem, 69584bv64) == 69681bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load64_le(mem, 69584bv64) == 69681bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69682bv64); + free ensures (memory_load64_le(mem, 69584bv64) == 69681bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R10_out: bv64, Gamma_R10_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R10_1: bool; - var Gamma_R8_2: bool; - var Gamma_R8_3: bool; - var Gamma_R8_4: bool; - var Gamma_R9_1: bool; - var Gamma_R9_3: bool; - var R10_1: bv64; - var R8_2: bv64; - var R8_3: bv64; - var R8_4: bv64; - var R9_1: bv64; - var R9_3: bv64; $main$__0__$3y3_IhBrScqKSl092foduA: + assume {:captureState "$main$__0__$3y3_IhBrScqKSl092foduA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69584bv64), (gamma_load64(Gamma_mem, 69584bv64) || L(mem, 69584bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); - R9_1, Gamma_R9_1 := zero_extend56_8(memory_load8_le(mem, R8_2)), (gamma_load8(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R9_1[8:0]), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R9_1); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), true); - R10_1, Gamma_R10_1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R9, Gamma_R9 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R8))), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R9[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R9); + assume {:captureState "1892$0"} true; + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "1896$0"} true; + R10, Gamma_R10 := zero_extend32_32(zero_extend24_8(memory_load8_le(stack, bvadd64(R31, 15bv64)))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); + R9, Gamma_R9 := 65536bv64, true; call rely(); - R9_3, Gamma_R9_3 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); call rely(); - assert (L(mem, R9_3) ==> Gamma_R10_1); - mem, Gamma_mem := memory_store8_le(mem, R9_3, R10_1[8:0]), gamma_store8(Gamma_mem, R9_3, Gamma_R10_1); + assert (L(mem, R9) ==> Gamma_R10); + mem, Gamma_mem := memory_store8_le(mem, R9, R10[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R10); + assume {:captureState "1912$0"} true; call rely(); - R8_3, Gamma_R8_3 := zero_extend56_8(memory_load8_le(mem, R8_2)), (gamma_load8(Gamma_mem, R8_2) || L(mem, R8_2)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R8_3[8:0]), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R8_3); - R8_4, Gamma_R8_4 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R8, Gamma_R8 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R8))), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R8[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R8); + assume {:captureState "1920$0"} true; + R8, Gamma_R8 := zero_extend32_32(zero_extend24_8(memory_load8_le(stack, bvadd64(R31, 15bv64)))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); - assert (L(mem, R9_3) ==> Gamma_R8_4); - mem, Gamma_mem := memory_store8_le(mem, R9_3, R8_4[8:0]), gamma_store8(Gamma_mem, R9_3, Gamma_R8_4); + assert (L(mem, R9) ==> Gamma_R8); + mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "1928$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R10_out, R31_out, R8_out, R9_out := 0bv64, R10_1, R31_in, R8_4, R9_3; - Gamma_R0_out, Gamma_R10_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := true, Gamma_R10_1, Gamma_R31_in, Gamma_R8_4, Gamma_R9_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign3/gcc/basicassign3.expected b/src/test/incorrect/basicassign3/gcc/basicassign3.expected index 88c06ce97..8058b3573 100644 --- a/src/test/incorrect/basicassign3/gcc/basicassign3.expected +++ b/src/test/incorrect/basicassign3/gcc/basicassign3.expected @@ -1,12 +1,18 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69650bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69649bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } @@ -19,6 +25,10 @@ function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) gammaMap[index := value] } +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) +} + function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -28,18 +38,15 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -47,8 +54,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -61,57 +68,61 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1916bv64) == 1bv8); - free requires (memory_load8_le(mem, 1917bv64) == 0bv8); - free requires (memory_load8_le(mem, 1918bv64) == 2bv8); - free requires (memory_load8_le(mem, 1919bv64) == 0bv8); + free requires (memory_load32_le(mem, 1916bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_3: bool; - var Gamma_R0_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var R0_3: bv8; - var R0_8: bv8; - var R1_1: bv8; - var R1_2: bv64; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 18bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := memory_load8_le(mem, 69650bv64), (gamma_load8(Gamma_mem, 69650bv64) || L(mem, 69650bv64)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R0_3), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), true); - R1_1, Gamma_R1_1 := memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64)), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%0000031c"} true; + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "%00000323"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 17bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); - assert (L(mem, 69649bv64) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store8_le(mem, 69649bv64, R1_1), gamma_store8(Gamma_mem, 69649bv64, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000033d"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 18bv64), Gamma_R0; call rely(); - R0_8, Gamma_R0_8 := memory_load8_le(mem, 69650bv64), (gamma_load8(Gamma_mem, 69650bv64) || L(mem, 69650bv64)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R0_8), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R0_8); - R1_2, Gamma_R1_2 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%00000357"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 17bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); - assert (L(mem, 69649bv64) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store8_le(mem, 69649bv64, R1_2[8:0]), gamma_store8(Gamma_mem, 69649bv64, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000371"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign3/gcc/basicassign3_gtirb.expected b/src/test/incorrect/basicassign3/gcc/basicassign3_gtirb.expected index 1b8e0df10..572d5b366 100644 --- a/src/test/incorrect/basicassign3/gcc/basicassign3_gtirb.expected +++ b/src/test/incorrect/basicassign3/gcc/basicassign3_gtirb.expected @@ -1,12 +1,18 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69650bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69649bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } @@ -19,6 +25,10 @@ function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) gammaMap[index := value] } +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) +} + function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -28,18 +38,16 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -47,8 +55,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -61,69 +69,61 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1916bv64) == 1bv8); - free requires (memory_load8_le(mem, 1917bv64) == 0bv8); - free requires (memory_load8_le(mem, 1918bv64) == 2bv8); - free requires (memory_load8_le(mem, 1919bv64) == 0bv8); + free requires (memory_load32_le(mem, 1916bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1916bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1917bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1918bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1919bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1916bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var R0_10: bv64; - var R0_2: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_8: bv64; - var R1_1: bv64; - var R1_2: bv64; $main$__0__$6KyTrn2fQai0rTadNoNzYA: - R0_2, Gamma_R0_2 := 69650bv64, true; + assume {:captureState "$main$__0__$6KyTrn2fQai0rTadNoNzYA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 18bv64), Gamma_R0; call rely(); - R0_3, Gamma_R0_3 := zero_extend56_8(memory_load8_le(mem, R0_2)), (gamma_load8(Gamma_mem, R0_2) || L(mem, R0_2)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R0_3[8:0]), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), true); - R0_5, Gamma_R0_5 := 69649bv64, true; - R1_1, Gamma_R1_1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R0, Gamma_R0 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R0))), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "1828$0"} true; + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "1832$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 17bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(zero_extend24_8(memory_load8_le(stack, bvadd64(R31, 15bv64)))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store8_le(mem, R0_5, R1_1[8:0]), gamma_store8(Gamma_mem, R0_5, Gamma_R1_1); - R0_7, Gamma_R0_7 := 69650bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1848$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 18bv64), Gamma_R0; call rely(); - R0_8, Gamma_R0_8 := zero_extend56_8(memory_load8_le(mem, R0_7)), (gamma_load8(Gamma_mem, R0_7) || L(mem, R0_7)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R0_8[8:0]), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R0_8); - R0_10, Gamma_R0_10 := 69649bv64, true; - R1_2, Gamma_R1_2 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R0, Gamma_R0 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R0))), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "1864$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 17bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(zero_extend24_8(memory_load8_le(stack, bvadd64(R31, 15bv64)))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); - assert (L(mem, R0_10) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store8_le(mem, R0_10, R1_2[8:0]), gamma_store8(Gamma_mem, R0_10, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1880$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign3/gcc_O2/basicassign3.expected b/src/test/incorrect/basicassign3/gcc_O2/basicassign3.expected index d9a7dd372..d14aea98f 100644 --- a/src/test/incorrect/basicassign3/gcc_O2/basicassign3.expected +++ b/src/test/incorrect/basicassign3/gcc_O2/basicassign3.expected @@ -1,10 +1,16 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69650bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69649bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } @@ -17,6 +23,10 @@ function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) gammaMap[index := value] } +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) +} + function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -26,18 +36,15 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -45,8 +52,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -59,41 +66,37 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R2_3: bool; - var R2_3: bv64; lmain: + assume {:captureState "lmain"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 17bv64), Gamma_R1; + R0, Gamma_R0 := 0bv64, true; call rely(); - R2_3, Gamma_R2_3 := zero_extend56_8(memory_load8_le(mem, 69650bv64)), (gamma_load8(Gamma_mem, 69650bv64) || L(mem, 69650bv64)); + R2, Gamma_R2 := zero_extend56_8(memory_load8_le(mem, bvadd64(R2, 1bv64))), (gamma_load8(Gamma_mem, bvadd64(R2, 1bv64)) || L(mem, bvadd64(R2, 1bv64))); call rely(); - assert (L(mem, 69649bv64) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store8_le(mem, 69649bv64, R2_3[8:0]), gamma_store8(Gamma_mem, 69649bv64, Gamma_R2_3); + assert (L(mem, bvadd64(R1, 17bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R1, 17bv64), R2[8:0]), gamma_store8(Gamma_mem, bvadd64(R1, 17bv64), Gamma_R2); + assume {:captureState "%000001c5"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, R2_3; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, Gamma_R2_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign3/gcc_O2/basicassign3_gtirb.expected b/src/test/incorrect/basicassign3/gcc_O2/basicassign3_gtirb.expected index e807a4595..3f85361a9 100644 --- a/src/test/incorrect/basicassign3/gcc_O2/basicassign3_gtirb.expected +++ b/src/test/incorrect/basicassign3/gcc_O2/basicassign3_gtirb.expected @@ -1,10 +1,16 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; var {:extern} mem: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69650bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69649bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } @@ -17,6 +23,10 @@ function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) gammaMap[index := value] } +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) +} + function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -26,18 +36,16 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); @@ -45,8 +53,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -59,44 +67,37 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool); - modifies Gamma_mem, mem; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R2, Gamma_mem, R0, R1, R2, mem; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1872bv64); free requires (memory_load64_le(mem, 69024bv64) == 1792bv64); free requires (memory_load64_le(mem, 69616bv64) == 1536bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1536bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R1_in: bv64, Gamma_R1_in: bool, R2_in: bv64, Gamma_R2_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R2_out: bv64, Gamma_R2_out: bool) +implementation main() { - var Gamma_R2_2: bool; - var Gamma_R2_3: bool; - var R2_2: bv64; - var R2_3: bv64; $main$__0__$C40bGhKMQsKtBZRFrd1r0w: - R2_2, Gamma_R2_2 := 69649bv64, true; + assume {:captureState "$main$__0__$C40bGhKMQsKtBZRFrd1r0w"} true; + R1, Gamma_R1 := 69632bv64, true; + R2, Gamma_R2 := bvadd64(R1, 17bv64), Gamma_R1; + R0, Gamma_R0 := 0bv64, true; call rely(); - R2_3, Gamma_R2_3 := zero_extend56_8(memory_load8_le(mem, bvadd64(R2_2, 1bv64))), (gamma_load8(Gamma_mem, bvadd64(R2_2, 1bv64)) || L(mem, bvadd64(R2_2, 1bv64))); + R2, Gamma_R2 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, bvadd64(R2, 1bv64)))), (gamma_load8(Gamma_mem, bvadd64(R2, 1bv64)) || L(mem, bvadd64(R2, 1bv64))); call rely(); - assert (L(mem, 69649bv64) ==> Gamma_R2_3); - mem, Gamma_mem := memory_store8_le(mem, 69649bv64, R2_3[8:0]), gamma_store8(Gamma_mem, 69649bv64, Gamma_R2_3); + assert (L(mem, bvadd64(R1, 17bv64)) ==> Gamma_R2); + mem, Gamma_mem := memory_store8_le(mem, bvadd64(R1, 17bv64), R2[8:0]), gamma_store8(Gamma_mem, bvadd64(R1, 17bv64), Gamma_R2); + assume {:captureState "1552$0"} true; goto main_basil_return; main_basil_return: - R0_out, R1_out, R2_out := 0bv64, 69632bv64, R2_3; - Gamma_R0_out, Gamma_R1_out, Gamma_R2_out := true, true, Gamma_R2_3; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign3/gcc_pic/basicassign3.expected b/src/test/incorrect/basicassign3/gcc_pic/basicassign3.expected index 37a75bdeb..be209327b 100644 --- a/src/test/incorrect/basicassign3/gcc_pic/basicassign3.expected +++ b/src/test/incorrect/basicassign3/gcc_pic/basicassign3.expected @@ -1,12 +1,18 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69650bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69649bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } @@ -23,6 +29,10 @@ function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) gammaMap[index := value] } +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) +} + function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -32,29 +42,26 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69650bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69649bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69650bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -67,77 +74,69 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1980bv64) == 1bv8); - free requires (memory_load8_le(mem, 1981bv64) == 0bv8); - free requires (memory_load8_le(mem, 1982bv64) == 2bv8); - free requires (memory_load8_le(mem, 1983bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69650bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1980bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69649bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69650bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69650bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69649bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69650bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var R0_10: bv64; - var R0_2: bv64; - var R0_3: bv8; - var R0_5: bv64; - var R0_7: bv64; - var R0_8: bv8; - var R1_1: bv8; - var R1_2: bv64; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_3, Gamma_R0_3 := memory_load8_le(mem, R0_2), (gamma_load8(Gamma_mem, R0_2) || L(mem, R0_2)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R0_3), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), true); + R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%0000031d"} true; + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "%00000324"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - R1_1, Gamma_R1_1 := memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64)), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store8_le(mem, R0_5, R1_1), gamma_store8(Gamma_mem, R0_5, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000033f"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_8, Gamma_R0_8 := memory_load8_le(mem, R0_7), (gamma_load8(Gamma_mem, R0_7) || L(mem, R0_7)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R0_8), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R0_8); + R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%0000035a"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_10, Gamma_R0_10 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - R1_2, Gamma_R1_2 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); - assert (L(mem, R0_10) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store8_le(mem, R0_10, R1_2[8:0]), gamma_store8(Gamma_mem, R0_10, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000375"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/basicassign3/gcc_pic/basicassign3_gtirb.expected b/src/test/incorrect/basicassign3/gcc_pic/basicassign3_gtirb.expected index 8ec9d45ea..f4858673c 100644 --- a/src/test/incorrect/basicassign3/gcc_pic/basicassign3_gtirb.expected +++ b/src/test/incorrect/basicassign3/gcc_pic/basicassign3_gtirb.expected @@ -1,12 +1,18 @@ +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69650bv64); const {:extern} $z_addr: bv64; axiom ($z_addr == 69649bv64); -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } @@ -23,6 +29,10 @@ function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) gammaMap[index := value] } +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { + (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) +} + function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } @@ -32,29 +42,27 @@ function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) } function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { - memory[index := value] + memory[index := value[8:0]] } -function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 24"} zero_extend24_8(bv8) returns (bv32); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69650bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69649bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69650bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -67,77 +75,69 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies Gamma_R0, Gamma_R1, Gamma_R31, Gamma_mem, Gamma_stack, R0, R1, R31, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1980bv64) == 1bv8); - free requires (memory_load8_le(mem, 1981bv64) == 0bv8); - free requires (memory_load8_le(mem, 1982bv64) == 2bv8); - free requires (memory_load8_le(mem, 1983bv64) == 0bv8); - free requires (memory_load64_le(mem, 69608bv64) == 69650bv64); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load32_le(mem, 1980bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69649bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69608bv64) == 69650bv64); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69608bv64) == 69650bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69649bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69608bv64) == 69650bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_7: bool; - var Gamma_R0_8: bool; - var Gamma_R1_1: bool; - var Gamma_R1_2: bool; - var R0_10: bv64; - var R0_2: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_7: bv64; - var R0_8: bv64; - var R1_1: bv64; - var R1_2: bv64; $main$__0__$rtcpQtj9TBywq60y1zeDfg: + assume {:captureState "$main$__0__$rtcpQtj9TBywq60y1zeDfg"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_2, Gamma_R0_2 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_3, Gamma_R0_3 := zero_extend56_8(memory_load8_le(mem, R0_2)), (gamma_load8(Gamma_mem, R0_2) || L(mem, R0_2)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R0_3[8:0]), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R0_3); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), true); + R0, Gamma_R0 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R0))), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "1892$0"} true; + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "1896$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - R1_1, Gamma_R1_1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := zero_extend32_32(zero_extend24_8(memory_load8_le(stack, bvadd64(R31, 15bv64)))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); - assert (L(mem, R0_5) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store8_le(mem, R0_5, R1_1[8:0]), gamma_store8(Gamma_mem, R0_5, Gamma_R1_1); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1912$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_7, Gamma_R0_7 := memory_load64_le(mem, 69608bv64), (gamma_load64(Gamma_mem, 69608bv64) || L(mem, 69608bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); - R0_8, Gamma_R0_8 := zero_extend56_8(memory_load8_le(mem, R0_7)), (gamma_load8(Gamma_mem, R0_7) || L(mem, R0_7)); - stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31_in, 18446744073709551615bv64), R0_8[8:0]), gamma_store8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64), Gamma_R0_8); + R0, Gamma_R0 := zero_extend32_32(zero_extend24_8(memory_load8_le(mem, R0))), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "1928$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_10, Gamma_R0_10 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); - R1_2, Gamma_R1_2 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31_in, 18446744073709551615bv64))), gamma_load8(Gamma_stack, bvadd64(R31_in, 18446744073709551615bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); + R1, Gamma_R1 := zero_extend32_32(zero_extend24_8(memory_load8_le(stack, bvadd64(R31, 15bv64)))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); - assert (L(mem, R0_10) ==> Gamma_R1_2); - mem, Gamma_mem := memory_store8_le(mem, R0_10, R1_2[8:0]), gamma_store8(Gamma_mem, R0_10, Gamma_R1_2); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1944$0"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_2, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_2, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/iflocal/clang/iflocal.expected b/src/test/incorrect/iflocal/clang/iflocal.expected index 7952630cc..b4d695d42 100644 --- a/src/test/incorrect/iflocal/clang/iflocal.expected +++ b/src/test/incorrect/iflocal/clang/iflocal.expected @@ -1,27 +1,34 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,23 +39,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -56,8 +58,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -70,73 +72,90 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R0, R31, R8, VF, ZF, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R8_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_2: bool; - var Gamma_R8_7: bool; - var R0_2: bv64; - var R8_1: bv32; - var R8_10: bv64; - var R8_2: bv32; - var R8_7: bv64; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_in); - R8_1, Gamma_R8_1 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), R8_1), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), Gamma_R8_1); - R8_2, Gamma_R8_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - assert Gamma_R8_2; + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f5"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%000002fd"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%0000030c"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000334, lmain_goto_l00000337; - lmain_goto_l00000337: - assume (!(R8_2 == 0bv32)); - R8_7, Gamma_R8_7 := 1bv64, true; + l00000337: + assume {:captureState "l00000337"} true; + R8, Gamma_R8 := 1bv64, true; goto l0000033a; - lmain_goto_l00000334: - assume (R8_2 == 0bv32); - R8_7, Gamma_R8_7 := 0bv64, true; + l00000334: + assume {:captureState "l00000334"} true; + R8, Gamma_R8 := 0bv64, true; goto l0000033a; l0000033a: - assert Gamma_R8_7; + assume {:captureState "l0000033a"} true; + assert Gamma_R8; goto l0000033a_goto_l00000342, l0000033a_goto_l00000359; - l0000033a_goto_l00000359: - assume (!(R8_7[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); - R8_10, Gamma_R8_10 := 1bv64, true; - goto l00000342; - l0000033a_goto_l00000342: - assume (R8_7[1:0] == 1bv1); - R8_10, Gamma_R8_10 := R8_7, Gamma_R8_7; + l00000359: + assume {:captureState "l00000359"} true; + goto l0000035a; + l0000035a: + assume {:captureState "l0000035a"} true; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000368"} true; goto l00000342; l00000342: - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l00000342"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000334: + assume {:captureState "lmain_goto_l00000334"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l00000334; + lmain_goto_l00000337: + assume {:captureState "lmain_goto_l00000337"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l00000337; + l0000033a_goto_l00000342: + assume {:captureState "l0000033a_goto_l00000342"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l00000342; + l0000033a_goto_l00000359: + assume {:captureState "l0000033a_goto_l00000359"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000359; main_basil_return: - R0_out, R31_out, R8_out := R0_2, R31_in, R8_10; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_2, Gamma_R31_in, Gamma_R8_10; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/iflocal/clang/iflocal_gtirb.expected b/src/test/incorrect/iflocal/clang/iflocal_gtirb.expected index c54d33daa..7296e2682 100644 --- a/src/test/incorrect/iflocal/clang/iflocal_gtirb.expected +++ b/src/test/incorrect/iflocal/clang/iflocal_gtirb.expected @@ -1,27 +1,33 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,23 +38,17 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -56,8 +56,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -70,110 +70,82 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R0, R31, R8, VF, ZF, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1896bv64) == 1bv8); - free requires (memory_load8_le(mem, 1897bv64) == 0bv8); - free requires (memory_load8_le(mem, 1898bv64) == 2bv8); - free requires (memory_load8_le(mem, 1899bv64) == 0bv8); + free requires (memory_load32_le(mem, 1896bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1896bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1897bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1898bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1899bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1896bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R31_11: bool; - var Gamma_R31_2: bool; - var Gamma_R31_7: bool; - var Gamma_R31_9: bool; - var Gamma_R8_1: bool; - var Gamma_R8_10: bool; - var Gamma_R8_11: bool; - var Gamma_R8_13: bool; - var Gamma_R8_15: bool; - var Gamma_R8_2: bool; - var Gamma_R8_4: bool; - var Gamma_R8_7: bool; - var R0_2: bv64; - var R31_11: bv64; - var R31_2: bv64; - var R31_7: bv64; - var R31_9: bv64; - var R8_1: bv64; - var R8_10: bv64; - var R8_11: bv64; - var R8_13: bv64; - var R8_15: bv64; - var R8_2: bv64; - var R8_4: bv64; - var R8_7: bv64; + var Cse0__5$1$6: bv32; + var Gamma_Cse0__5$1$6: bool; $main$__0__$dITIp_QuTySaVuiLkGLLoQ: - R31_2, Gamma_R31_2 := bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_in); - R8_1, Gamma_R8_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), R8_1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), Gamma_R8_1); - R8_2, Gamma_R8_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - assert Gamma_R8_2; + assume {:captureState "$main$__0__$dITIp_QuTySaVuiLkGLLoQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1816$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "1820$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "1828$0"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); + Cse0__5$1$6, Gamma_Cse0__5$1$6 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$1$6, Cse0__5$1$6)), Gamma_Cse0__5$1$6; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$1$6), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$1$6); + ZF, Gamma_ZF := bvcomp32(Cse0__5$1$6, 0bv32), Gamma_Cse0__5$1$6; + NF, Gamma_NF := Cse0__5$1$6[32:31], Gamma_Cse0__5$1$6; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$1$6), Gamma_Cse0__5$1$6; + assert Gamma_ZF; goto $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__0, $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__1; - $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__1: - assume (!(R8_2[32:0] == 0bv32)); - R8_4, Gamma_R8_4 := 1bv64, true; - goto $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__1_phi_$main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__3__$VzkdJ~gQQUaAj8nayCsAQg, $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__1_phi_$main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__1__$9yZxYvkWSfeMd9LhgBu42A; - $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__1_phi_$main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__1__$9yZxYvkWSfeMd9LhgBu42A: - R31_7, Gamma_R31_7 := R31_2, Gamma_R31_2; - R8_10, Gamma_R8_10 := R8_4, Gamma_R8_4; - assert Gamma_R8_10; - goto $main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__1__$9yZxYvkWSfeMd9LhgBu42A; - $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__1_phi_$main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__3__$VzkdJ~gQQUaAj8nayCsAQg: - R31_9, Gamma_R31_9 := R31_2, Gamma_R31_2; - R8_13, Gamma_R8_13 := R8_4, Gamma_R8_4; - assert Gamma_R8_13; - goto $main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__3__$VzkdJ~gQQUaAj8nayCsAQg; - $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__0: - assume (R8_2[32:0] == 0bv32); - R8_7, Gamma_R8_7 := 0bv64, true; - goto $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__0_phi_$main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__3__$VzkdJ~gQQUaAj8nayCsAQg, $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__0_phi_$main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__1__$9yZxYvkWSfeMd9LhgBu42A; - $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__0_phi_$main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__1__$9yZxYvkWSfeMd9LhgBu42A: - R31_7, Gamma_R31_7 := R31_2, Gamma_R31_2; - R8_10, Gamma_R8_10 := R8_7, Gamma_R8_7; - assert Gamma_R8_10; - goto $main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__1__$9yZxYvkWSfeMd9LhgBu42A; - $main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__1__$9yZxYvkWSfeMd9LhgBu42A: - assume (!(R8_10[1:0] == 1bv1)); - R8_11, Gamma_R8_11 := 1bv64, true; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_7, 4bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_7, 4bv64), true); - R31_11, Gamma_R31_11 := R31_7, Gamma_R31_7; - R8_15, Gamma_R8_15 := R8_11, Gamma_R8_11; - goto $main$__3__$VzkdJ~gQQUaAj8nayCsAQg; - $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__0_phi_$main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__3__$VzkdJ~gQQUaAj8nayCsAQg: - R31_9, Gamma_R31_9 := R31_2, Gamma_R31_2; - R8_13, Gamma_R8_13 := R8_7, Gamma_R8_7; - assert Gamma_R8_13; - goto $main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__3__$VzkdJ~gQQUaAj8nayCsAQg; - $main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__3__$VzkdJ~gQQUaAj8nayCsAQg: - assume (R8_13[1:0] == 1bv1); - R31_11, Gamma_R31_11 := R31_9, Gamma_R31_9; - R8_15, Gamma_R8_15 := R8_13, Gamma_R8_13; + $main$__1__$9yZxYvkWSfeMd9LhgBu42A: + assume {:captureState "$main$__1__$9yZxYvkWSfeMd9LhgBu42A"} true; + goto $main$__2__$imxUF1WxQcO7w5yQCfBNQw; + $main$__2__$imxUF1WxQcO7w5yQCfBNQw: + assume {:captureState "$main$__2__$imxUF1WxQcO7w5yQCfBNQw"} true; + R8, Gamma_R8 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "1856$0"} true; goto $main$__3__$VzkdJ~gQQUaAj8nayCsAQg; $main$__3__$VzkdJ~gQQUaAj8nayCsAQg: - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_11, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31_11, 4bv64)); + assume {:captureState "$main$__3__$VzkdJ~gQQUaAj8nayCsAQg"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__3__$VzkdJ~gQQUaAj8nayCsAQg: + assume {:captureState "$main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__3__$VzkdJ~gQQUaAj8nayCsAQg"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$VzkdJ~gQQUaAj8nayCsAQg; + $main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__1__$9yZxYvkWSfeMd9LhgBu42A: + assume {:captureState "$main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__1__$9yZxYvkWSfeMd9LhgBu42A"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$9yZxYvkWSfeMd9LhgBu42A; + $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__0: + assume {:captureState "$main$__0__$dITIp_QuTySaVuiLkGLLoQ$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__3__$VzkdJ~gQQUaAj8nayCsAQg, $main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__1__$9yZxYvkWSfeMd9LhgBu42A; + $main$__0__$dITIp_QuTySaVuiLkGLLoQ$__1: + assume {:captureState "$main$__0__$dITIp_QuTySaVuiLkGLLoQ$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__3__$VzkdJ~gQQUaAj8nayCsAQg, $main$__0__$dITIp_QuTySaVuiLkGLLoQ_goto_$main$__1__$9yZxYvkWSfeMd9LhgBu42A; main_basil_return: - R0_out, R31_out, R8_out := R0_2, bvadd64(R31_11, 16bv64), R8_15; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out := Gamma_R0_2, Gamma_R31_11, Gamma_R8_15; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/iflocal/gcc/iflocal.expected b/src/test/incorrect/iflocal/gcc/iflocal.expected index 0d865e532..f89816a93 100644 --- a/src/test/incorrect/iflocal/gcc/iflocal.expected +++ b/src/test/incorrect/iflocal/gcc/iflocal.expected @@ -1,27 +1,32 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,22 +37,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1880bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1881bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1882bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1883bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1880bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -55,8 +56,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -69,52 +70,64 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R0, R31, VF, ZF, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1880bv64) == 1bv8); - free requires (memory_load8_le(mem, 1881bv64) == 0bv8); - free requires (memory_load8_le(mem, 1882bv64) == 2bv8); - free requires (memory_load8_le(mem, 1883bv64) == 0bv8); + free requires (memory_load32_le(mem, 1880bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1880bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1881bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1882bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1883bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1880bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var R0_2: bv32; - var R0_3: bv32; + var #4: bv32; + var Gamma_#4: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - R0_2, Gamma_R0_2 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_2), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_2); - R0_3, Gamma_R0_3 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - assert Gamma_R0_3; + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002e6"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%000002f5"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000318, lmain_goto_l0000032d; - lmain_goto_l0000032d: - assume (R0_3 == 0bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - goto l00000318; - lmain_goto_l00000318: - assume (!(R0_3 == 0bv32)); + l0000032d: + assume {:captureState "l0000032d"} true; + R0, Gamma_R0 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000338"} true; goto l00000318; l00000318: + assume {:captureState "l00000318"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000318: + assume {:captureState "lmain_goto_l00000318"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000318; + lmain_goto_l0000032d: + assume {:captureState "lmain_goto_l0000032d"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l0000032d; main_basil_return: - R0_out, R31_out := 0bv64, R31_in; - Gamma_R0_out, Gamma_R31_out := true, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/iflocal/gcc/iflocal_gtirb.expected b/src/test/incorrect/iflocal/gcc/iflocal_gtirb.expected index 9f4d658f1..f9bfdc01e 100644 --- a/src/test/incorrect/iflocal/gcc/iflocal_gtirb.expected +++ b/src/test/incorrect/iflocal/gcc/iflocal_gtirb.expected @@ -1,27 +1,31 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -32,23 +36,17 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1880bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1881bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1882bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1883bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1880bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -56,8 +54,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -70,62 +68,64 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_stack, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_stack, NF, R0, R31, VF, ZF, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1880bv64) == 1bv8); - free requires (memory_load8_le(mem, 1881bv64) == 0bv8); - free requires (memory_load8_le(mem, 1882bv64) == 2bv8); - free requires (memory_load8_le(mem, 1883bv64) == 0bv8); + free requires (memory_load32_le(mem, 1880bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1880bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1881bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1882bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1883bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1880bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R31_2: bool; - var Gamma_R31_5: bool; - var R0_2: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R31_2: bv64; - var R31_5: bv64; + var Cse0__5$1$5: bv32; + var Gamma_Cse0__5$1$5: bool; $main$__0__$JHsGwNfGRCOpiUZHeubweA: - R31_2, Gamma_R31_2 := bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_2[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_2); - R0_3, Gamma_R0_3 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - assert Gamma_R0_3; + assume {:captureState "$main$__0__$JHsGwNfGRCOpiUZHeubweA"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1816$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1824$0"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + Cse0__5$1$5, Gamma_Cse0__5$1$5 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$1$5, Cse0__5$1$5)), Gamma_Cse0__5$1$5; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$1$5), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$1$5); + ZF, Gamma_ZF := bvcomp32(Cse0__5$1$5, 0bv32), Gamma_Cse0__5$1$5; + NF, Gamma_NF := Cse0__5$1$5[32:31], Gamma_Cse0__5$1$5; + assert Gamma_ZF; goto $main$__0__$JHsGwNfGRCOpiUZHeubweA_goto_$main$__2__$ISicwCLjQ0aYINQWknU4Ug, $main$__0__$JHsGwNfGRCOpiUZHeubweA_goto_$main$__1__$f08glPMzTSyyoBl6Ituc2w; - $main$__0__$JHsGwNfGRCOpiUZHeubweA_goto_$main$__1__$f08glPMzTSyyoBl6Ituc2w: - assume (R0_3[32:0] == 0bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 1bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R31_5, Gamma_R31_5 := R31_2, Gamma_R31_2; - goto $main$__2__$ISicwCLjQ0aYINQWknU4Ug; - $main$__0__$JHsGwNfGRCOpiUZHeubweA_goto_$main$__2__$ISicwCLjQ0aYINQWknU4Ug: - assume (!(R0_3[32:0] == 0bv32)); - R31_5, Gamma_R31_5 := R31_2, Gamma_R31_2; + $main$__1__$f08glPMzTSyyoBl6Ituc2w: + assume {:captureState "$main$__1__$f08glPMzTSyyoBl6Ituc2w"} true; + R0, Gamma_R0 := 1bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1844$0"} true; goto $main$__2__$ISicwCLjQ0aYINQWknU4Ug; $main$__2__$ISicwCLjQ0aYINQWknU4Ug: - R0_5, Gamma_R0_5 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_5, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31_5, 28bv64)); + assume {:captureState "$main$__2__$ISicwCLjQ0aYINQWknU4Ug"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + $main$__0__$JHsGwNfGRCOpiUZHeubweA_goto_$main$__2__$ISicwCLjQ0aYINQWknU4Ug: + assume {:captureState "$main$__0__$JHsGwNfGRCOpiUZHeubweA_goto_$main$__2__$ISicwCLjQ0aYINQWknU4Ug"} true; + assume (!(ZF == 1bv1)); + goto $main$__2__$ISicwCLjQ0aYINQWknU4Ug; + $main$__0__$JHsGwNfGRCOpiUZHeubweA_goto_$main$__1__$f08glPMzTSyyoBl6Ituc2w: + assume {:captureState "$main$__0__$JHsGwNfGRCOpiUZHeubweA_goto_$main$__1__$f08glPMzTSyyoBl6Ituc2w"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__1__$f08glPMzTSyyoBl6Ituc2w; main_basil_return: - R0_out, R31_out := R0_5, bvadd64(R31_5, 32bv64); - Gamma_R0_out, Gamma_R31_out := Gamma_R0_5, Gamma_R31_5; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/nestedifglobal/clang/nestedifglobal.expected b/src/test/incorrect/nestedifglobal/clang/nestedifglobal.expected index 3beced949..f21ee0c3b 100644 --- a/src/test/incorrect/nestedifglobal/clang/nestedifglobal.expected +++ b/src/test/incorrect/nestedifglobal/clang/nestedifglobal.expected @@ -1,31 +1,40 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,23 +45,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1976bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1977bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1978bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1979bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1976bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -60,8 +64,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -74,134 +78,200 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, R9, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1976bv64) == 1bv8); - free requires (memory_load8_le(mem, 1977bv64) == 0bv8); - free requires (memory_load8_le(mem, 1978bv64) == 2bv8); - free requires (memory_load8_le(mem, 1979bv64) == 0bv8); + free requires (memory_load32_le(mem, 1976bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1976bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1977bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1978bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1979bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1976bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R8_10: bool; - var Gamma_R8_15: bool; - var Gamma_R8_17: bool; - var Gamma_R8_2: bool; - var Gamma_R8_22: bool; - var Gamma_R8_24: bool; - var Gamma_R8_26: bool; - var Gamma_R8_7: bool; - var Gamma_R9_1: bool; - var R0_2: bv64; - var R8_10: bv32; - var R8_15: bv64; - var R8_17: bv32; - var R8_2: bv32; - var R8_22: bv64; - var R8_24: bv64; - var R8_26: bv64; - var R8_7: bv64; - var R9_1: bv64; + var #4: bv32; + var #5: bv32; + var #6: bv32; + var Gamma_#4: bool; + var Gamma_#5: bool; + var Gamma_#6: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_in); - R9_1, Gamma_R9_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000345"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000034d"} true; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R9_1); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, R9_1[32:0]), gamma_store32(Gamma_mem, 69684bv64, Gamma_R9_1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); + assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assume {:captureState "%00000361"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), true); + assume {:captureState "%00000368"} true; call rely(); - R8_2, Gamma_R8_2 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000390, lmain_goto_l00000393; - lmain_goto_l00000393: - assume (!(R8_2 == 0bv32)); - R8_7, Gamma_R8_7 := 1bv64, true; + l00000393: + assume {:captureState "l00000393"} true; + R8, Gamma_R8 := 1bv64, true; goto l00000396; - lmain_goto_l00000390: - assume (R8_2 == 0bv32); - R8_7, Gamma_R8_7 := 0bv64, true; + l00000390: + assume {:captureState "l00000390"} true; + R8, Gamma_R8 := 0bv64, true; goto l00000396; l00000396: - assert Gamma_R8_7; + assume {:captureState "l00000396"} true; + assert Gamma_R8; goto l00000396_goto_l0000039e, l00000396_goto_l0000045d; - l00000396_goto_l0000045d: - assume (!(R8_7[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); - goto l0000039e; - l00000396_goto_l0000039e: - assume (R8_7[1:0] == 1bv1); + l0000045d: + assume {:captureState "l0000045d"} true; + goto l0000045e; + l0000045e: + assume {:captureState "l0000045e"} true; + R8, Gamma_R8 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%0000046c"} true; goto l0000039e; l0000039e: + assume {:captureState "l0000039e"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_10, Gamma_R8_10 := memory_load32_le(mem, 69684bv64), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_10; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + #5, Gamma_#5 := bvadd32(R8[32:0], 4294967294bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_#5); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#5, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967295bv33))), (Gamma_R8 && Gamma_#5); + ZF, Gamma_ZF := bvcomp32(bvadd32(#5, 1bv32), 0bv32), Gamma_#5; + NF, Gamma_NF := bvadd32(#5, 1bv32)[32:31], Gamma_#5; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#5, 1bv32)), Gamma_#5; + assert Gamma_ZF; goto l0000039e_goto_l000003ce, l0000039e_goto_l000003d1; - l0000039e_goto_l000003d1: - assume (!(R8_10 == 1bv32)); - R8_15, Gamma_R8_15 := 1bv64, true; + l000003d1: + assume {:captureState "l000003d1"} true; + R8, Gamma_R8 := 1bv64, true; goto l000003d4; - l0000039e_goto_l000003ce: - assume (R8_10 == 1bv32); - R8_15, Gamma_R8_15 := 0bv64, true; + l000003ce: + assume {:captureState "l000003ce"} true; + R8, Gamma_R8 := 0bv64, true; goto l000003d4; l000003d4: - assert Gamma_R8_15; + assume {:captureState "l000003d4"} true; + assert Gamma_R8; goto l000003d4_goto_l000003dc, l000003d4_goto_l00000448; - l000003d4_goto_l00000448: - assume (!(R8_15[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 5bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); - goto l000003dc; - l000003d4_goto_l000003dc: - assume (R8_15[1:0] == 1bv1); + l00000448: + assume {:captureState "l00000448"} true; + goto l00000449; + l00000449: + assume {:captureState "l00000449"} true; + R8, Gamma_R8 := 5bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000457"} true; goto l000003dc; l000003dc: - R8_17, Gamma_R8_17 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - assert Gamma_R8_17; + assume {:captureState "l000003dc"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); + #6, Gamma_#6 := bvadd32(R8[32:0], 4294967292bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934589bv33))), (Gamma_R8 && Gamma_#6); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#6, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967293bv33))), (Gamma_R8 && Gamma_#6); + ZF, Gamma_ZF := bvcomp32(bvadd32(#6, 1bv32), 0bv32), Gamma_#6; + NF, Gamma_NF := bvadd32(#6, 1bv32)[32:31], Gamma_#6; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#6, 1bv32)), Gamma_#6; + assert Gamma_ZF; goto l000003dc_goto_l00000407, l000003dc_goto_l0000040a; - l000003dc_goto_l0000040a: - assume (!(R8_17 == 3bv32)); - R8_22, Gamma_R8_22 := 1bv64, true; + l0000040a: + assume {:captureState "l0000040a"} true; + R8, Gamma_R8 := 1bv64, true; goto l0000040d; - l000003dc_goto_l00000407: - assume (R8_17 == 3bv32); - R8_22, Gamma_R8_22 := 0bv64, true; + l00000407: + assume {:captureState "l00000407"} true; + R8, Gamma_R8 := 0bv64, true; goto l0000040d; l0000040d: - assert Gamma_R8_22; + assume {:captureState "l0000040d"} true; + assert Gamma_R8; goto l0000040d_goto_l00000415, l0000040d_goto_l0000042c; - l0000040d_goto_l0000042c: - assume (!(R8_22[1:0] == 1bv1)); + l0000042c: + assume {:captureState "l0000042c"} true; + goto l0000042d; + l0000042d: + assume {:captureState "l0000042d"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_24, Gamma_R8_24 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), R8_24[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), Gamma_R8_24); - R8_26, Gamma_R8_26 := R8_24, Gamma_R8_24; - goto l00000415; - l0000040d_goto_l00000415: - assume (R8_22[1:0] == 1bv1); - R8_26, Gamma_R8_26 := R8_22, Gamma_R8_22; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000442"} true; goto l00000415; l00000415: - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l00000415"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000390: + assume {:captureState "lmain_goto_l00000390"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l00000390; + lmain_goto_l00000393: + assume {:captureState "lmain_goto_l00000393"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l00000393; + l00000396_goto_l0000039e: + assume {:captureState "l00000396_goto_l0000039e"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l0000039e; + l00000396_goto_l0000045d: + assume {:captureState "l00000396_goto_l0000045d"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l0000045d; + l0000039e_goto_l000003ce: + assume {:captureState "l0000039e_goto_l000003ce"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l000003ce; + l0000039e_goto_l000003d1: + assume {:captureState "l0000039e_goto_l000003d1"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l000003d1; + l000003d4_goto_l000003dc: + assume {:captureState "l000003d4_goto_l000003dc"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l000003dc; + l000003d4_goto_l00000448: + assume {:captureState "l000003d4_goto_l00000448"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000448; + l000003dc_goto_l00000407: + assume {:captureState "l000003dc_goto_l00000407"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l00000407; + l000003dc_goto_l0000040a: + assume {:captureState "l000003dc_goto_l0000040a"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l0000040a; + l0000040d_goto_l00000415: + assume {:captureState "l0000040d_goto_l00000415"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l00000415; + l0000040d_goto_l0000042c: + assume {:captureState "l0000040d_goto_l0000042c"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l0000042c; main_basil_return: - R0_out, R31_out, R8_out, R9_out := R0_2, R31_in, R8_26, R9_1; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_2, Gamma_R31_in, Gamma_R8_26, Gamma_R9_1; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/nestedifglobal/clang/nestedifglobal_gtirb.expected b/src/test/incorrect/nestedifglobal/clang/nestedifglobal_gtirb.expected index dfbaf1f3b..6378df02e 100644 --- a/src/test/incorrect/nestedifglobal/clang/nestedifglobal_gtirb.expected +++ b/src/test/incorrect/nestedifglobal/clang/nestedifglobal_gtirb.expected @@ -1,31 +1,39 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,23 +44,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); @@ -60,8 +63,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -74,263 +77,178 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, R9, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 1980bv64) == 1bv8); - free requires (memory_load8_le(mem, 1981bv64) == 0bv8); - free requires (memory_load8_le(mem, 1982bv64) == 2bv8); - free requires (memory_load8_le(mem, 1983bv64) == 0bv8); + free requires (memory_load32_le(mem, 1980bv64) == 131073bv32); free requires (memory_load64_le(mem, 69064bv64) == 1808bv64); free requires (memory_load64_le(mem, 69072bv64) == 1728bv64); free requires (memory_load64_le(mem, 69592bv64) == 1812bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free ensures (memory_load8_le(mem, 1980bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1981bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1982bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1983bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1980bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69064bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69072bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R31_11: bool; - var Gamma_R31_16: bool; - var Gamma_R31_18: bool; - var Gamma_R31_2: bool; - var Gamma_R31_20: bool; - var Gamma_R31_25: bool; - var Gamma_R31_27: bool; - var Gamma_R31_29: bool; - var Gamma_R31_7: bool; - var Gamma_R31_9: bool; - var Gamma_R8_10: bool; - var Gamma_R8_12: bool; - var Gamma_R8_14: bool; - var Gamma_R8_16: bool; - var Gamma_R8_19: bool; - var Gamma_R8_2: bool; - var Gamma_R8_22: bool; - var Gamma_R8_24: bool; - var Gamma_R8_25: bool; - var Gamma_R8_27: bool; - var Gamma_R8_30: bool; - var Gamma_R8_33: bool; - var Gamma_R8_35: bool; - var Gamma_R8_36: bool; - var Gamma_R8_4: bool; - var Gamma_R8_7: bool; - var Gamma_R9_1: bool; - var Gamma_R9_10: bool; - var Gamma_R9_15: bool; - var Gamma_R9_17: bool; - var Gamma_R9_19: bool; - var Gamma_R9_24: bool; - var Gamma_R9_26: bool; - var Gamma_R9_28: bool; - var Gamma_R9_6: bool; - var Gamma_R9_8: bool; - var R0_2: bv64; - var R31_11: bv64; - var R31_16: bv64; - var R31_18: bv64; - var R31_2: bv64; - var R31_20: bv64; - var R31_25: bv64; - var R31_27: bv64; - var R31_29: bv64; - var R31_7: bv64; - var R31_9: bv64; - var R8_10: bv64; - var R8_12: bv64; - var R8_14: bv64; - var R8_16: bv64; - var R8_19: bv64; - var R8_2: bv64; - var R8_22: bv64; - var R8_24: bv64; - var R8_25: bv64; - var R8_27: bv64; - var R8_30: bv64; - var R8_33: bv64; - var R8_35: bv64; - var R8_36: bv64; - var R8_4: bv64; - var R8_7: bv64; - var R9_1: bv64; - var R9_10: bv64; - var R9_15: bv64; - var R9_17: bv64; - var R9_19: bv64; - var R9_24: bv64; - var R9_26: bv64; - var R9_28: bv64; - var R9_6: bv64; - var R9_8: bv64; + var Cse0__5$1$2: bv32; + var Cse0__5$2$8: bv32; + var Cse0__5$4$1: bv32; + var Gamma_Cse0__5$1$2: bool; + var Gamma_Cse0__5$2$8: bool; + var Gamma_Cse0__5$4$1: bool; $main$__0__$5~JKHoJWR8~6Qpjlk4xLag: - R31_2, Gamma_R31_2 := bvadd64(R31_in, 18446744073709551600bv64), Gamma_R31_in; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_in); - R9_1, Gamma_R9_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + assume {:captureState "$main$__0__$5~JKHoJWR8~6Qpjlk4xLag"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "1816$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "1820$0"} true; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); + R8, Gamma_R8 := 69632bv64, true; call rely(); - assert (L(mem, 69684bv64) ==> Gamma_R9_1); - mem, Gamma_mem := memory_store32_le(mem, 69684bv64, R9_1[32:0]), gamma_store32(Gamma_mem, 69684bv64, Gamma_R9_1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); + assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assume {:captureState "1832$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), true); + assume {:captureState "1836$0"} true; call rely(); - R8_2, Gamma_R8_2 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_2; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + Cse0__5$2$8, Gamma_Cse0__5$2$8 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$2$8, Cse0__5$2$8)), Gamma_Cse0__5$2$8; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$2$8), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$2$8); + ZF, Gamma_ZF := bvcomp32(Cse0__5$2$8, 0bv32), Gamma_Cse0__5$2$8; + NF, Gamma_NF := Cse0__5$2$8[32:31], Gamma_Cse0__5$2$8; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$2$8), Gamma_Cse0__5$2$8; + assert Gamma_ZF; goto $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__0, $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__1; - $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__1: - assume (!(R8_2[32:0] == 0bv32)); - R8_4, Gamma_R8_4 := 1bv64, true; - goto $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__1_phi_$main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg, $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__1_phi_$main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__1__$KuIORB~IS7~W8tkjfAUb_Q; - $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__1_phi_$main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__1__$KuIORB~IS7~W8tkjfAUb_Q: - R9_6, Gamma_R9_6 := R9_1, Gamma_R9_1; - R31_7, Gamma_R31_7 := R31_2, Gamma_R31_2; - R8_10, Gamma_R8_10 := R8_4, Gamma_R8_4; - assert Gamma_R8_10; - goto $main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__1__$KuIORB~IS7~W8tkjfAUb_Q; - $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__1_phi_$main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg: - R9_8, Gamma_R9_8 := R9_1, Gamma_R9_1; - R31_9, Gamma_R31_9 := R31_2, Gamma_R31_2; - R8_12, Gamma_R8_12 := R8_4, Gamma_R8_4; - assert Gamma_R8_12; - goto $main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg; - $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__0: - assume (R8_2[32:0] == 0bv32); - R8_7, Gamma_R8_7 := 0bv64, true; - goto $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__0_phi_$main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg, $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__0_phi_$main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__1__$KuIORB~IS7~W8tkjfAUb_Q; - $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__0_phi_$main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__1__$KuIORB~IS7~W8tkjfAUb_Q: - R9_6, Gamma_R9_6 := R9_1, Gamma_R9_1; - R31_7, Gamma_R31_7 := R31_2, Gamma_R31_2; - R8_10, Gamma_R8_10 := R8_7, Gamma_R8_7; - assert Gamma_R8_10; - goto $main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__1__$KuIORB~IS7~W8tkjfAUb_Q; - $main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__1__$KuIORB~IS7~W8tkjfAUb_Q: - assume (!(R8_10[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_7, 4bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_7, 4bv64), true); - R9_10, Gamma_R9_10 := R9_6, Gamma_R9_6; - R31_11, Gamma_R31_11 := R31_7, Gamma_R31_7; - goto $main$__3__$4zQQ78p3RBGN7NOzIYTxvg; - $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__0_phi_$main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg: - R9_8, Gamma_R9_8 := R9_1, Gamma_R9_1; - R31_9, Gamma_R31_9 := R31_2, Gamma_R31_2; - R8_12, Gamma_R8_12 := R8_7, Gamma_R8_7; - assert Gamma_R8_12; - goto $main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg; - $main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg: - assume (R8_12[1:0] == 1bv1); - R9_10, Gamma_R9_10 := R9_8, Gamma_R9_8; - R31_11, Gamma_R31_11 := R31_9, Gamma_R31_9; + $main$__1__$KuIORB~IS7~W8tkjfAUb_Q: + assume {:captureState "$main$__1__$KuIORB~IS7~W8tkjfAUb_Q"} true; + goto $main$__2__$YnjHRw7ZSTa3I0Dc55xViw; + $main$__2__$YnjHRw7ZSTa3I0Dc55xViw: + assume {:captureState "$main$__2__$YnjHRw7ZSTa3I0Dc55xViw"} true; + R8, Gamma_R8 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "1864$0"} true; goto $main$__3__$4zQQ78p3RBGN7NOzIYTxvg; $main$__3__$4zQQ78p3RBGN7NOzIYTxvg: + assume {:captureState "$main$__3__$4zQQ78p3RBGN7NOzIYTxvg"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_14, Gamma_R8_14 := zero_extend32_32(memory_load32_le(mem, 69684bv64)), (gamma_load32(Gamma_mem, 69684bv64) || L(mem, 69684bv64)); - assert Gamma_R8_14; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); + Cse0__5$1$2, Gamma_Cse0__5$1$2 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$1$2), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_Cse0__5$1$2); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$1$2), bvadd33(zero_extend1_32(R8[32:0]), 4294967295bv33))), (Gamma_R8 && Gamma_Cse0__5$1$2); + ZF, Gamma_ZF := bvcomp32(Cse0__5$1$2, 0bv32), Gamma_Cse0__5$1$2; + NF, Gamma_NF := Cse0__5$1$2[32:31], Gamma_Cse0__5$1$2; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$1$2), Gamma_Cse0__5$1$2; + assert Gamma_ZF; goto $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__0, $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__1; - $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__1: - assume (!(R8_14[32:0] == 1bv32)); - R8_16, Gamma_R8_16 := 1bv64, true; - goto $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__1_phi_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__6__$Bi8U6733SjiyOwaLV4yoGg, $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__1_phi_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__4__$mvvj12GjRhuZDH0mklvA1Q; - $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__1_phi_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__4__$mvvj12GjRhuZDH0mklvA1Q: - R9_15, Gamma_R9_15 := R9_10, Gamma_R9_10; - R31_16, Gamma_R31_16 := R31_11, Gamma_R31_11; - R8_22, Gamma_R8_22 := R8_16, Gamma_R8_16; - assert Gamma_R8_22; - goto $main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__4__$mvvj12GjRhuZDH0mklvA1Q; - $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__1_phi_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__6__$Bi8U6733SjiyOwaLV4yoGg: - R9_17, Gamma_R9_17 := R9_10, Gamma_R9_10; - R31_18, Gamma_R31_18 := R31_11, Gamma_R31_11; - R8_24, Gamma_R8_24 := R8_16, Gamma_R8_16; - assert Gamma_R8_24; - goto $main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__6__$Bi8U6733SjiyOwaLV4yoGg; - $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__0: - assume (R8_14[32:0] == 1bv32); - R8_19, Gamma_R8_19 := 0bv64, true; - goto $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__0_phi_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__6__$Bi8U6733SjiyOwaLV4yoGg, $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__0_phi_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__4__$mvvj12GjRhuZDH0mklvA1Q; - $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__0_phi_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__4__$mvvj12GjRhuZDH0mklvA1Q: - R9_15, Gamma_R9_15 := R9_10, Gamma_R9_10; - R31_16, Gamma_R31_16 := R31_11, Gamma_R31_11; - R8_22, Gamma_R8_22 := R8_19, Gamma_R8_19; - assert Gamma_R8_22; - goto $main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__4__$mvvj12GjRhuZDH0mklvA1Q; - $main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__4__$mvvj12GjRhuZDH0mklvA1Q: - assume (!(R8_22[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_16, 4bv64), 5bv32), gamma_store32(Gamma_stack, bvadd64(R31_16, 4bv64), true); - R9_19, Gamma_R9_19 := R9_15, Gamma_R9_15; - R31_20, Gamma_R31_20 := R31_16, Gamma_R31_16; - goto $main$__6__$Bi8U6733SjiyOwaLV4yoGg; - $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__0_phi_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__6__$Bi8U6733SjiyOwaLV4yoGg: - R9_17, Gamma_R9_17 := R9_10, Gamma_R9_10; - R31_18, Gamma_R31_18 := R31_11, Gamma_R31_11; - R8_24, Gamma_R8_24 := R8_19, Gamma_R8_19; - assert Gamma_R8_24; - goto $main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__6__$Bi8U6733SjiyOwaLV4yoGg; - $main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__6__$Bi8U6733SjiyOwaLV4yoGg: - assume (R8_24[1:0] == 1bv1); - R9_19, Gamma_R9_19 := R9_17, Gamma_R9_17; - R31_20, Gamma_R31_20 := R31_18, Gamma_R31_18; + $main$__4__$mvvj12GjRhuZDH0mklvA1Q: + assume {:captureState "$main$__4__$mvvj12GjRhuZDH0mklvA1Q"} true; + goto $main$__5__$qyZYtjM~TZG82G5a2M8umw; + $main$__5__$qyZYtjM~TZG82G5a2M8umw: + assume {:captureState "$main$__5__$qyZYtjM~TZG82G5a2M8umw"} true; + R8, Gamma_R8 := 5bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "1900$0"} true; goto $main$__6__$Bi8U6733SjiyOwaLV4yoGg; $main$__6__$Bi8U6733SjiyOwaLV4yoGg: - R8_25, Gamma_R8_25 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_20, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31_20, 4bv64)); - assert Gamma_R8_25; + assume {:captureState "$main$__6__$Bi8U6733SjiyOwaLV4yoGg"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); + Cse0__5$4$1, Gamma_Cse0__5$4$1 := bvadd32(R8[32:0], 4294967293bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$4$1), bvadd33(sign_extend1_32(R8[32:0]), 8589934589bv33))), (Gamma_R8 && Gamma_Cse0__5$4$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$4$1), bvadd33(zero_extend1_32(R8[32:0]), 4294967293bv33))), (Gamma_R8 && Gamma_Cse0__5$4$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$4$1, 0bv32), Gamma_Cse0__5$4$1; + NF, Gamma_NF := Cse0__5$4$1[32:31], Gamma_Cse0__5$4$1; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$4$1), Gamma_Cse0__5$4$1; + assert Gamma_ZF; goto $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__0, $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__1; - $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__1: - assume (!(R8_25[32:0] == 3bv32)); - R8_27, Gamma_R8_27 := 1bv64, true; - goto $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__1_phi_$main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__9__$ZE4m7PzcQaiZtThKfMYMbw, $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__1_phi_$main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__7__$Ke1U9A74QzyX5d6~BvAXuA; - $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__1_phi_$main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__7__$Ke1U9A74QzyX5d6~BvAXuA: - R9_24, Gamma_R9_24 := R9_19, Gamma_R9_19; - R31_25, Gamma_R31_25 := R31_20, Gamma_R31_20; - R8_33, Gamma_R8_33 := R8_27, Gamma_R8_27; - assert Gamma_R8_33; - goto $main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__7__$Ke1U9A74QzyX5d6~BvAXuA; - $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__1_phi_$main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__9__$ZE4m7PzcQaiZtThKfMYMbw: - R9_26, Gamma_R9_26 := R9_19, Gamma_R9_19; - R31_27, Gamma_R31_27 := R31_20, Gamma_R31_20; - R8_36, Gamma_R8_36 := R8_27, Gamma_R8_27; - assert Gamma_R8_36; - goto $main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__9__$ZE4m7PzcQaiZtThKfMYMbw; - $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__0: - assume (R8_25[32:0] == 3bv32); - R8_30, Gamma_R8_30 := 0bv64, true; - goto $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__0_phi_$main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__9__$ZE4m7PzcQaiZtThKfMYMbw, $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__0_phi_$main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__7__$Ke1U9A74QzyX5d6~BvAXuA; - $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__0_phi_$main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__7__$Ke1U9A74QzyX5d6~BvAXuA: - R9_24, Gamma_R9_24 := R9_19, Gamma_R9_19; - R31_25, Gamma_R31_25 := R31_20, Gamma_R31_20; - R8_33, Gamma_R8_33 := R8_30, Gamma_R8_30; - assert Gamma_R8_33; - goto $main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__7__$Ke1U9A74QzyX5d6~BvAXuA; - $main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__7__$Ke1U9A74QzyX5d6~BvAXuA: - assume (!(R8_33[1:0] == 1bv1)); + $main$__7__$Ke1U9A74QzyX5d6~BvAXuA: + assume {:captureState "$main$__7__$Ke1U9A74QzyX5d6~BvAXuA"} true; + goto $main$__8__$Y0H3mt1KQG6tdER4yPd20Q; + $main$__8__$Y0H3mt1KQG6tdER4yPd20Q: + assume {:captureState "$main$__8__$Y0H3mt1KQG6tdER4yPd20Q"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R8_35, Gamma_R8_35 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_25, 4bv64), R8_35[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_25, 4bv64), Gamma_R8_35); - R9_28, Gamma_R9_28 := R9_24, Gamma_R9_24; - R31_29, Gamma_R31_29 := R31_25, Gamma_R31_25; - goto $main$__9__$ZE4m7PzcQaiZtThKfMYMbw; - $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__0_phi_$main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__9__$ZE4m7PzcQaiZtThKfMYMbw: - R9_26, Gamma_R9_26 := R9_19, Gamma_R9_19; - R31_27, Gamma_R31_27 := R31_20, Gamma_R31_20; - R8_36, Gamma_R8_36 := R8_30, Gamma_R8_30; - assert Gamma_R8_36; - goto $main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__9__$ZE4m7PzcQaiZtThKfMYMbw; - $main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__9__$ZE4m7PzcQaiZtThKfMYMbw: - assume (R8_36[1:0] == 1bv1); - R9_28, Gamma_R9_28 := R9_26, Gamma_R9_26; - R31_29, Gamma_R31_29 := R31_27, Gamma_R31_27; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "1936$0"} true; goto $main$__9__$ZE4m7PzcQaiZtThKfMYMbw; $main$__9__$ZE4m7PzcQaiZtThKfMYMbw: + assume {:captureState "$main$__9__$ZE4m7PzcQaiZtThKfMYMbw"} true; + R8, Gamma_R8 := 69632bv64, true; call rely(); - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(mem, 69688bv64)), (gamma_load32(Gamma_mem, 69688bv64) || L(mem, 69688bv64)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); + R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; goto main_basil_return; + $main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__6__$Bi8U6733SjiyOwaLV4yoGg: + assume {:captureState "$main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__6__$Bi8U6733SjiyOwaLV4yoGg"} true; + assume (R8[1:0] == 1bv1); + goto $main$__6__$Bi8U6733SjiyOwaLV4yoGg; + $main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__4__$mvvj12GjRhuZDH0mklvA1Q: + assume {:captureState "$main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__4__$mvvj12GjRhuZDH0mklvA1Q"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__4__$mvvj12GjRhuZDH0mklvA1Q; + $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__0: + assume {:captureState "$main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__6__$Bi8U6733SjiyOwaLV4yoGg, $main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__4__$mvvj12GjRhuZDH0mklvA1Q; + $main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__1: + assume {:captureState "$main$__3__$4zQQ78p3RBGN7NOzIYTxvg$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__6__$Bi8U6733SjiyOwaLV4yoGg, $main$__3__$4zQQ78p3RBGN7NOzIYTxvg_goto_$main$__4__$mvvj12GjRhuZDH0mklvA1Q; + $main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg: + assume {:captureState "$main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$4zQQ78p3RBGN7NOzIYTxvg; + $main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__1__$KuIORB~IS7~W8tkjfAUb_Q: + assume {:captureState "$main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__1__$KuIORB~IS7~W8tkjfAUb_Q"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$KuIORB~IS7~W8tkjfAUb_Q; + $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__0: + assume {:captureState "$main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg, $main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__1__$KuIORB~IS7~W8tkjfAUb_Q; + $main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__1: + assume {:captureState "$main$__0__$5~JKHoJWR8~6Qpjlk4xLag$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__3__$4zQQ78p3RBGN7NOzIYTxvg, $main$__0__$5~JKHoJWR8~6Qpjlk4xLag_goto_$main$__1__$KuIORB~IS7~W8tkjfAUb_Q; + $main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__9__$ZE4m7PzcQaiZtThKfMYMbw: + assume {:captureState "$main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__9__$ZE4m7PzcQaiZtThKfMYMbw"} true; + assume (R8[1:0] == 1bv1); + goto $main$__9__$ZE4m7PzcQaiZtThKfMYMbw; + $main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__7__$Ke1U9A74QzyX5d6~BvAXuA: + assume {:captureState "$main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__7__$Ke1U9A74QzyX5d6~BvAXuA"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__7__$Ke1U9A74QzyX5d6~BvAXuA; + $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__0: + assume {:captureState "$main$__6__$Bi8U6733SjiyOwaLV4yoGg$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__9__$ZE4m7PzcQaiZtThKfMYMbw, $main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__7__$Ke1U9A74QzyX5d6~BvAXuA; + $main$__6__$Bi8U6733SjiyOwaLV4yoGg$__1: + assume {:captureState "$main$__6__$Bi8U6733SjiyOwaLV4yoGg$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__9__$ZE4m7PzcQaiZtThKfMYMbw, $main$__6__$Bi8U6733SjiyOwaLV4yoGg_goto_$main$__7__$Ke1U9A74QzyX5d6~BvAXuA; main_basil_return: - R0_out, R31_out, R8_out, R9_out := R0_2, bvadd64(R31_29, 16bv64), 69632bv64, R9_28; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_2, Gamma_R31_29, true, Gamma_R9_28; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/nestedifglobal/clang_pic/nestedifglobal.expected b/src/test/incorrect/nestedifglobal/clang_pic/nestedifglobal.expected index 68709cfcb..80d21764f 100644 --- a/src/test/incorrect/nestedifglobal/clang_pic/nestedifglobal.expected +++ b/src/test/incorrect/nestedifglobal/clang_pic/nestedifglobal.expected @@ -1,26 +1,34 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -30,15 +38,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -49,38 +53,33 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -93,150 +92,210 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, R9, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 2052bv64) == 1bv8); - free requires (memory_load8_le(mem, 2053bv64) == 0bv8); - free requires (memory_load8_le(mem, 2054bv64) == 2bv8); - free requires (memory_load8_le(mem, 2055bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 2052bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 2052bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2053bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2054bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2055bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2052bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R8_10: bool; - var Gamma_R8_11: bool; - var Gamma_R8_16: bool; - var Gamma_R8_18: bool; - var Gamma_R8_2: bool; - var Gamma_R8_23: bool; - var Gamma_R8_25: bool; - var Gamma_R8_26: bool; - var Gamma_R8_28: bool; - var Gamma_R8_3: bool; - var Gamma_R8_8: bool; - var Gamma_R9_1: bool; - var R0_2: bv64; - var R8_10: bv64; - var R8_11: bv32; - var R8_16: bv64; - var R8_18: bv32; - var R8_2: bv64; - var R8_23: bv64; - var R8_25: bv64; - var R8_26: bv64; - var R8_28: bv64; - var R8_3: bv32; - var R8_8: bv64; - var R9_1: bv64; + var #4: bv32; + var #5: bv32; + var #6: bv32; + var Gamma_#4: bool; + var Gamma_#5: bool; + var Gamma_#6: bool; lmain: + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R8_2), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R8_2); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_in); - R9_1, Gamma_R9_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000035e"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%00000365"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%0000036d"} true; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); - assert (L(mem, R8_2) ==> Gamma_R9_1); - mem, Gamma_mem := memory_store32_le(mem, R8_2, R9_1[32:0]), gamma_store32(Gamma_mem, R8_2, Gamma_R9_1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); + assert (L(mem, R8) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, R8, R9[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R9); + assume {:captureState "%0000037c"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), true); + assume {:captureState "%00000383"} true; call rely(); - R8_3, Gamma_R8_3 := memory_load32_le(mem, R8_2), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#4, 1bv32)), Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l000003ab, lmain_goto_l000003ae; - lmain_goto_l000003ae: - assume (!(R8_3 == 0bv32)); - R8_8, Gamma_R8_8 := 1bv64, true; + l000003ae: + assume {:captureState "l000003ae"} true; + R8, Gamma_R8 := 1bv64, true; goto l000003b1; - lmain_goto_l000003ab: - assume (R8_3 == 0bv32); - R8_8, Gamma_R8_8 := 0bv64, true; + l000003ab: + assume {:captureState "l000003ab"} true; + R8, Gamma_R8 := 0bv64, true; goto l000003b1; l000003b1: - assert Gamma_R8_8; + assume {:captureState "l000003b1"} true; + assert Gamma_R8; goto l000003b1_goto_l000003b9, l000003b1_goto_l00000481; - l000003b1_goto_l00000481: - assume (!(R8_8[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); - goto l000003b9; - l000003b1_goto_l000003b9: - assume (R8_8[1:0] == 1bv1); + l00000481: + assume {:captureState "l00000481"} true; + goto l00000482; + l00000482: + assume {:captureState "l00000482"} true; + R8, Gamma_R8 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "%00000490"} true; goto l000003b9; l000003b9: - R8_10, Gamma_R8_10 := memory_load64_le(stack, bvadd64(R31_in, 18446744073709551592bv64)), gamma_load64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64)); + assume {:captureState "l000003b9"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - R8_11, Gamma_R8_11 := memory_load32_le(mem, R8_10), (gamma_load32(Gamma_mem, R8_10) || L(mem, R8_10)); - assert Gamma_R8_11; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + #5, Gamma_#5 := bvadd32(R8[32:0], 4294967294bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_#5); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#5, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967295bv33))), (Gamma_R8 && Gamma_#5); + ZF, Gamma_ZF := bvcomp32(bvadd32(#5, 1bv32), 0bv32), Gamma_#5; + NF, Gamma_NF := bvadd32(#5, 1bv32)[32:31], Gamma_#5; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#5, 1bv32)), Gamma_#5; + assert Gamma_ZF; goto l000003b9_goto_l000003eb, l000003b9_goto_l000003ee; - l000003b9_goto_l000003ee: - assume (!(R8_11 == 1bv32)); - R8_16, Gamma_R8_16 := 1bv64, true; + l000003ee: + assume {:captureState "l000003ee"} true; + R8, Gamma_R8 := 1bv64, true; goto l000003f1; - l000003b9_goto_l000003eb: - assume (R8_11 == 1bv32); - R8_16, Gamma_R8_16 := 0bv64, true; + l000003eb: + assume {:captureState "l000003eb"} true; + R8, Gamma_R8 := 0bv64, true; goto l000003f1; l000003f1: - assert Gamma_R8_16; + assume {:captureState "l000003f1"} true; + assert Gamma_R8; goto l000003f1_goto_l000003f9, l000003f1_goto_l0000046c; - l000003f1_goto_l0000046c: - assume (!(R8_16[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 5bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); - goto l000003f9; - l000003f1_goto_l000003f9: - assume (R8_16[1:0] == 1bv1); + l0000046c: + assume {:captureState "l0000046c"} true; + goto l0000046d; + l0000046d: + assume {:captureState "l0000046d"} true; + R8, Gamma_R8 := 5bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "%0000047b"} true; goto l000003f9; l000003f9: - R8_18, Gamma_R8_18 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551604bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64)); - assert Gamma_R8_18; + assume {:captureState "l000003f9"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + #6, Gamma_#6 := bvadd32(R8[32:0], 4294967292bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934589bv33))), (Gamma_R8 && Gamma_#6); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#6, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967293bv33))), (Gamma_R8 && Gamma_#6); + ZF, Gamma_ZF := bvcomp32(bvadd32(#6, 1bv32), 0bv32), Gamma_#6; + NF, Gamma_NF := bvadd32(#6, 1bv32)[32:31], Gamma_#6; + R8, Gamma_R8 := zero_extend32_32(bvadd32(#6, 1bv32)), Gamma_#6; + assert Gamma_ZF; goto l000003f9_goto_l00000424, l000003f9_goto_l00000427; - l000003f9_goto_l00000427: - assume (!(R8_18 == 3bv32)); - R8_23, Gamma_R8_23 := 1bv64, true; + l00000427: + assume {:captureState "l00000427"} true; + R8, Gamma_R8 := 1bv64, true; goto l0000042a; - l000003f9_goto_l00000424: - assume (R8_18 == 3bv32); - R8_23, Gamma_R8_23 := 0bv64, true; + l00000424: + assume {:captureState "l00000424"} true; + R8, Gamma_R8 := 0bv64, true; goto l0000042a; l0000042a: - assert Gamma_R8_23; + assume {:captureState "l0000042a"} true; + assert Gamma_R8; goto l0000042a_goto_l00000432, l0000042a_goto_l00000449; - l0000042a_goto_l00000449: - assume (!(R8_23[1:0] == 1bv1)); + l00000449: + assume {:captureState "l00000449"} true; + goto l0000044a; + l0000044a: + assume {:captureState "l0000044a"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_25, Gamma_R8_25 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - R8_26, Gamma_R8_26 := zero_extend32_32(memory_load32_le(mem, R8_25)), (gamma_load32(Gamma_mem, R8_25) || L(mem, R8_25)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), R8_26[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), Gamma_R8_26); - R8_28, Gamma_R8_28 := R8_26, Gamma_R8_26; - goto l00000432; - l0000042a_goto_l00000432: - assume (R8_23[1:0] == 1bv1); - R8_28, Gamma_R8_28 := R8_23, Gamma_R8_23; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "%00000466"} true; goto l00000432; l00000432: - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); + assume {:captureState "l00000432"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l000003ab: + assume {:captureState "lmain_goto_l000003ab"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l000003ab; + lmain_goto_l000003ae: + assume {:captureState "lmain_goto_l000003ae"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l000003ae; + l000003b1_goto_l000003b9: + assume {:captureState "l000003b1_goto_l000003b9"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l000003b9; + l000003b1_goto_l00000481: + assume {:captureState "l000003b1_goto_l00000481"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000481; + l000003b9_goto_l000003eb: + assume {:captureState "l000003b9_goto_l000003eb"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l000003eb; + l000003b9_goto_l000003ee: + assume {:captureState "l000003b9_goto_l000003ee"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l000003ee; + l000003f1_goto_l000003f9: + assume {:captureState "l000003f1_goto_l000003f9"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l000003f9; + l000003f1_goto_l0000046c: + assume {:captureState "l000003f1_goto_l0000046c"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l0000046c; + l000003f9_goto_l00000424: + assume {:captureState "l000003f9_goto_l00000424"} true; + assume (bvcomp1(ZF, 1bv1) != 0bv1); + goto l00000424; + l000003f9_goto_l00000427: + assume {:captureState "l000003f9_goto_l00000427"} true; + assume (bvcomp1(ZF, 1bv1) == 0bv1); + goto l00000427; + l0000042a_goto_l00000432: + assume {:captureState "l0000042a_goto_l00000432"} true; + assume (bvcomp1(R8[1:0], 1bv1) != 0bv1); + goto l00000432; + l0000042a_goto_l00000449: + assume {:captureState "l0000042a_goto_l00000449"} true; + assume (bvcomp1(R8[1:0], 1bv1) == 0bv1); + goto l00000449; main_basil_return: - R0_out, R31_out, R8_out, R9_out := R0_2, R31_in, R8_28, R9_1; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_2, Gamma_R31_in, Gamma_R8_28, Gamma_R9_1; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/nestedifglobal/clang_pic/nestedifglobal_gtirb.expected b/src/test/incorrect/nestedifglobal/clang_pic/nestedifglobal_gtirb.expected index 5b1296d4b..88dd27ef3 100644 --- a/src/test/incorrect/nestedifglobal/clang_pic/nestedifglobal_gtirb.expected +++ b/src/test/incorrect/nestedifglobal/clang_pic/nestedifglobal_gtirb.expected @@ -1,26 +1,33 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - -function {:inline} byte_extract64_64(value: bv64, offset: bv64) returns (bv8) { - bvlshr64(value,bvmul64(offset,8bv64))[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -30,15 +37,11 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -49,38 +52,33 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 8bv64, i) then byte_extract64_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2060bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2061bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2062bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2063bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2060bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -93,283 +91,190 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R31, Gamma_R8, Gamma_R9, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R31, R8, R9, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69664bv64) == 0bv64); free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); - free requires (memory_load8_le(mem, 2060bv64) == 1bv8); - free requires (memory_load8_le(mem, 2061bv64) == 0bv8); - free requires (memory_load8_le(mem, 2062bv64) == 2bv8); - free requires (memory_load8_le(mem, 2063bv64) == 0bv8); - free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); - free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load32_le(mem, 2060bv64) == 131073bv32); free requires (memory_load64_le(mem, 69048bv64) == 1872bv64); + free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); free requires (memory_load64_le(mem, 69568bv64) == 69688bv64); + free requires (memory_load64_le(mem, 69576bv64) == 69684bv64); free requires (memory_load64_le(mem, 69592bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69056bv64) == 1792bv64); - free ensures (memory_load8_le(mem, 2060bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2061bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2062bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2063bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); - free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); + free requires (memory_load64_le(mem, 69672bv64) == 69672bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2060bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69048bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69568bv64) == 69688bv64); + free ensures (memory_load64_le(mem, 69576bv64) == 69684bv64); free ensures (memory_load64_le(mem, 69592bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69056bv64) == 1792bv64); + free ensures (memory_load64_le(mem, 69672bv64) == 69672bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R31_out: bv64, Gamma_R31_out: bool, R8_out: bv64, Gamma_R8_out: bool, R9_out: bv64, Gamma_R9_out: bool) +implementation main() { - var Gamma_R0_2: bool; - var Gamma_R31_11: bool; - var Gamma_R31_16: bool; - var Gamma_R31_18: bool; - var Gamma_R31_2: bool; - var Gamma_R31_20: bool; - var Gamma_R31_25: bool; - var Gamma_R31_27: bool; - var Gamma_R31_29: bool; - var Gamma_R31_7: bool; - var Gamma_R31_9: bool; - var Gamma_R8_11: bool; - var Gamma_R8_13: bool; - var Gamma_R8_14: bool; - var Gamma_R8_15: bool; - var Gamma_R8_17: bool; - var Gamma_R8_2: bool; - var Gamma_R8_20: bool; - var Gamma_R8_23: bool; - var Gamma_R8_25: bool; - var Gamma_R8_26: bool; - var Gamma_R8_28: bool; - var Gamma_R8_3: bool; - var Gamma_R8_31: bool; - var Gamma_R8_34: bool; - var Gamma_R8_36: bool; - var Gamma_R8_37: bool; - var Gamma_R8_38: bool; - var Gamma_R8_40: bool; - var Gamma_R8_5: bool; - var Gamma_R8_8: bool; - var Gamma_R9_1: bool; - var Gamma_R9_10: bool; - var Gamma_R9_15: bool; - var Gamma_R9_17: bool; - var Gamma_R9_19: bool; - var Gamma_R9_24: bool; - var Gamma_R9_26: bool; - var Gamma_R9_28: bool; - var Gamma_R9_6: bool; - var Gamma_R9_8: bool; - var R0_2: bv64; - var R31_11: bv64; - var R31_16: bv64; - var R31_18: bv64; - var R31_2: bv64; - var R31_20: bv64; - var R31_25: bv64; - var R31_27: bv64; - var R31_29: bv64; - var R31_7: bv64; - var R31_9: bv64; - var R8_11: bv64; - var R8_13: bv64; - var R8_14: bv64; - var R8_15: bv64; - var R8_17: bv64; - var R8_2: bv64; - var R8_20: bv64; - var R8_23: bv64; - var R8_25: bv64; - var R8_26: bv64; - var R8_28: bv64; - var R8_3: bv64; - var R8_31: bv64; - var R8_34: bv64; - var R8_36: bv64; - var R8_37: bv64; - var R8_38: bv64; - var R8_40: bv64; - var R8_5: bv64; - var R8_8: bv64; - var R9_1: bv64; - var R9_10: bv64; - var R9_15: bv64; - var R9_17: bv64; - var R9_19: bv64; - var R9_24: bv64; - var R9_26: bv64; - var R9_28: bv64; - var R9_6: bv64; - var R9_8: bv64; + var Cse0__5$3$1: bv32; + var Cse0__5$4$2: bv32; + var Cse0__5$7$10: bv32; + var Gamma_Cse0__5$3$1: bool; + var Gamma_Cse0__5$4$2: bool; + var Gamma_Cse0__5$7$10: bool; $main$__0__$T93CJsvjRiGkLGM3lm~zUw: - R31_2, Gamma_R31_2 := bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in; + assume {:captureState "$main$__0__$T93CJsvjRiGkLGM3lm~zUw"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_2, Gamma_R8_2 := memory_load64_le(mem, 69576bv64), (gamma_load64(Gamma_mem, 69576bv64) || L(mem, 69576bv64)); - stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31_in, 18446744073709551592bv64), R8_2), gamma_store64(Gamma_stack, bvadd64(R31_in, 18446744073709551592bv64), Gamma_R8_2); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551608bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64), Gamma_R0_in); - R9_1, Gamma_R9_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551608bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551608bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); + stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "1888$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "1892$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "1896$0"} true; + R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); - assert (L(mem, R8_2) ==> Gamma_R9_1); - mem, Gamma_mem := memory_store32_le(mem, R8_2, R9_1[32:0]), gamma_store32(Gamma_mem, R8_2, Gamma_R9_1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551604bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551604bv64), true); + assert (L(mem, R8) ==> Gamma_R9); + mem, Gamma_mem := memory_store32_le(mem, R8, R9[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R9); + assume {:captureState "1904$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), true); + assume {:captureState "1908$0"} true; call rely(); - R8_3, Gamma_R8_3 := zero_extend32_32(memory_load32_le(mem, R8_2)), (gamma_load32(Gamma_mem, R8_2) || L(mem, R8_2)); - assert Gamma_R8_3; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + Cse0__5$7$10, Gamma_Cse0__5$7$10 := bvadd32(R8[32:0], 0bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$7$10, Cse0__5$7$10)), Gamma_Cse0__5$7$10; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$7$10), bvadd33(zero_extend1_32(R8[32:0]), 4294967296bv33))), (Gamma_R8 && Gamma_Cse0__5$7$10); + ZF, Gamma_ZF := bvcomp32(Cse0__5$7$10, 0bv32), Gamma_Cse0__5$7$10; + NF, Gamma_NF := Cse0__5$7$10[32:31], Gamma_Cse0__5$7$10; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$7$10), Gamma_Cse0__5$7$10; + assert Gamma_ZF; goto $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__0, $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__1; - $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__1: - assume (!(R8_3[32:0] == 0bv32)); - R8_5, Gamma_R8_5 := 1bv64, true; - goto $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__1_phi_$main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ, $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__1_phi_$main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__1__$XR5j_yKuQR24HXECGUTTaw; - $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__1_phi_$main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__1__$XR5j_yKuQR24HXECGUTTaw: - R9_6, Gamma_R9_6 := R9_1, Gamma_R9_1; - R31_7, Gamma_R31_7 := R31_2, Gamma_R31_2; - R8_11, Gamma_R8_11 := R8_5, Gamma_R8_5; - assert Gamma_R8_11; - goto $main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__1__$XR5j_yKuQR24HXECGUTTaw; - $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__1_phi_$main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ: - R9_8, Gamma_R9_8 := R9_1, Gamma_R9_1; - R31_9, Gamma_R31_9 := R31_2, Gamma_R31_2; - R8_13, Gamma_R8_13 := R8_5, Gamma_R8_5; - assert Gamma_R8_13; - goto $main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ; - $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__0: - assume (R8_3[32:0] == 0bv32); - R8_8, Gamma_R8_8 := 0bv64, true; - goto $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__0_phi_$main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ, $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__0_phi_$main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__1__$XR5j_yKuQR24HXECGUTTaw; - $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__0_phi_$main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__1__$XR5j_yKuQR24HXECGUTTaw: - R9_6, Gamma_R9_6 := R9_1, Gamma_R9_1; - R31_7, Gamma_R31_7 := R31_2, Gamma_R31_2; - R8_11, Gamma_R8_11 := R8_8, Gamma_R8_8; - assert Gamma_R8_11; - goto $main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__1__$XR5j_yKuQR24HXECGUTTaw; - $main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__1__$XR5j_yKuQR24HXECGUTTaw: - assume (!(R8_11[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_7, 20bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_7, 20bv64), true); - R9_10, Gamma_R9_10 := R9_6, Gamma_R9_6; - R31_11, Gamma_R31_11 := R31_7, Gamma_R31_7; - goto $main$__3__$BQu4h3vlSRawGkdd3zg0DQ; - $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__0_phi_$main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ: - R9_8, Gamma_R9_8 := R9_1, Gamma_R9_1; - R31_9, Gamma_R31_9 := R31_2, Gamma_R31_2; - R8_13, Gamma_R8_13 := R8_8, Gamma_R8_8; - assert Gamma_R8_13; - goto $main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ; - $main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ: - assume (R8_13[1:0] == 1bv1); - R9_10, Gamma_R9_10 := R9_8, Gamma_R9_8; - R31_11, Gamma_R31_11 := R31_9, Gamma_R31_9; + $main$__1__$XR5j_yKuQR24HXECGUTTaw: + assume {:captureState "$main$__1__$XR5j_yKuQR24HXECGUTTaw"} true; + goto $main$__2__$StfBUB0KQESSUkJf_60bAQ; + $main$__2__$StfBUB0KQESSUkJf_60bAQ: + assume {:captureState "$main$__2__$StfBUB0KQESSUkJf_60bAQ"} true; + R8, Gamma_R8 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "1936$0"} true; goto $main$__3__$BQu4h3vlSRawGkdd3zg0DQ; $main$__3__$BQu4h3vlSRawGkdd3zg0DQ: - R8_14, Gamma_R8_14 := memory_load64_le(stack, bvadd64(R31_11, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31_11, 8bv64)); + assume {:captureState "$main$__3__$BQu4h3vlSRawGkdd3zg0DQ"} true; + R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); - R8_15, Gamma_R8_15 := zero_extend32_32(memory_load32_le(mem, R8_14)), (gamma_load32(Gamma_mem, R8_14) || L(mem, R8_14)); - assert Gamma_R8_15; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + Cse0__5$4$2, Gamma_Cse0__5$4$2 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$4$2), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_Cse0__5$4$2); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$4$2), bvadd33(zero_extend1_32(R8[32:0]), 4294967295bv33))), (Gamma_R8 && Gamma_Cse0__5$4$2); + ZF, Gamma_ZF := bvcomp32(Cse0__5$4$2, 0bv32), Gamma_Cse0__5$4$2; + NF, Gamma_NF := Cse0__5$4$2[32:31], Gamma_Cse0__5$4$2; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$4$2), Gamma_Cse0__5$4$2; + assert Gamma_ZF; goto $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__0, $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__1; - $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__1: - assume (!(R8_15[32:0] == 1bv32)); - R8_17, Gamma_R8_17 := 1bv64, true; - goto $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__1_phi_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__6__$ScgHlHhCS1WcMwxSLBCjog, $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__1_phi_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__4__$kgyF7X0vQAeoGY79WFpAXw; - $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__1_phi_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__4__$kgyF7X0vQAeoGY79WFpAXw: - R9_15, Gamma_R9_15 := R9_10, Gamma_R9_10; - R31_16, Gamma_R31_16 := R31_11, Gamma_R31_11; - R8_23, Gamma_R8_23 := R8_17, Gamma_R8_17; - assert Gamma_R8_23; - goto $main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__4__$kgyF7X0vQAeoGY79WFpAXw; - $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__1_phi_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__6__$ScgHlHhCS1WcMwxSLBCjog: - R9_17, Gamma_R9_17 := R9_10, Gamma_R9_10; - R31_18, Gamma_R31_18 := R31_11, Gamma_R31_11; - R8_25, Gamma_R8_25 := R8_17, Gamma_R8_17; - assert Gamma_R8_25; - goto $main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__6__$ScgHlHhCS1WcMwxSLBCjog; - $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__0: - assume (R8_15[32:0] == 1bv32); - R8_20, Gamma_R8_20 := 0bv64, true; - goto $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__0_phi_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__6__$ScgHlHhCS1WcMwxSLBCjog, $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__0_phi_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__4__$kgyF7X0vQAeoGY79WFpAXw; - $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__0_phi_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__4__$kgyF7X0vQAeoGY79WFpAXw: - R9_15, Gamma_R9_15 := R9_10, Gamma_R9_10; - R31_16, Gamma_R31_16 := R31_11, Gamma_R31_11; - R8_23, Gamma_R8_23 := R8_20, Gamma_R8_20; - assert Gamma_R8_23; - goto $main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__4__$kgyF7X0vQAeoGY79WFpAXw; - $main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__4__$kgyF7X0vQAeoGY79WFpAXw: - assume (!(R8_23[1:0] == 1bv1)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_16, 20bv64), 5bv32), gamma_store32(Gamma_stack, bvadd64(R31_16, 20bv64), true); - R9_19, Gamma_R9_19 := R9_15, Gamma_R9_15; - R31_20, Gamma_R31_20 := R31_16, Gamma_R31_16; - goto $main$__6__$ScgHlHhCS1WcMwxSLBCjog; - $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__0_phi_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__6__$ScgHlHhCS1WcMwxSLBCjog: - R9_17, Gamma_R9_17 := R9_10, Gamma_R9_10; - R31_18, Gamma_R31_18 := R31_11, Gamma_R31_11; - R8_25, Gamma_R8_25 := R8_20, Gamma_R8_20; - assert Gamma_R8_25; - goto $main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__6__$ScgHlHhCS1WcMwxSLBCjog; - $main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__6__$ScgHlHhCS1WcMwxSLBCjog: - assume (R8_25[1:0] == 1bv1); - R9_19, Gamma_R9_19 := R9_17, Gamma_R9_17; - R31_20, Gamma_R31_20 := R31_18, Gamma_R31_18; + $main$__4__$kgyF7X0vQAeoGY79WFpAXw: + assume {:captureState "$main$__4__$kgyF7X0vQAeoGY79WFpAXw"} true; + goto $main$__5__$La5W_bn0QnSJ~MnvpXFWoA; + $main$__5__$La5W_bn0QnSJ~MnvpXFWoA: + assume {:captureState "$main$__5__$La5W_bn0QnSJ~MnvpXFWoA"} true; + R8, Gamma_R8 := 5bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "1972$0"} true; goto $main$__6__$ScgHlHhCS1WcMwxSLBCjog; $main$__6__$ScgHlHhCS1WcMwxSLBCjog: - R8_26, Gamma_R8_26 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_20, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31_20, 20bv64)); - assert Gamma_R8_26; + assume {:captureState "$main$__6__$ScgHlHhCS1WcMwxSLBCjog"} true; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); + Cse0__5$3$1, Gamma_Cse0__5$3$1 := bvadd32(R8[32:0], 4294967293bv32), Gamma_R8; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$3$1), bvadd33(sign_extend1_32(R8[32:0]), 8589934589bv33))), (Gamma_R8 && Gamma_Cse0__5$3$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$1), bvadd33(zero_extend1_32(R8[32:0]), 4294967293bv33))), (Gamma_R8 && Gamma_Cse0__5$3$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$1, 0bv32), Gamma_Cse0__5$3$1; + NF, Gamma_NF := Cse0__5$3$1[32:31], Gamma_Cse0__5$3$1; + R8, Gamma_R8 := zero_extend32_32(Cse0__5$3$1), Gamma_Cse0__5$3$1; + assert Gamma_ZF; goto $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__0, $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__1; - $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__1: - assume (!(R8_26[32:0] == 3bv32)); - R8_28, Gamma_R8_28 := 1bv64, true; - goto $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__1_phi_$main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__9__$WNf_4UJFTCupBtDlyt4H0A, $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__1_phi_$main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__7__$PJQQ~S5hQ3isxVg_lohkuQ; - $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__1_phi_$main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__7__$PJQQ~S5hQ3isxVg_lohkuQ: - R9_24, Gamma_R9_24 := R9_19, Gamma_R9_19; - R31_25, Gamma_R31_25 := R31_20, Gamma_R31_20; - R8_34, Gamma_R8_34 := R8_28, Gamma_R8_28; - assert Gamma_R8_34; - goto $main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__7__$PJQQ~S5hQ3isxVg_lohkuQ; - $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__1_phi_$main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__9__$WNf_4UJFTCupBtDlyt4H0A: - R9_26, Gamma_R9_26 := R9_19, Gamma_R9_19; - R31_27, Gamma_R31_27 := R31_20, Gamma_R31_20; - R8_38, Gamma_R8_38 := R8_28, Gamma_R8_28; - assert Gamma_R8_38; - goto $main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__9__$WNf_4UJFTCupBtDlyt4H0A; - $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__0: - assume (R8_26[32:0] == 3bv32); - R8_31, Gamma_R8_31 := 0bv64, true; - goto $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__0_phi_$main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__9__$WNf_4UJFTCupBtDlyt4H0A, $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__0_phi_$main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__7__$PJQQ~S5hQ3isxVg_lohkuQ; - $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__0_phi_$main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__7__$PJQQ~S5hQ3isxVg_lohkuQ: - R9_24, Gamma_R9_24 := R9_19, Gamma_R9_19; - R31_25, Gamma_R31_25 := R31_20, Gamma_R31_20; - R8_34, Gamma_R8_34 := R8_31, Gamma_R8_31; - assert Gamma_R8_34; - goto $main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__7__$PJQQ~S5hQ3isxVg_lohkuQ; - $main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__7__$PJQQ~S5hQ3isxVg_lohkuQ: - assume (!(R8_34[1:0] == 1bv1)); + $main$__7__$PJQQ~S5hQ3isxVg_lohkuQ: + assume {:captureState "$main$__7__$PJQQ~S5hQ3isxVg_lohkuQ"} true; + goto $main$__8__$iZUB7usbTzOrpOA3bSaAkg; + $main$__8__$iZUB7usbTzOrpOA3bSaAkg: + assume {:captureState "$main$__8__$iZUB7usbTzOrpOA3bSaAkg"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_36, Gamma_R8_36 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - R8_37, Gamma_R8_37 := zero_extend32_32(memory_load32_le(mem, R8_36)), (gamma_load32(Gamma_mem, R8_36) || L(mem, R8_36)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_25, 20bv64), R8_37[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_25, 20bv64), Gamma_R8_37); - R9_28, Gamma_R9_28 := R9_24, Gamma_R9_24; - R31_29, Gamma_R31_29 := R31_25, Gamma_R31_25; - goto $main$__9__$WNf_4UJFTCupBtDlyt4H0A; - $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__0_phi_$main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__9__$WNf_4UJFTCupBtDlyt4H0A: - R9_26, Gamma_R9_26 := R9_19, Gamma_R9_19; - R31_27, Gamma_R31_27 := R31_20, Gamma_R31_20; - R8_38, Gamma_R8_38 := R8_31, Gamma_R8_31; - assert Gamma_R8_38; - goto $main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__9__$WNf_4UJFTCupBtDlyt4H0A; - $main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__9__$WNf_4UJFTCupBtDlyt4H0A: - assume (R8_38[1:0] == 1bv1); - R9_28, Gamma_R9_28 := R9_26, Gamma_R9_26; - R31_29, Gamma_R31_29 := R31_27, Gamma_R31_27; + R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "2012$0"} true; goto $main$__9__$WNf_4UJFTCupBtDlyt4H0A; $main$__9__$WNf_4UJFTCupBtDlyt4H0A: + assume {:captureState "$main$__9__$WNf_4UJFTCupBtDlyt4H0A"} true; + R8, Gamma_R8 := 65536bv64, true; call rely(); - R8_40, Gamma_R8_40 := memory_load64_le(mem, 69568bv64), (gamma_load64(Gamma_mem, 69568bv64) || L(mem, 69568bv64)); + R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); - R0_2, Gamma_R0_2 := zero_extend32_32(memory_load32_le(mem, R8_40)), (gamma_load32(Gamma_mem, R8_40) || L(mem, R8_40)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + $main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__9__$WNf_4UJFTCupBtDlyt4H0A: + assume {:captureState "$main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__9__$WNf_4UJFTCupBtDlyt4H0A"} true; + assume (R8[1:0] == 1bv1); + goto $main$__9__$WNf_4UJFTCupBtDlyt4H0A; + $main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__7__$PJQQ~S5hQ3isxVg_lohkuQ: + assume {:captureState "$main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__7__$PJQQ~S5hQ3isxVg_lohkuQ"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__7__$PJQQ~S5hQ3isxVg_lohkuQ; + $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__0: + assume {:captureState "$main$__6__$ScgHlHhCS1WcMwxSLBCjog$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__9__$WNf_4UJFTCupBtDlyt4H0A, $main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__7__$PJQQ~S5hQ3isxVg_lohkuQ; + $main$__6__$ScgHlHhCS1WcMwxSLBCjog$__1: + assume {:captureState "$main$__6__$ScgHlHhCS1WcMwxSLBCjog$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__9__$WNf_4UJFTCupBtDlyt4H0A, $main$__6__$ScgHlHhCS1WcMwxSLBCjog_goto_$main$__7__$PJQQ~S5hQ3isxVg_lohkuQ; + $main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__6__$ScgHlHhCS1WcMwxSLBCjog: + assume {:captureState "$main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__6__$ScgHlHhCS1WcMwxSLBCjog"} true; + assume (R8[1:0] == 1bv1); + goto $main$__6__$ScgHlHhCS1WcMwxSLBCjog; + $main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__4__$kgyF7X0vQAeoGY79WFpAXw: + assume {:captureState "$main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__4__$kgyF7X0vQAeoGY79WFpAXw"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__4__$kgyF7X0vQAeoGY79WFpAXw; + $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__0: + assume {:captureState "$main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__6__$ScgHlHhCS1WcMwxSLBCjog, $main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__4__$kgyF7X0vQAeoGY79WFpAXw; + $main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__1: + assume {:captureState "$main$__3__$BQu4h3vlSRawGkdd3zg0DQ$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__6__$ScgHlHhCS1WcMwxSLBCjog, $main$__3__$BQu4h3vlSRawGkdd3zg0DQ_goto_$main$__4__$kgyF7X0vQAeoGY79WFpAXw; + $main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ: + assume {:captureState "$main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ"} true; + assume (R8[1:0] == 1bv1); + goto $main$__3__$BQu4h3vlSRawGkdd3zg0DQ; + $main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__1__$XR5j_yKuQR24HXECGUTTaw: + assume {:captureState "$main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__1__$XR5j_yKuQR24HXECGUTTaw"} true; + assume (!(R8[1:0] == 1bv1)); + goto $main$__1__$XR5j_yKuQR24HXECGUTTaw; + $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__0: + assume {:captureState "$main$__0__$T93CJsvjRiGkLGM3lm~zUw$__0"} true; + assume (ZF == 1bv1); + R8, Gamma_R8 := 0bv64, true; + assert Gamma_R8; + goto $main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ, $main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__1__$XR5j_yKuQR24HXECGUTTaw; + $main$__0__$T93CJsvjRiGkLGM3lm~zUw$__1: + assume {:captureState "$main$__0__$T93CJsvjRiGkLGM3lm~zUw$__1"} true; + assume (!(ZF == 1bv1)); + R8, Gamma_R8 := 1bv64, true; + assert Gamma_R8; + goto $main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__3__$BQu4h3vlSRawGkdd3zg0DQ, $main$__0__$T93CJsvjRiGkLGM3lm~zUw_goto_$main$__1__$XR5j_yKuQR24HXECGUTTaw; main_basil_return: - R0_out, R31_out, R8_out, R9_out := R0_2, bvadd64(R31_29, 32bv64), R8_40, R9_28; - Gamma_R0_out, Gamma_R31_out, Gamma_R8_out, Gamma_R9_out := Gamma_R0_2, Gamma_R31_29, Gamma_R8_40, Gamma_R9_28; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/nestedifglobal/gcc/nestedifglobal.expected b/src/test/incorrect/nestedifglobal/gcc/nestedifglobal.expected index a0f236369..ef127f1d9 100644 --- a/src/test/incorrect/nestedifglobal/gcc/nestedifglobal.expected +++ b/src/test/incorrect/nestedifglobal/gcc/nestedifglobal.expected @@ -1,31 +1,38 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,23 +43,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -60,8 +62,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -74,87 +76,131 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R1, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1956bv64) == 1bv8); - free requires (memory_load8_le(mem, 1957bv64) == 0bv8); - free requires (memory_load8_le(mem, 1958bv64) == 2bv8); - free requires (memory_load8_le(mem, 1959bv64) == 0bv8); + free requires (memory_load32_le(mem, 1956bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1956bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1957bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1958bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1959bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1956bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_12: bool; - var Gamma_R0_15: bool; - var Gamma_R0_6: bool; - var Gamma_R1_1: bool; - var R0_10: bv32; - var R0_12: bv32; - var R0_15: bv32; - var R0_6: bv32; - var R1_1: bv64; + var #4: bv32; + var #5: bv32; + var #6: bv32; + var Gamma_#4: bool; + var Gamma_#5: bool; + var Gamma_#6: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - R1_1, Gamma_R1_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000332"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, 69652bv64) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, 69652bv64, R1_1[32:0]), gamma_store32(Gamma_mem, 69652bv64, Gamma_R1_1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000034c"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%00000353"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000381, lmain_goto_l00000414; - lmain_goto_l00000414: - assume (R0_6 == 0bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - goto l00000381; - lmain_goto_l00000381: - assume (!(R0_6 == 0bv32)); + l00000414: + assume {:captureState "l00000414"} true; + R0, Gamma_R0 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000041f"} true; goto l00000381; l00000381: + assume {:captureState "l00000381"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_10, Gamma_R0_10 := memory_load32_le(mem, 69652bv64), (gamma_load32(Gamma_mem, 69652bv64) || L(mem, 69652bv64)); - assert Gamma_R0_10; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #5, Gamma_#5 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#5); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#5, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967295bv33))), (Gamma_R0 && Gamma_#5); + ZF, Gamma_ZF := bvcomp32(bvadd32(#5, 1bv32), 0bv32), Gamma_#5; + NF, Gamma_NF := bvadd32(#5, 1bv32)[32:31], Gamma_#5; + assert Gamma_ZF; goto l00000381_goto_l000003b2, l00000381_goto_l00000407; - l00000381_goto_l00000407: - assume (R0_10 == 1bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 5bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - goto l000003b2; - l00000381_goto_l000003b2: - assume (!(R0_10 == 1bv32)); + l00000407: + assume {:captureState "l00000407"} true; + R0, Gamma_R0 := 5bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000412"} true; goto l000003b2; l000003b2: - R0_12, Gamma_R0_12 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - assert Gamma_R0_12; + assume {:captureState "l000003b2"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + #6, Gamma_#6 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#6); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#6, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967293bv33))), (Gamma_R0 && Gamma_#6); + ZF, Gamma_ZF := bvcomp32(bvadd32(#6, 1bv32), 0bv32), Gamma_#6; + NF, Gamma_NF := bvadd32(#6, 1bv32)[32:31], Gamma_#6; + assert Gamma_ZF; goto l000003b2_goto_l000003d8, l000003b2_goto_l000003ed; - l000003b2_goto_l000003ed: - assume (R0_12 == 3bv32); + l000003ed: + assume {:captureState "l000003ed"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_15, Gamma_R0_15 := memory_load32_le(mem, 69656bv64), (gamma_load32(Gamma_mem, 69656bv64) || L(mem, 69656bv64)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_15), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_15); - goto l000003d8; - l000003b2_goto_l000003d8: - assume (!(R0_12 == 3bv32)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000405"} true; goto l000003d8; l000003d8: + assume {:captureState "l000003d8"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000381: + assume {:captureState "lmain_goto_l00000381"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000381; + lmain_goto_l00000414: + assume {:captureState "lmain_goto_l00000414"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000414; + l00000381_goto_l000003b2: + assume {:captureState "l00000381_goto_l000003b2"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l000003b2; + l00000381_goto_l00000407: + assume {:captureState "l00000381_goto_l00000407"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000407; + l000003b2_goto_l000003d8: + assume {:captureState "l000003b2_goto_l000003d8"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l000003d8; + l000003b2_goto_l000003ed: + assume {:captureState "l000003b2_goto_l000003ed"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l000003ed; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_1, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_1, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/nestedifglobal/gcc/nestedifglobal_gtirb.expected b/src/test/incorrect/nestedifglobal/gcc/nestedifglobal_gtirb.expected index 9e6306814..51b6b796d 100644 --- a/src/test/incorrect/nestedifglobal/gcc/nestedifglobal_gtirb.expected +++ b/src/test/incorrect/nestedifglobal/gcc/nestedifglobal_gtirb.expected @@ -1,31 +1,37 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -36,23 +42,18 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); @@ -60,8 +61,8 @@ procedure {:extern} rely(); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -74,133 +75,134 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R1, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 1964bv64) == 1bv8); - free requires (memory_load8_le(mem, 1965bv64) == 0bv8); - free requires (memory_load8_le(mem, 1966bv64) == 2bv8); - free requires (memory_load8_le(mem, 1967bv64) == 0bv8); + free requires (memory_load32_le(mem, 1964bv64) == 131073bv32); free requires (memory_load64_le(mem, 69016bv64) == 1808bv64); free requires (memory_load64_le(mem, 69024bv64) == 1728bv64); free requires (memory_load64_le(mem, 69616bv64) == 1812bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load8_le(mem, 1964bv64) == 1bv8); - free ensures (memory_load8_le(mem, 1965bv64) == 0bv8); - free ensures (memory_load8_le(mem, 1966bv64) == 2bv8); - free ensures (memory_load8_le(mem, 1967bv64) == 0bv8); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 1964bv64) == 131073bv32); free ensures (memory_load64_le(mem, 69016bv64) == 1808bv64); free ensures (memory_load64_le(mem, 69024bv64) == 1728bv64); free ensures (memory_load64_le(mem, 69616bv64) == 1812bv64); free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_12: bool; - var Gamma_R0_14: bool; - var Gamma_R0_15: bool; - var Gamma_R0_17: bool; - var Gamma_R0_18: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_9: bool; - var Gamma_R1_1: bool; - var Gamma_R1_10: bool; - var Gamma_R1_4: bool; - var Gamma_R1_7: bool; - var Gamma_R31_11: bool; - var Gamma_R31_2: bool; - var Gamma_R31_5: bool; - var Gamma_R31_8: bool; - var R0_10: bv64; - var R0_12: bv64; - var R0_14: bv64; - var R0_15: bv64; - var R0_17: bv64; - var R0_18: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_6: bv64; - var R0_9: bv64; - var R1_1: bv64; - var R1_10: bv64; - var R1_4: bv64; - var R1_7: bv64; - var R31_11: bv64; - var R31_2: bv64; - var R31_5: bv64; - var R31_8: bv64; + var Cse0__5$4$1: bv32; + var Cse0__5$5$3: bv32; + var Cse0__5$6$10: bv32; + var Gamma_Cse0__5$4$1: bool; + var Gamma_Cse0__5$5$3: bool; + var Gamma_Cse0__5$6$10: bool; $main$__0__$9yseNFkhTuK04TK0yW3DZQ: - R31_2, Gamma_R31_2 := bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); - R0_3, Gamma_R0_3 := 69652bv64, true; - R1_1, Gamma_R1_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); + assume {:captureState "$main$__0__$9yseNFkhTuK04TK0yW3DZQ"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1816$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R0_3) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, R0_3, R1_1[32:0]), gamma_store32(Gamma_mem, R0_3, Gamma_R1_1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R0_5, Gamma_R0_5 := 69652bv64, true; + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1832$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "1836$0"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_6, Gamma_R0_6 := zero_extend32_32(memory_load32_le(mem, R0_5)), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$6$10, Gamma_Cse0__5$6$10 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$6$10, Cse0__5$6$10)), Gamma_Cse0__5$6$10; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$6$10), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$6$10); + ZF, Gamma_ZF := bvcomp32(Cse0__5$6$10, 0bv32), Gamma_Cse0__5$6$10; + NF, Gamma_NF := Cse0__5$6$10[32:31], Gamma_Cse0__5$6$10; + assert Gamma_ZF; goto $main$__0__$9yseNFkhTuK04TK0yW3DZQ_goto_$main$__2__$yfXOQSPfSoG_R~3nzeQfBw, $main$__0__$9yseNFkhTuK04TK0yW3DZQ_goto_$main$__1__$hCnLZz43RxuSXmdEBY0pRw; - $main$__0__$9yseNFkhTuK04TK0yW3DZQ_goto_$main$__1__$hCnLZz43RxuSXmdEBY0pRw: - assume (R0_6[32:0] == 0bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R31_5, Gamma_R31_5 := R31_2, Gamma_R31_2; - R1_4, Gamma_R1_4 := R1_1, Gamma_R1_1; - goto $main$__2__$yfXOQSPfSoG_R~3nzeQfBw; - $main$__0__$9yseNFkhTuK04TK0yW3DZQ_goto_$main$__2__$yfXOQSPfSoG_R~3nzeQfBw: - assume (!(R0_6[32:0] == 0bv32)); - R31_5, Gamma_R31_5 := R31_2, Gamma_R31_2; - R1_4, Gamma_R1_4 := R1_1, Gamma_R1_1; + $main$__1__$hCnLZz43RxuSXmdEBY0pRw: + assume {:captureState "$main$__1__$hCnLZz43RxuSXmdEBY0pRw"} true; + R0, Gamma_R0 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1864$0"} true; goto $main$__2__$yfXOQSPfSoG_R~3nzeQfBw; $main$__2__$yfXOQSPfSoG_R~3nzeQfBw: - R0_9, Gamma_R0_9 := 69652bv64, true; + assume {:captureState "$main$__2__$yfXOQSPfSoG_R~3nzeQfBw"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); - R0_10, Gamma_R0_10 := zero_extend32_32(memory_load32_le(mem, R0_9)), (gamma_load32(Gamma_mem, R0_9) || L(mem, R0_9)); - assert Gamma_R0_10; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$5$3, Gamma_Cse0__5$5$3 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$5$3), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_Cse0__5$5$3); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$5$3), bvadd33(zero_extend1_32(R0[32:0]), 4294967295bv33))), (Gamma_R0 && Gamma_Cse0__5$5$3); + ZF, Gamma_ZF := bvcomp32(Cse0__5$5$3, 0bv32), Gamma_Cse0__5$5$3; + NF, Gamma_NF := Cse0__5$5$3[32:31], Gamma_Cse0__5$5$3; + assert Gamma_ZF; goto $main$__2__$yfXOQSPfSoG_R~3nzeQfBw_goto_$main$__4__$oqZU9BW6TP6kbuw3LSxXQA, $main$__2__$yfXOQSPfSoG_R~3nzeQfBw_goto_$main$__3__$9kAXtc8KTiCv7~xlE1Ofpg; - $main$__2__$yfXOQSPfSoG_R~3nzeQfBw_goto_$main$__3__$9kAXtc8KTiCv7~xlE1Ofpg: - assume (R0_10[32:0] == 1bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_5, 28bv64), 5bv32), gamma_store32(Gamma_stack, bvadd64(R31_5, 28bv64), true); - R31_8, Gamma_R31_8 := R31_5, Gamma_R31_5; - R1_7, Gamma_R1_7 := R1_4, Gamma_R1_4; - goto $main$__4__$oqZU9BW6TP6kbuw3LSxXQA; - $main$__2__$yfXOQSPfSoG_R~3nzeQfBw_goto_$main$__4__$oqZU9BW6TP6kbuw3LSxXQA: - assume (!(R0_10[32:0] == 1bv32)); - R31_8, Gamma_R31_8 := R31_5, Gamma_R31_5; - R1_7, Gamma_R1_7 := R1_4, Gamma_R1_4; + $main$__3__$9kAXtc8KTiCv7~xlE1Ofpg: + assume {:captureState "$main$__3__$9kAXtc8KTiCv7~xlE1Ofpg"} true; + R0, Gamma_R0 := 5bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1892$0"} true; goto $main$__4__$oqZU9BW6TP6kbuw3LSxXQA; $main$__4__$oqZU9BW6TP6kbuw3LSxXQA: - R0_12, Gamma_R0_12 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_8, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31_8, 28bv64)); - assert Gamma_R0_12; + assume {:captureState "$main$__4__$oqZU9BW6TP6kbuw3LSxXQA"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + Cse0__5$4$1, Gamma_Cse0__5$4$1 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$4$1), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_Cse0__5$4$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$4$1), bvadd33(zero_extend1_32(R0[32:0]), 4294967293bv33))), (Gamma_R0 && Gamma_Cse0__5$4$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$4$1, 0bv32), Gamma_Cse0__5$4$1; + NF, Gamma_NF := Cse0__5$4$1[32:31], Gamma_Cse0__5$4$1; + assert Gamma_ZF; goto $main$__4__$oqZU9BW6TP6kbuw3LSxXQA_goto_$main$__6__$dkXkbQHUTxKWR8e~2scKWw, $main$__4__$oqZU9BW6TP6kbuw3LSxXQA_goto_$main$__5__$NGQwXgNySXKcztP0lKywGA; - $main$__4__$oqZU9BW6TP6kbuw3LSxXQA_goto_$main$__5__$NGQwXgNySXKcztP0lKywGA: - assume (R0_12[32:0] == 3bv32); - R0_14, Gamma_R0_14 := 69656bv64, true; + $main$__5__$NGQwXgNySXKcztP0lKywGA: + assume {:captureState "$main$__5__$NGQwXgNySXKcztP0lKywGA"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_15, Gamma_R0_15 := zero_extend32_32(memory_load32_le(mem, R0_14)), (gamma_load32(Gamma_mem, R0_14) || L(mem, R0_14)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_8, 28bv64), R0_15[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_8, 28bv64), Gamma_R0_15); - R31_11, Gamma_R31_11 := R31_8, Gamma_R31_8; - R1_10, Gamma_R1_10 := R1_7, Gamma_R1_7; - goto $main$__6__$dkXkbQHUTxKWR8e~2scKWw; - $main$__4__$oqZU9BW6TP6kbuw3LSxXQA_goto_$main$__6__$dkXkbQHUTxKWR8e~2scKWw: - assume (!(R0_12[32:0] == 3bv32)); - R31_11, Gamma_R31_11 := R31_8, Gamma_R31_8; - R1_10, Gamma_R1_10 := R1_7, Gamma_R1_7; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1920$0"} true; goto $main$__6__$dkXkbQHUTxKWR8e~2scKWw; $main$__6__$dkXkbQHUTxKWR8e~2scKWw: - R0_17, Gamma_R0_17 := 69656bv64, true; + assume {:captureState "$main$__6__$dkXkbQHUTxKWR8e~2scKWw"} true; + R0, Gamma_R0 := 69632bv64, true; + R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); - R0_18, Gamma_R0_18 := zero_extend32_32(memory_load32_le(mem, R0_17)), (gamma_load32(Gamma_mem, R0_17) || L(mem, R0_17)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + $main$__4__$oqZU9BW6TP6kbuw3LSxXQA_goto_$main$__6__$dkXkbQHUTxKWR8e~2scKWw: + assume {:captureState "$main$__4__$oqZU9BW6TP6kbuw3LSxXQA_goto_$main$__6__$dkXkbQHUTxKWR8e~2scKWw"} true; + assume (!(ZF == 1bv1)); + goto $main$__6__$dkXkbQHUTxKWR8e~2scKWw; + $main$__4__$oqZU9BW6TP6kbuw3LSxXQA_goto_$main$__5__$NGQwXgNySXKcztP0lKywGA: + assume {:captureState "$main$__4__$oqZU9BW6TP6kbuw3LSxXQA_goto_$main$__5__$NGQwXgNySXKcztP0lKywGA"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__5__$NGQwXgNySXKcztP0lKywGA; + $main$__2__$yfXOQSPfSoG_R~3nzeQfBw_goto_$main$__4__$oqZU9BW6TP6kbuw3LSxXQA: + assume {:captureState "$main$__2__$yfXOQSPfSoG_R~3nzeQfBw_goto_$main$__4__$oqZU9BW6TP6kbuw3LSxXQA"} true; + assume (!(ZF == 1bv1)); + goto $main$__4__$oqZU9BW6TP6kbuw3LSxXQA; + $main$__2__$yfXOQSPfSoG_R~3nzeQfBw_goto_$main$__3__$9kAXtc8KTiCv7~xlE1Ofpg: + assume {:captureState "$main$__2__$yfXOQSPfSoG_R~3nzeQfBw_goto_$main$__3__$9kAXtc8KTiCv7~xlE1Ofpg"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__3__$9kAXtc8KTiCv7~xlE1Ofpg; + $main$__0__$9yseNFkhTuK04TK0yW3DZQ_goto_$main$__2__$yfXOQSPfSoG_R~3nzeQfBw: + assume {:captureState "$main$__0__$9yseNFkhTuK04TK0yW3DZQ_goto_$main$__2__$yfXOQSPfSoG_R~3nzeQfBw"} true; + assume (!(ZF == 1bv1)); + goto $main$__2__$yfXOQSPfSoG_R~3nzeQfBw; + $main$__0__$9yseNFkhTuK04TK0yW3DZQ_goto_$main$__1__$hCnLZz43RxuSXmdEBY0pRw: + assume {:captureState "$main$__0__$9yseNFkhTuK04TK0yW3DZQ_goto_$main$__1__$hCnLZz43RxuSXmdEBY0pRw"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__1__$hCnLZz43RxuSXmdEBY0pRw; main_basil_return: - R0_out, R1_out, R31_out := R0_18, R1_10, bvadd64(R31_11, 32bv64); - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := Gamma_R0_18, Gamma_R1_10, Gamma_R31_11; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/nestedifglobal/gcc_pic/nestedifglobal.expected b/src/test/incorrect/nestedifglobal/gcc_pic/nestedifglobal.expected index 2020a2fd3..eba786ea8 100644 --- a/src/test/incorrect/nestedifglobal/gcc_pic/nestedifglobal.expected +++ b/src/test/incorrect/nestedifglobal/gcc_pic/nestedifglobal.expected @@ -1,21 +1,32 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -25,11 +36,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,34 +47,29 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2020bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2021bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2022bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2023bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2020bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -80,107 +82,139 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R1, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 2020bv64) == 1bv8); - free requires (memory_load8_le(mem, 2021bv64) == 0bv8); - free requires (memory_load8_le(mem, 2022bv64) == 2bv8); - free requires (memory_load8_le(mem, 2023bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 2020bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 2020bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2021bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2022bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2023bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2020bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_12: bool; - var Gamma_R0_14: bool; - var Gamma_R0_15: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_9: bool; - var Gamma_R1_1: bool; - var R0_10: bv32; - var R0_12: bv32; - var R0_14: bv64; - var R0_15: bv32; - var R0_3: bv64; - var R0_5: bv64; - var R0_6: bv32; - var R0_9: bv64; - var R1_1: bv64; + var #4: bv32; + var #5: bv32; + var #6: bv32; + var Gamma_#4: bool; + var Gamma_#5: bool; + var Gamma_#6: bool; lmain: - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); + assume {:captureState "lmain"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000332"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); - R1_1, Gamma_R1_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R0_3) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, R0_3, R1_1[32:0]), gamma_store32(Gamma_mem, R0_3, Gamma_R1_1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000034d"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%00000354"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_6, Gamma_R0_6 := memory_load32_le(mem, R0_5), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#4); + ZF, Gamma_ZF := bvcomp32(bvadd32(#4, 1bv32), 0bv32), Gamma_#4; + NF, Gamma_NF := bvadd32(#4, 1bv32)[32:31], Gamma_#4; + assert Gamma_ZF; goto lmain_goto_l00000383, lmain_goto_l00000418; - lmain_goto_l00000418: - assume (R0_6 == 0bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - goto l00000383; - lmain_goto_l00000383: - assume (!(R0_6 == 0bv32)); + l00000418: + assume {:captureState "l00000418"} true; + R0, Gamma_R0 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000423"} true; goto l00000383; l00000383: + assume {:captureState "l00000383"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_9, Gamma_R0_9 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_10, Gamma_R0_10 := memory_load32_le(mem, R0_9), (gamma_load32(Gamma_mem, R0_9) || L(mem, R0_9)); - assert Gamma_R0_10; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + #5, Gamma_#5 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#5); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#5, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967295bv33))), (Gamma_R0 && Gamma_#5); + ZF, Gamma_ZF := bvcomp32(bvadd32(#5, 1bv32), 0bv32), Gamma_#5; + NF, Gamma_NF := bvadd32(#5, 1bv32)[32:31], Gamma_#5; + assert Gamma_ZF; goto l00000383_goto_l000003b5, l00000383_goto_l0000040b; - l00000383_goto_l0000040b: - assume (R0_10 == 1bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 5bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - goto l000003b5; - l00000383_goto_l000003b5: - assume (!(R0_10 == 1bv32)); + l0000040b: + assume {:captureState "l0000040b"} true; + R0, Gamma_R0 := 5bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000416"} true; goto l000003b5; l000003b5: - R0_12, Gamma_R0_12 := memory_load32_le(stack, bvadd64(R31_in, 18446744073709551612bv64)), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64)); - assert Gamma_R0_12; + assume {:captureState "l000003b5"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + #6, Gamma_#6 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#6); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#6, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967293bv33))), (Gamma_R0 && Gamma_#6); + ZF, Gamma_ZF := bvcomp32(bvadd32(#6, 1bv32), 0bv32), Gamma_#6; + NF, Gamma_NF := bvadd32(#6, 1bv32)[32:31], Gamma_#6; + assert Gamma_ZF; goto l000003b5_goto_l000003db, l000003b5_goto_l000003f0; - l000003b5_goto_l000003f0: - assume (R0_12 == 3bv32); + l000003f0: + assume {:captureState "l000003f0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_14, Gamma_R0_14 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_15, Gamma_R0_15 := memory_load32_le(mem, R0_14), (gamma_load32(Gamma_mem, R0_14) || L(mem, R0_14)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), R0_15), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), Gamma_R0_15); - goto l000003db; - l000003b5_goto_l000003db: - assume (!(R0_12 == 3bv32)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000409"} true; goto l000003db; l000003db: + assume {:captureState "l000003db"} true; + R0, Gamma_R0 := 0bv64, true; + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + lmain_goto_l00000383: + assume {:captureState "lmain_goto_l00000383"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l00000383; + lmain_goto_l00000418: + assume {:captureState "lmain_goto_l00000418"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l00000418; + l00000383_goto_l000003b5: + assume {:captureState "l00000383_goto_l000003b5"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l000003b5; + l00000383_goto_l0000040b: + assume {:captureState "l00000383_goto_l0000040b"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l0000040b; + l000003b5_goto_l000003db: + assume {:captureState "l000003b5_goto_l000003db"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) != 0bv1); + goto l000003db; + l000003b5_goto_l000003f0: + assume {:captureState "l000003b5_goto_l000003f0"} true; + assume (bvnot1(bvcomp1(ZF, 1bv1)) == 0bv1); + goto l000003f0; main_basil_return: - R0_out, R1_out, R31_out := 0bv64, R1_1, R31_in; - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := true, Gamma_R1_1, Gamma_R31_in; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/incorrect/nestedifglobal/gcc_pic/nestedifglobal_gtirb.expected b/src/test/incorrect/nestedifglobal/gcc_pic/nestedifglobal_gtirb.expected index efb2272ad..8e445464f 100644 --- a/src/test/incorrect/nestedifglobal/gcc_pic/nestedifglobal_gtirb.expected +++ b/src/test/incorrect/nestedifglobal/gcc_pic/nestedifglobal_gtirb.expected @@ -1,21 +1,31 @@ +var {:extern} CF: bv1; +var {:extern} Gamma_CF: bool; +var {:extern} Gamma_NF: bool; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_VF: bool; +var {:extern} Gamma_ZF: bool; var {:extern} Gamma_mem: [bv64]bool; var {:extern} Gamma_stack: [bv64]bool; +var {:extern} NF: bv1; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} VF: bv1; +var {:extern} ZF: bv1; var {:extern} mem: [bv64]bv8; var {:extern} stack: [bv64]bv8; -function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(mem$in: [bv64]bv8, index: bv64) returns (bool) { false } +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvlshr"} bvlshr32(bv32, bv32) returns (bv32); -function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvsub"} bvsub64(bv64, bv64) returns (bv64); -function {:extern} {:bvbuiltin "bvule"} bvule64(bv64, bv64) returns (bool); -function {:extern} {:bvbuiltin "bvult"} bvult64(bv64, bv64) returns (bool); -function {:inline} byte_extract32_64(value: bv32, offset: bv64) returns (bv8) { - bvlshr32(value,bvmul64(offset,8bv64)[32:0])[8:0] -} - +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } @@ -25,11 +35,7 @@ function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool } function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then value else gammaMap[i]))) -} - -function {:inline} in_bounds64_le(base: bv64, len: bv64, i: bv64) returns (bool) { - (if bvule64(base, bvadd64(base, len)) then (bvule64(base, i) && bvult64(i, bvadd64(base, len))) else (bvule64(base, i) || bvult64(i, bvadd64(base, len)))) + gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { @@ -40,34 +46,29 @@ function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv6 (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { - memory[index] -} - function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { - (lambda i: bv64 :: ((if in_bounds64_le(index, 4bv64, i) then byte_extract32_64(value, bvsub64(i, index)) else memory[i]))) + memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); procedure {:extern} rely(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); - free ensures (memory_load8_le(mem, 2028bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2029bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2030bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2031bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + ensures (mem == old(mem)); + free ensures (memory_load32_le(mem, 2028bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); procedure {:extern} rely_transitive(); modifies Gamma_mem, mem; - ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); + ensures (mem == old(mem)); implementation {:extern} rely_transitive() { @@ -80,142 +81,143 @@ procedure {:extern} rely_reflexive(); procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; -procedure main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool); - modifies Gamma_mem, Gamma_stack, mem, stack; +procedure main(); + modifies CF, Gamma_CF, Gamma_NF, Gamma_R0, Gamma_R1, Gamma_R31, Gamma_VF, Gamma_ZF, Gamma_mem, Gamma_stack, NF, R0, R1, R31, VF, ZF, mem, stack; free requires (memory_load64_le(mem, 69632bv64) == 0bv64); free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load8_le(mem, 2028bv64) == 1bv8); - free requires (memory_load8_le(mem, 2029bv64) == 0bv8); - free requires (memory_load8_le(mem, 2030bv64) == 2bv8); - free requires (memory_load8_le(mem, 2031bv64) == 0bv8); - free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); - free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); - free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load32_le(mem, 2028bv64) == 131073bv32); + free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); free requires (memory_load64_le(mem, 69008bv64) == 1792bv64); free requires (memory_load64_le(mem, 69592bv64) == 69656bv64); - free requires (memory_load64_le(mem, 69000bv64) == 1872bv64); - free ensures (memory_load8_le(mem, 2028bv64) == 1bv8); - free ensures (memory_load8_le(mem, 2029bv64) == 0bv8); - free ensures (memory_load8_le(mem, 2030bv64) == 2bv8); - free ensures (memory_load8_le(mem, 2031bv64) == 0bv8); - free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); - free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); - free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69600bv64) == 69652bv64); + free requires (memory_load64_le(mem, 69616bv64) == 1876bv64); + free requires (memory_load64_le(mem, 69640bv64) == 69640bv64); + free ensures (Gamma_R31 == old(Gamma_R31)); + free ensures (R31 == old(R31)); + free ensures (memory_load32_le(mem, 2028bv64) == 131073bv32); + free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); free ensures (memory_load64_le(mem, 69008bv64) == 1792bv64); free ensures (memory_load64_le(mem, 69592bv64) == 69656bv64); - free ensures (memory_load64_le(mem, 69000bv64) == 1872bv64); + free ensures (memory_load64_le(mem, 69600bv64) == 69652bv64); + free ensures (memory_load64_le(mem, 69616bv64) == 1876bv64); + free ensures (memory_load64_le(mem, 69640bv64) == 69640bv64); -implementation main(R0_in: bv64, Gamma_R0_in: bool, R31_in: bv64, Gamma_R31_in: bool) returns (R0_out: bv64, Gamma_R0_out: bool, R1_out: bv64, Gamma_R1_out: bool, R31_out: bv64, Gamma_R31_out: bool) +implementation main() { - var Gamma_R0_10: bool; - var Gamma_R0_12: bool; - var Gamma_R0_14: bool; - var Gamma_R0_15: bool; - var Gamma_R0_17: bool; - var Gamma_R0_18: bool; - var Gamma_R0_3: bool; - var Gamma_R0_5: bool; - var Gamma_R0_6: bool; - var Gamma_R0_9: bool; - var Gamma_R1_1: bool; - var Gamma_R1_10: bool; - var Gamma_R1_4: bool; - var Gamma_R1_7: bool; - var Gamma_R31_11: bool; - var Gamma_R31_2: bool; - var Gamma_R31_5: bool; - var Gamma_R31_8: bool; - var R0_10: bv64; - var R0_12: bv64; - var R0_14: bv64; - var R0_15: bv64; - var R0_17: bv64; - var R0_18: bv64; - var R0_3: bv64; - var R0_5: bv64; - var R0_6: bv64; - var R0_9: bv64; - var R1_1: bv64; - var R1_10: bv64; - var R1_4: bv64; - var R1_7: bv64; - var R31_11: bv64; - var R31_2: bv64; - var R31_5: bv64; - var R31_8: bv64; + var Cse0__5$1$10: bv32; + var Cse0__5$3$1: bv32; + var Cse0__5$5$3: bv32; + var Gamma_Cse0__5$1$10: bool; + var Gamma_Cse0__5$3$1: bool; + var Gamma_Cse0__5$5$3: bool; $main$__0__$_4YKHPc_R16UBSwXbttMHg: - R31_2, Gamma_R31_2 := bvadd64(R31_in, 18446744073709551584bv64), Gamma_R31_in; - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551596bv64), R0_in[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64), Gamma_R0_in); + assume {:captureState "$main$__0__$_4YKHPc_R16UBSwXbttMHg"} true; + R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "1880$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_3, Gamma_R0_3 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); - R1_1, Gamma_R1_1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_in, 18446744073709551596bv64))), gamma_load32(Gamma_stack, bvadd64(R31_in, 18446744073709551596bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); + R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); - assert (L(mem, R0_3) ==> Gamma_R1_1); - mem, Gamma_mem := memory_store32_le(mem, R0_3, R1_1[32:0]), gamma_store32(Gamma_mem, R0_3, Gamma_R1_1); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); + assert (L(mem, R0) ==> Gamma_R1); + mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "1896$0"} true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "1900$0"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_5, Gamma_R0_5 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_6, Gamma_R0_6 := zero_extend32_32(memory_load32_le(mem, R0_5)), (gamma_load32(Gamma_mem, R0_5) || L(mem, R0_5)); - assert Gamma_R0_6; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$1$10, Gamma_Cse0__5$1$10 := bvadd32(R0[32:0], 0bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp32(Cse0__5$1$10, Cse0__5$1$10)), Gamma_Cse0__5$1$10; + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$1$10), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_Cse0__5$1$10); + ZF, Gamma_ZF := bvcomp32(Cse0__5$1$10, 0bv32), Gamma_Cse0__5$1$10; + NF, Gamma_NF := Cse0__5$1$10[32:31], Gamma_Cse0__5$1$10; + assert Gamma_ZF; goto $main$__0__$_4YKHPc_R16UBSwXbttMHg_goto_$main$__2__$suhWjK9FQk6egl8Kq7bkzA, $main$__0__$_4YKHPc_R16UBSwXbttMHg_goto_$main$__1__$JFpnTYKyQUOhK~aVMxMB9w; - $main$__0__$_4YKHPc_R16UBSwXbttMHg_goto_$main$__1__$JFpnTYKyQUOhK~aVMxMB9w: - assume (R0_6[32:0] == 0bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_in, 18446744073709551612bv64), 3bv32), gamma_store32(Gamma_stack, bvadd64(R31_in, 18446744073709551612bv64), true); - R31_5, Gamma_R31_5 := R31_2, Gamma_R31_2; - R1_4, Gamma_R1_4 := R1_1, Gamma_R1_1; - goto $main$__2__$suhWjK9FQk6egl8Kq7bkzA; - $main$__0__$_4YKHPc_R16UBSwXbttMHg_goto_$main$__2__$suhWjK9FQk6egl8Kq7bkzA: - assume (!(R0_6[32:0] == 0bv32)); - R31_5, Gamma_R31_5 := R31_2, Gamma_R31_2; - R1_4, Gamma_R1_4 := R1_1, Gamma_R1_1; + $main$__1__$JFpnTYKyQUOhK~aVMxMB9w: + assume {:captureState "$main$__1__$JFpnTYKyQUOhK~aVMxMB9w"} true; + R0, Gamma_R0 := 3bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1928$0"} true; goto $main$__2__$suhWjK9FQk6egl8Kq7bkzA; $main$__2__$suhWjK9FQk6egl8Kq7bkzA: + assume {:captureState "$main$__2__$suhWjK9FQk6egl8Kq7bkzA"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_9, Gamma_R0_9 := memory_load64_le(mem, 69600bv64), (gamma_load64(Gamma_mem, 69600bv64) || L(mem, 69600bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); - R0_10, Gamma_R0_10 := zero_extend32_32(memory_load32_le(mem, R0_9)), (gamma_load32(Gamma_mem, R0_9) || L(mem, R0_9)); - assert Gamma_R0_10; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + Cse0__5$5$3, Gamma_Cse0__5$5$3 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$5$3), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_Cse0__5$5$3); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$5$3), bvadd33(zero_extend1_32(R0[32:0]), 4294967295bv33))), (Gamma_R0 && Gamma_Cse0__5$5$3); + ZF, Gamma_ZF := bvcomp32(Cse0__5$5$3, 0bv32), Gamma_Cse0__5$5$3; + NF, Gamma_NF := Cse0__5$5$3[32:31], Gamma_Cse0__5$5$3; + assert Gamma_ZF; goto $main$__2__$suhWjK9FQk6egl8Kq7bkzA_goto_$main$__4__$pjW61HZrTOmndoem0ZAjmQ, $main$__2__$suhWjK9FQk6egl8Kq7bkzA_goto_$main$__3__$25~YyveSSxKjFiy3ZvDL7w; - $main$__2__$suhWjK9FQk6egl8Kq7bkzA_goto_$main$__3__$25~YyveSSxKjFiy3ZvDL7w: - assume (R0_10[32:0] == 1bv32); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_5, 28bv64), 5bv32), gamma_store32(Gamma_stack, bvadd64(R31_5, 28bv64), true); - R31_8, Gamma_R31_8 := R31_5, Gamma_R31_5; - R1_7, Gamma_R1_7 := R1_4, Gamma_R1_4; - goto $main$__4__$pjW61HZrTOmndoem0ZAjmQ; - $main$__2__$suhWjK9FQk6egl8Kq7bkzA_goto_$main$__4__$pjW61HZrTOmndoem0ZAjmQ: - assume (!(R0_10[32:0] == 1bv32)); - R31_8, Gamma_R31_8 := R31_5, Gamma_R31_5; - R1_7, Gamma_R1_7 := R1_4, Gamma_R1_4; + $main$__3__$25~YyveSSxKjFiy3ZvDL7w: + assume {:captureState "$main$__3__$25~YyveSSxKjFiy3ZvDL7w"} true; + R0, Gamma_R0 := 5bv64, true; + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1956$0"} true; goto $main$__4__$pjW61HZrTOmndoem0ZAjmQ; $main$__4__$pjW61HZrTOmndoem0ZAjmQ: - R0_12, Gamma_R0_12 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31_8, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31_8, 28bv64)); - assert Gamma_R0_12; + assume {:captureState "$main$__4__$pjW61HZrTOmndoem0ZAjmQ"} true; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); + Cse0__5$3$1, Gamma_Cse0__5$3$1 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; + VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(Cse0__5$3$1), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_Cse0__5$3$1); + CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(Cse0__5$3$1), bvadd33(zero_extend1_32(R0[32:0]), 4294967293bv33))), (Gamma_R0 && Gamma_Cse0__5$3$1); + ZF, Gamma_ZF := bvcomp32(Cse0__5$3$1, 0bv32), Gamma_Cse0__5$3$1; + NF, Gamma_NF := Cse0__5$3$1[32:31], Gamma_Cse0__5$3$1; + assert Gamma_ZF; goto $main$__4__$pjW61HZrTOmndoem0ZAjmQ_goto_$main$__6__$~1v8YRimTzWott7vgkSlCw, $main$__4__$pjW61HZrTOmndoem0ZAjmQ_goto_$main$__5__$7jJxdga~TUGdn0Pj55GVWw; - $main$__4__$pjW61HZrTOmndoem0ZAjmQ_goto_$main$__5__$7jJxdga~TUGdn0Pj55GVWw: - assume (R0_12[32:0] == 3bv32); + $main$__5__$7jJxdga~TUGdn0Pj55GVWw: + assume {:captureState "$main$__5__$7jJxdga~TUGdn0Pj55GVWw"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_14, Gamma_R0_14 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_15, Gamma_R0_15 := zero_extend32_32(memory_load32_le(mem, R0_14)), (gamma_load32(Gamma_mem, R0_14) || L(mem, R0_14)); - stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31_8, 28bv64), R0_15[32:0]), gamma_store32(Gamma_stack, bvadd64(R31_8, 28bv64), Gamma_R0_15); - R31_11, Gamma_R31_11 := R31_8, Gamma_R31_8; - R1_10, Gamma_R1_10 := R1_7, Gamma_R1_7; - goto $main$__6__$~1v8YRimTzWott7vgkSlCw; - $main$__4__$pjW61HZrTOmndoem0ZAjmQ_goto_$main$__6__$~1v8YRimTzWott7vgkSlCw: - assume (!(R0_12[32:0] == 3bv32)); - R31_11, Gamma_R31_11 := R31_8, Gamma_R31_8; - R1_10, Gamma_R1_10 := R1_7, Gamma_R1_7; + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "1984$0"} true; goto $main$__6__$~1v8YRimTzWott7vgkSlCw; $main$__6__$~1v8YRimTzWott7vgkSlCw: + assume {:captureState "$main$__6__$~1v8YRimTzWott7vgkSlCw"} true; + R0, Gamma_R0 := 65536bv64, true; call rely(); - R0_17, Gamma_R0_17 := memory_load64_le(mem, 69592bv64), (gamma_load64(Gamma_mem, 69592bv64) || L(mem, 69592bv64)); + R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); - R0_18, Gamma_R0_18 := zero_extend32_32(memory_load32_le(mem, R0_17)), (gamma_load32(Gamma_mem, R0_17) || L(mem, R0_17)); + R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); + R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; goto main_basil_return; + $main$__0__$_4YKHPc_R16UBSwXbttMHg_goto_$main$__2__$suhWjK9FQk6egl8Kq7bkzA: + assume {:captureState "$main$__0__$_4YKHPc_R16UBSwXbttMHg_goto_$main$__2__$suhWjK9FQk6egl8Kq7bkzA"} true; + assume (!(ZF == 1bv1)); + goto $main$__2__$suhWjK9FQk6egl8Kq7bkzA; + $main$__0__$_4YKHPc_R16UBSwXbttMHg_goto_$main$__1__$JFpnTYKyQUOhK~aVMxMB9w: + assume {:captureState "$main$__0__$_4YKHPc_R16UBSwXbttMHg_goto_$main$__1__$JFpnTYKyQUOhK~aVMxMB9w"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__1__$JFpnTYKyQUOhK~aVMxMB9w; + $main$__4__$pjW61HZrTOmndoem0ZAjmQ_goto_$main$__6__$~1v8YRimTzWott7vgkSlCw: + assume {:captureState "$main$__4__$pjW61HZrTOmndoem0ZAjmQ_goto_$main$__6__$~1v8YRimTzWott7vgkSlCw"} true; + assume (!(ZF == 1bv1)); + goto $main$__6__$~1v8YRimTzWott7vgkSlCw; + $main$__4__$pjW61HZrTOmndoem0ZAjmQ_goto_$main$__5__$7jJxdga~TUGdn0Pj55GVWw: + assume {:captureState "$main$__4__$pjW61HZrTOmndoem0ZAjmQ_goto_$main$__5__$7jJxdga~TUGdn0Pj55GVWw"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__5__$7jJxdga~TUGdn0Pj55GVWw; + $main$__2__$suhWjK9FQk6egl8Kq7bkzA_goto_$main$__4__$pjW61HZrTOmndoem0ZAjmQ: + assume {:captureState "$main$__2__$suhWjK9FQk6egl8Kq7bkzA_goto_$main$__4__$pjW61HZrTOmndoem0ZAjmQ"} true; + assume (!(ZF == 1bv1)); + goto $main$__4__$pjW61HZrTOmndoem0ZAjmQ; + $main$__2__$suhWjK9FQk6egl8Kq7bkzA_goto_$main$__3__$25~YyveSSxKjFiy3ZvDL7w: + assume {:captureState "$main$__2__$suhWjK9FQk6egl8Kq7bkzA_goto_$main$__3__$25~YyveSSxKjFiy3ZvDL7w"} true; + assume (!(!(ZF == 1bv1))); + goto $main$__3__$25~YyveSSxKjFiy3ZvDL7w; main_basil_return: - R0_out, R1_out, R31_out := R0_18, R1_10, bvadd64(R31_11, 32bv64); - Gamma_R0_out, Gamma_R1_out, Gamma_R31_out := Gamma_R0_18, Gamma_R1_10, Gamma_R31_11; + assume {:captureState "main_basil_return"} true; return; } diff --git a/src/test/scala/DataStructureAnalysisTest.scala b/src/test/scala/DataStructureAnalysisTest.scala new file mode 100644 index 000000000..80d848821 --- /dev/null +++ b/src/test/scala/DataStructureAnalysisTest.scala @@ -0,0 +1,532 @@ +import analysis.data_structure_analysis.* +import ir.* +import org.scalatest.funsuite.AnyFunSuite +import ir.dsl.* +import specification.Specification +import util.{BASILConfig, BASILResult, BoogieGeneratorConfig, ILLoadingConfig, IRContext, RunUtils, StaticAnalysisConfig, StaticAnalysisContext} + +/** + * This is the test suite for testing DSA functionality + * The tests follow a general pattern of running BASIL analyses on a test program + * and then asserting properties about the Data Structure Graph (DSG) of the function produced at + * different levels + * + * DSA has three phases. + * BASILRESULT.analysis.get.local is the set of graphs from the end of the local phase + * BASILRESULT.analysis.get.bu is the set of graphs from the end of the bottom-up phase + * BASILRESULT.analysis.get.td is the set of graphs from the end of the top-down phase + * + */ +class DataStructureAnalysisTest extends AnyFunSuite { + + def runAnalysis(program: Program): StaticAnalysisContext = { + cilvisitor.visit_prog(transforms.ReplaceReturns(), program) + transforms.addReturnBlocks(program) + cilvisitor.visit_prog(transforms.ConvertSingleReturn(), program) + + val emptySpec = Specification(Set(), Set(), Map(), List(), List(), List(), Set()) + val emptyContext = IRContext(List(), Set(), Set(), Set(), Map(), emptySpec, program) + RunUtils.staticAnalysis(StaticAnalysisConfig(), emptyContext) + } + + def runTest(path: String): BASILResult = { + RunUtils.loadAndTranslate( + BASILConfig( + loading = ILLoadingConfig( + inputFile = path + ".adt", + relfFile = path + ".relf", + specFile = None, + dumpIL = None, + ), + staticAnalysis = Some(StaticAnalysisConfig()), + boogieTranslation = BoogieGeneratorConfig(), + outputPrefix = "boogie_out", + ) + ) + } + + // Local DSA tests + /* + TODO - rewrite this test with a new input that is more suitable than the removed example + test("basic pointer") { + val results = RunUtils.loadAndTranslate( + BASILConfig( + loading = ILLoadingConfig( + inputFile = "examples/basicpointer/basicpointer.adt", + relfFile = "examples/basicpointer/basicpointer.relf", + specFile = None, + dumpIL = None, + ), + staticAnalysis = Some(StaticAnalysisConfig()), + boogieTranslation = BoogieGeneratorConfig(), + outputPrefix = "boogie_out", + ) + ) + val program = results.ir.program + + // the dsg of the main procedure after the local phase + val dsg = results.analysis.get.localDSA(program.mainProcedure) + + // dsg.formals(R29) is the slice representing formal R29 + val R29formal = dsg.adjust(dsg.formals(R29)) + + // cells representing the stack at various offsets + val stack0 = dsg.find(dsg.stackMapping(0).cells(0)) // R31 + val stack8 = dsg.find(dsg.stackMapping(8).cells(0)) // R31 + 8 + val stack40 = dsg.find(dsg.stackMapping(40).cells(0))// R31 + 40 + val stack32 = dsg.find(dsg.stackMapping(32).cells(0)) // R31 + 32 + val stack24 = dsg.find(dsg.stackMapping(24).cells(0)) // R31 + 24 and Malloc + + assert(dsg.adjust(stack0.getPointee).equals(R29formal)) // R31 points to the frame pointer + assert(dsg.adjust(stack8.getPointee).equals(dsg.adjust(dsg.formals(R30)))) // R31 + 8 points to the link register + + /* + Position 0000044F: tmp1 := R31 + 24 // Ev(tmp1) = new Node(R31 + 24).0 + implicit normalisation: tmp2 := R31 + 32 // Ev(tmp2) = new Node(R31 + 32).0 + Position 00000457: *tmp2 := tmp1 // merge(Ev(tmp1), E(Ev(tmp2))) + Therefore, Node(R31 + 32).0.pointee is merged with Node(R31 + 24).0, making E(Node(R31 + 32).0) == Node(R31 + 24).0 + at position 00000446 Ev(R0) == Malloc_Node == E(Node(R31 + 24).0) we have + mem := mem with [R31 + 0x20, el]:u64 <- R0 + *(R31 + 32) := R0 + merge(Ev(R0), E(Ev(R31+ 32)) + == merge(E(Node(R31 + 24).0), E(Node(R31 + 32).0)) + == merge(E(Node(R31 + 24).0), Node(R31 + 24).0) + which merges make the stack + 24 point to itself + */ + + // R31 + 32 points to R31 + 24, later set to point to heap but it should point to both ( + assert(dsg.adjust(stack32.getPointee).equals(stack24)) + assert(stack24.node.get.collapsed) // 00000497 collapses stack24 concatenation is currently unhandled, any objects referenced in an unhandled operation are collapsed + assert(dsg.adjust(stack24.getPointee).equals(stack24)) // 00000466, R31 + 32 and R31 + 24 pointees are merged + + // __stack_chk_guard's pointee is also pointed to by stack40 + assert(dsg.find(dsg.adjust(stack40.getPointee)).equals(dsg.find(dsg.adjust(dsg.find(dsg.adjust(dsg.globalMapping(AddressRange(69600, 69600)).node.cells(0).getPointee)).getPointee)))) + + } + */ + + // this function asserts universal properties about global objects in Jumptable2 example + def assertJumptable2Globals(dsg: Graph): Unit = { + // global mappings + + // jump_table relocation + assert(dsg.adjust(dsg.globalMapping(AddressRange(69624, 69624 + 8)).node.cells(0).getPointee).equals(dsg.find(dsg.globalMapping(AddressRange(69656, 69656 + 24)).node.cells(0)))) + // add_two relocation + assert(dsg.adjust(dsg.globalMapping(AddressRange(69656, 69656 + 24)).node.cells(0).getPointee).equals(dsg.find(dsg.globalMapping(AddressRange(1940, 1940 + 36)).node.cells(0)))) + // add_six relocation + assert(dsg.adjust(dsg.globalMapping(AddressRange(69656, 69656 + 24)).node.cells(8).getPointee).equals(dsg.find(dsg.globalMapping(AddressRange(1976, 1976 + 36)).node.cells(0)))) + // sub_seven relocation + assert(dsg.adjust(dsg.globalMapping(AddressRange(69656, 69656 + 24)).node.cells(16).getPointee).equals(dsg.find(dsg.globalMapping(AddressRange(2012, 2012 + 36)).node.cells(0)))) + // main relocation + assert(dsg.adjust(dsg.globalMapping(AddressRange(69608, 69608 + 8)).node.cells(0).getPointee).equals(dsg.find(dsg.globalMapping(AddressRange(2048, 2048 + 76)).node.cells(0)))) + // x relocation + assert(dsg.adjust(dsg.globalMapping(AddressRange(69592, 69592 + 8)).node.cells(0).getPointee).equals(dsg.find(dsg.globalMapping(AddressRange(69648, 69648 + 4)).node.cells(0)))) + } + + test("local jumptable2 callees") { + val results = runTest("src/test/indirect_calls/jumptable2/gcc_pic/jumptable2") + + val program = results.ir.program + // test that all three callees have the same local graph + val callees = Set("sub_seven", "add_two", "add_six") + val procs = program.nameToProcedure + + callees.foreach { callee => + val dsg = results.analysis.get.localDSA(procs(callee)) + assert(dsg.stackMapping.isEmpty) // stack is not used in either callee + assertJumptable2Globals(dsg) // globals should be the same everywhere unused in callees + // x should point to a collapsed object, in all 3 functions + // all three load value of x + // the analysis doesn't know if x is a pointer or not therefore assumes it is for soundness + // arbitrary pointer is used in arithmetic causing collapse + assert(dsg.adjust(dsg.find(dsg.globalMapping(AddressRange(69648, 69648 + 4)).node.cells(0)).getPointee).node.get.collapsed) + } + } + + test("local jumptable2 main") { + val results = runTest("src/test/indirect_calls/jumptable2/gcc_pic/jumptable2") + + val program = results.ir.program + val dsg = results.analysis.get.localDSA(program.mainProcedure) + val stack0 = dsg.find(dsg.stackMapping(0).cells(0)) + val stack8 = dsg.find(dsg.stackMapping(8).cells(0)) + val stack16 = dsg.find(dsg.stackMapping(16).cells(0)) + val stack28 = dsg.find(dsg.stackMapping(28).cells(0)) + assert(dsg.adjust(stack0.getPointee).equals(dsg.adjust(dsg.formals(R29)))) + assert(dsg.adjust(stack8.getPointee).equals(dsg.adjust(dsg.formals(R30)))) + assert(dsg.adjust(stack16.getPointee).equals(dsg.adjust(dsg.formals(R1)))) // input args + assert(dsg.adjust(stack28.getPointee).equals(dsg.adjust(dsg.formals(R0)))) // input args + + // initial global mappings + assertJumptable2Globals(dsg) + + // x should not be collapsed in the main function's local graph + assert(!dsg.find(dsg.globalMapping(AddressRange(69648, 69648 + 4)).node.cells(0)).getPointee.node.collapsed) + } + + test("unsafe pointer arithmetic") { + val results = runTest("src/test/dsa/unsafe_pointer_arithmetic/unsafe_pointer_arithmetic") + + val program = results.ir.program + val dsg = results.analysis.get.localDSA(program.mainProcedure) + + // stackX is the pointee of stack object at position X instead of the stack object itself + val stack0 = dsg.adjust(dsg.find(dsg.stackMapping(0).cells(0)).getPointee) + val stack8 = dsg.adjust(dsg.find(dsg.stackMapping(8).cells(0)).getPointee) + val stack24 = dsg.adjust(dsg.find(dsg.stackMapping(24).cells(0)).getPointee) + val stack32 = dsg.adjust(dsg.find(dsg.stackMapping(32).cells(0)).getPointee) + val stack40 = dsg.adjust(dsg.find(dsg.stackMapping(40).cells(0)).getPointee) + val stack48 = dsg.adjust(dsg.find(dsg.stackMapping(48).cells(0)).getPointee) + val stack56 = dsg.adjust(dsg.find(dsg.stackMapping(56).cells(0)).getPointee) + + assert(stack0.equals(dsg.adjust(dsg.formals(R29)))) + assert(stack8.equals(dsg.adjust(dsg.formals(R30)))) + + // stack24 and stack32 should point to the beginning of first Malloc (size 20) + assert(stack24.equals(stack32)) + assert(stack24.offset == 0) + assert(stack24.node.get.allocationRegions.size == 1) + assert(stack24.node.get.allocationRegions.head.asInstanceOf[HeapLocation].size == 20) + + // stack24 and stack40 should be pointing to the same cell at different internal offsets + val unadjustedStack24Pointee = dsg.find(dsg.stackMapping(24).cells(0)).getPointee + val unadjustedStack40Pointee = dsg.find(dsg.stackMapping(40).cells(0)).getPointee + assert(unadjustedStack24Pointee.cell.equals(unadjustedStack40Pointee.cell)) + assert(unadjustedStack40Pointee.internalOffset == 1) // result of unsafe pointer arithmetic + assert(unadjustedStack24Pointee.internalOffset == 0) + assert(unadjustedStack24Pointee.offset == 0) + + // stack48 points to second malloc (size 8) + assert(stack48.node.get.allocationRegions.size == 1) + assert(stack48.node.get.allocationRegions.head.asInstanceOf[HeapLocation].size == 8) + + // stack 48 points to a malloc address which point to the pointee of stack40 and stack56 + assert(dsg.adjust(stack48.getPointee).equals(stack40)) + assert(dsg.adjust(stack48.getPointee).equals(stack56)) + } + + test("interproc pointer arithmetic main") { + val results = runTest("src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic") + val program = results.ir.program + val dsg = results.analysis.get.localDSA(program.mainProcedure) + val stack0 = dsg.adjust(dsg.find(dsg.stackMapping(0).cells(0)).getPointee) + val stack8 = dsg.adjust(dsg.find(dsg.stackMapping(8).cells(0)).getPointee) + val stack24 = dsg.adjust(dsg.find(dsg.stackMapping(24).cells(0)).getPointee) + val stack32 = dsg.adjust(dsg.find(dsg.stackMapping(32).cells(0)).getPointee) + val stack40 = dsg.adjust(dsg.find(dsg.stackMapping(40).cells(0)).getPointee) + + assert(stack0.equals(dsg.adjust(dsg.formals(R29)))) + assert(stack8.equals(dsg.adjust(dsg.formals(R30)))) + + // stack24 and 32 point to different offsets of the same node + assert(stack24.node.get.equals(stack32.node.get)) + assert(stack24.offset == 0) + assert(stack32.offset == 16) + + // stack40 points to a different offset of stack24's node but the analysis can't determine that in the local phase + assert(stack40.pointee.isDefined) + assert(!stack40.node.get.equals(stack24.node.get)) + } + + test("interproc pointer arithmetic callee") { + val results = runTest("src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic") + val program = results.ir.program + val dsg = results.analysis.get.localDSA(program.nameToProcedure("callee")) + val stack8 = dsg.adjust(dsg.find(dsg.stackMapping(8).cells(0)).getPointee) + val stack24 = dsg.adjust(dsg.find(dsg.stackMapping(24).cells(0)).getPointee) + + // stack8 points to the formal argument object + assert(stack8.equals(dsg.adjust(dsg.formals(R0)))) + assert(stack8.offset == 0) + // stack 24 points to the formal argument object at offset 16, instead + assert(stack24.equals(dsg.adjust(dsg.formals(R0)).node.get.cells(16))) + } + + + test("internal merge") { + // this is an internal merge (two cells of the same node overlap and are merged together) + val mem = SharedMemory("mem", 64, 8) + val locAssign1 = LocalAssign(R6, BinaryExpr(BVADD, R0, BitVecLiteral(4, 64)), Some("00001")) + val locAssign2 = LocalAssign(R7, BinaryExpr(BVADD, R0, BitVecLiteral(5, 64)), Some("00002")) + val program = prog( + proc("main", + block("operations", + locAssign1, // R6 = R0 + 4 + locAssign2, // R7 = R0 + 5 + MemoryStore(mem, R7, R1, Endian.BigEndian, 64, Some("00003")), // *R7 = R1, (*R6 + 1) = R1 + MemoryStore(mem, R6, R2, Endian.BigEndian, 64, Some("00004")), // *R6 = R2 + ret + ) + ) + ) + + val results = runAnalysis(program) + + val dsg: Graph = results.localDSA(program.mainProcedure) + + // R6 and R7 address the same cell (overlapping cells in the same node that are merged) + assert(dsg.find(dsg.varToCell(locAssign1)(R6)).cell.equals(dsg.find(dsg.varToCell(locAssign2)(R7)).cell)) + + // outgoing edges of R6 and R7 are unified since the cells are merged + // object of formals R1 and R2 are written to overlapping fields of the same node (R6, R7); causing them to be merged together + assert(dsg.adjust(dsg.formals(R1)).equals(dsg.adjust(dsg.formals(R2)))) + // however, they address different internal offets in those cells + assert(dsg.find(dsg.varToCell(locAssign1)(R6)).internalOffset == 0) + assert(dsg.find(dsg.varToCell(locAssign2)(R7)).internalOffset == 1) + + // Since R6 and R7 are pointing to the same cell (R1 and R2) + // R6 (or R7)'s pointee should be the same as R1 and R2 + assert(dsg.adjust(dsg.varToCell(locAssign1)(R6)).pointee.isDefined) + assert(dsg.adjust(dsg.adjust(dsg.varToCell(locAssign1)(R6)).getPointee).equals(dsg.adjust(dsg.formals(R1)))) + } + + test("offsetting from middle of cell to a new cell") { + val mem = SharedMemory("mem", 64, 8) + val locAssign1 = LocalAssign(R6, BinaryExpr(BVADD, R0, BitVecLiteral(4, 64)), Some("00001")) + val locAssign2 = LocalAssign(R7, BinaryExpr(BVADD, R0, BitVecLiteral(5, 64)), Some("00002")) + val locAssign3 = LocalAssign(R5, BinaryExpr(BVADD, R7, BitVecLiteral(8, 64)), Some("00005")) + + val program = prog( + proc("main", + block("operations", + locAssign1, // R6 = R0 + 4 + locAssign2, // R7 = R0 + 5 + MemoryStore(mem, R7, R1, Endian.BigEndian, 64, Some("00003")), + MemoryStore(mem, R6, R2, Endian.BigEndian, 64, Some("00004")), + locAssign3, // R5 = R7 + 8 + ret + ) + ) + ) + + val results = runAnalysis(program) + val dsg: Graph = results.localDSA(program.mainProcedure) + // check that R5 points to separate cell at offset 13 + assert(dsg.find(dsg.varToCell(locAssign3)(R5)).offset == 13) + } + + test("offsetting from middle of cell to the same cell") { + // similar to above except instead of creating new cell the last assign + // points R5's cell at an internal offset of 8 + val mem = SharedMemory("mem", 64, 8) + val locAssign1 = LocalAssign(R6, BinaryExpr(BVADD, R0, BitVecLiteral(4, 64)), Some("00001")) + val locAssign2 = LocalAssign(R7, BinaryExpr(BVADD, R0, BitVecLiteral(5, 64)), Some("00002")) + val locAssign3 = LocalAssign(R5, BinaryExpr(BVADD, R7, BitVecLiteral(7, 64)), Some("00005")) + + val program = prog( + proc("main", + block("operations", + locAssign1, + locAssign2, + MemoryStore(mem, R7, R1, Endian.BigEndian, 64, Some("00003")), + MemoryStore(mem, R6, R2, Endian.BigEndian, 64, Some("00004")), + locAssign3, + ret + ) + ) + ) + + val results = runAnalysis(program) + val dsg: Graph = results.localDSA(program.mainProcedure) + assert(dsg.find(dsg.formals(R1)).equals(dsg.find(dsg.formals(R2)))) + assert(dsg.find(dsg.varToCell(locAssign1)(R6)).cell.equals(dsg.find(dsg.varToCell(locAssign2)(R7)).cell)) + assert(dsg.find(dsg.varToCell(locAssign1)(R6)).cell.equals(dsg.find(dsg.varToCell(locAssign3)(R5)).cell)) + assert(dsg.find(dsg.varToCell(locAssign1)(R6)).internalOffset == 0) + assert(dsg.find(dsg.varToCell(locAssign2)(R7)).internalOffset == 1) + assert(dsg.find(dsg.varToCell(locAssign3)(R5)).internalOffset == 8) + assert(dsg.find(dsg.varToCell(locAssign1)(R6)).cell.pointee.isDefined) + assert(dsg.find(dsg.find(dsg.varToCell(locAssign1)(R6)).cell.getPointee).equals(dsg.find(dsg.formals(R1)))) + } + + test("internal offset transfer") { + // this is a test to check assignments transfer internal offset of slices. + val mem = SharedMemory("mem", 64, 8) + val locAssign1 = LocalAssign(R6, BinaryExpr(BVADD, R0, BitVecLiteral(4, 64)), Some("00001")) + val locAssign2 = LocalAssign(R7, BinaryExpr(BVADD, R0, BitVecLiteral(5, 64)), Some("00002")) + val locAssign3 = LocalAssign(R5, R7, Some("00005")) + + val program = prog( + proc("main", + block("operations", + // Assign(R0, MemoryLoad(mem, R0, BigEndian, 0), Some("00000")), + locAssign1, + locAssign2, + MemoryStore(mem, R7, R1, Endian.BigEndian, 64, Some("00003")), + MemoryStore(mem, R6, R2, Endian.BigEndian, 64, Some("00004")), + locAssign3, + ret + ) + ) + ) + + val results = runAnalysis(program) + + val dsg: Graph = results.localDSA(program.mainProcedure) + assert(dsg.find(dsg.varToCell(locAssign2)(R7)).equals(dsg.find(dsg.varToCell(locAssign3)(R5)))) + } + + // bottom up tests + ignore("bottom up jumptable2 callees") { + // this is the same as local graphs + // nothing should be changed + // TODO count point-to relations and ensure no more constraints are added in this phase + val results = runTest("src/test/indirect_calls/jumptable2/gcc_pic/jumptable2") + + val program = results.ir.program + // test that all three callees have the same local graph + val callees = Set("sub_seven", "add_two", "add_six") + val procs = program.nameToProcedure + callees.foreach { callee => + val dsg = results.analysis.get.bottomUpDSA(procs(callee)) + assert(dsg.stackMapping.isEmpty) // stack is not used in either callee + assertJumptable2Globals(dsg) // globals should be the same everywhere unused in callees + // x should point to a collapsed object, in all 3 functions + // all three load value of x + // the analysis doesn't know if x is a pointer or not therefore assumes it is for soundness + // arbitrary pointer is used in arithmetic causing collapse + assert(dsg.adjust(dsg.find(dsg.globalMapping(AddressRange(69648, 69648 + 4)).node.cells(0)).getPointee).node.get.collapsed) + } + } + + test("bottom up jumptable2 main") { + val results = runTest("src/test/indirect_calls/jumptable2/gcc_pic/jumptable2") + val program = results.ir.program + val dsg = results.analysis.get.bottomUpDSA(program.mainProcedure) + + val framePointer = dsg.find(dsg.stackMapping(0).cells(0)) + val stack8 = dsg.find(dsg.stackMapping(8).cells(0)) + val stack16 = dsg.find(dsg.stackMapping(16).cells(0)) + val stack28 = dsg.find(dsg.stackMapping(28).cells(0)) + assert(dsg.adjust(framePointer.getPointee).equals(dsg.adjust(dsg.formals(R29)))) + assert(dsg.adjust(stack8.getPointee).equals(dsg.adjust(dsg.formals(R30)))) + assert(dsg.adjust(stack16.getPointee).equals(dsg.adjust(dsg.formals(R1)))) + assert(dsg.adjust(stack28.getPointee).equals(dsg.adjust(dsg.formals(R0)))) + + // initial global mappings + assertJumptable2Globals(dsg) + + // bottom-up x now should be collapsed since it was collapsed in callees + assert(dsg.find(dsg.globalMapping(AddressRange(69648, 69648 + 4)).node.cells(0)).getPointee.node.collapsed) + } + + ignore("bottom up interproc pointer arithmetic callee") { + // same as interproc pointer arithmetic callee's local graph (no changes should have been made) + val results = runTest("src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic") + val program = results.ir.program + val dsg = results.analysis.get.bottomUpDSA(program.nameToProcedure("callee")) + val stack8 = dsg.adjust(dsg.find(dsg.stackMapping(8).cells(0)).getPointee) + val stack24 = dsg.adjust(dsg.find(dsg.stackMapping(24).cells(0)).getPointee) + + assert(stack8.equals(dsg.adjust(dsg.formals(R0)))) + assert(stack8.offset == 0) + assert(stack24.equals(dsg.adjust(dsg.formals(R0)).node.get.cells(16))) + } + + test("bottom up interproc pointer arithmetic main") { + val results = runTest("src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic") + val program = results.ir.program + val dsg = results.analysis.get.bottomUpDSA(program.mainProcedure) + + val stack0 = dsg.adjust(dsg.find(dsg.stackMapping(0).cells(0)).getPointee) + val stack8 = dsg.adjust(dsg.find(dsg.stackMapping(8).cells(0)).getPointee) + val stack24 = dsg.adjust(dsg.find(dsg.stackMapping(24).cells(0)).getPointee) + val stack32 = dsg.adjust(dsg.find(dsg.stackMapping(32).cells(0)).getPointee) + val stack40 = dsg.adjust(dsg.find(dsg.stackMapping(40).cells(0)).getPointee) + + // same as the local graph with the difference that stack40 points to cell at + // a different of the same node as pointees of stack32 and stack24 + assert(stack0.equals(dsg.adjust(dsg.formals(R29)))) + assert(stack8.equals(dsg.adjust(dsg.formals(R30)))) + assert(stack24.node.get.equals(stack32.node.get)) + assert(stack24.offset == 0) + assert(stack32.offset == 16) + assert(stack40.pointee.isDefined) + assert(stack40.node.get.equals(stack24.node.get)) + assert(stack40.offset == 32) + assert(dsg.find(dsg.stackMapping(40).cells(0)).getPointee.internalOffset == 0) + assert(dsg.find(dsg.stackMapping(32).cells(0)).getPointee.internalOffset == 0) + assert(dsg.find(dsg.stackMapping(24).cells(0)).getPointee.internalOffset == 0) + } + + // top down tests + ignore("top down jumptable2 main") { + // no changes should be made from previous phase + val results = runTest("src/test/indirect_calls/jumptable2/gcc_pic/jumptable2") + val program = results.ir.program + val dsg = results.analysis.get.topDownDSA(program.mainProcedure) +// assert(dsg.pointTo.size == 13) // 13 + + val framePointer = dsg.find(dsg.stackMapping(0).cells(0)) + val stack8 = dsg.find(dsg.stackMapping(8).cells(0)) + val stack16 = dsg.find(dsg.stackMapping(16).cells(0)) + val stack28 = dsg.find(dsg.stackMapping(28).cells(0)) + assert(dsg.adjust(framePointer.getPointee).equals(dsg.adjust(dsg.formals(R29)))) + assert(dsg.adjust(stack8.getPointee).equals(dsg.adjust(dsg.formals(R30)))) + assert(dsg.adjust(stack16.getPointee).equals(dsg.adjust(dsg.formals(R1)))) + assert(dsg.adjust(stack28.getPointee).equals(dsg.adjust(dsg.formals(R0)))) + assertJumptable2Globals(dsg) + + // bottom-up + assert(dsg.find(dsg.globalMapping(AddressRange(69648, 69648 + 4)).node.cells(0)).getPointee.node.collapsed) + + } + + ignore("top down jumptable2 callees") { + val results = runTest("src/test/indirect_calls/jumptable2/gcc_pic/jumptable2") + + val program = results.ir.program + // test that all three callees have the same local graph + val callees = Set("sub_seven", "add_two", "add_six") + val procs = program.nameToProcedure + callees.foreach { callee => + val dsg = results.analysis.get.topDownDSA(procs(callee)) + assert(dsg.stackMapping.isEmpty) // stack is not used in either callee + assertJumptable2Globals(dsg) // globals should be the same everywhere unused in callees + // x should point to a collapsed object, in all 3 functions + // all three load value of x + // the analysis doesn't know if x is a pointer or not therefore assumes it is for soundness + // arbitrary pointer is used in arithmetic causing collapse + assert(dsg.adjust(dsg.find(dsg.globalMapping(AddressRange(69648, 69652)).node.cells(0)).getPointee).node.get.collapsed) + } + } + + test("top down interproc pointer arithmetic callee") { + val results = runTest("src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic") + val program = results.ir.program + val dsg = results.analysis.get.topDownDSA(program.nameToProcedure("callee")) + + val stack8 = dsg.adjust(dsg.find(dsg.stackMapping(8).cells(0)).getPointee) + val stack24 = dsg.adjust(dsg.find(dsg.stackMapping(24).cells(0)).getPointee) + + // callee should now have different offsets due to formal and actual input parameters being unified + assert(stack8.equals(dsg.adjust(dsg.formals(R0)))) + assert(stack8.offset == 16) + assert(stack24.equals(dsg.adjust(dsg.formals(R0)).node.get.cells(32))) + } + + // top-down phase should be the same as bottom-up phase + ignore("top down interproc pointer arithmetic main") { + val results = runTest("src/test/dsa/interproc_pointer_arithmetic/interproc_pointer_arithmetic") + val program = results.ir.program + val dsg = results.analysis.get.topDownDSA(program.mainProcedure) + + val stack0 = dsg.adjust(dsg.find(dsg.stackMapping(0).cells(0)).getPointee) + val stack8 = dsg.adjust(dsg.find(dsg.stackMapping(8).cells(0)).getPointee) + val stack24 = dsg.adjust(dsg.find(dsg.stackMapping(24).cells(0)).getPointee) + val stack32 = dsg.adjust(dsg.find(dsg.stackMapping(32).cells(0)).getPointee) + val stack40 = dsg.adjust(dsg.find(dsg.stackMapping(40).cells(0)).getPointee) + + assert(stack0.equals(dsg.adjust(dsg.formals(R29)))) + assert(stack8.equals(dsg.adjust(dsg.formals(R30)))) + assert(stack24.node.get.equals(stack32.node.get)) + assert(stack24.offset == 0) + assert(stack32.offset == 16) + assert(stack40.pointee.isDefined) + assert(stack40.node.get.equals(stack24.node.get)) + assert(stack40.offset == 32) + assert(dsg.find(dsg.stackMapping(40).cells(0)).getPointee.internalOffset == 0) + assert(dsg.find(dsg.stackMapping(32).cells(0)).getPointee.internalOffset == 0) + assert(dsg.find(dsg.stackMapping(24).cells(0)).getPointee.internalOffset == 0) + } + +} diff --git a/src/test/scala/IndirectCallsTests.scala b/src/test/scala/IndirectCallsTests.scala deleted file mode 100644 index d83a71e5d..000000000 --- a/src/test/scala/IndirectCallsTests.scala +++ /dev/null @@ -1,554 +0,0 @@ -import ir.* -import ir.Endian.LittleEndian -import org.scalatest.* -import org.scalatest.funsuite.* -import specification.* -import util.{BASILConfig, ILLoadingConfig, IRContext, RunUtils, StaticAnalysis, StaticAnalysisConfig, StaticAnalysisContext, BASILResult} -import boogie.SpecGlobal - -import java.io.IOException -import java.nio.file.* -import java.nio.file.attribute.BasicFileAttributes -import ir.dsl.* -import util.RunUtils.loadAndTranslate - -import scala.collection.mutable - -class IndirectCallsTests extends AnyFunSuite with OneInstancePerTest with BeforeAndAfter { - - private val tempPath = System.getProperty("user.dir") + "/src/test/analysis/dump/" - - before { - clearOrCreateDirectory(tempPath) - } - - def clearOrCreateDirectory(path: String): Unit = { - val directory = Paths.get(path) - if (Files.exists(directory)) { - Files.walkFileTree(directory, new SimpleFileVisitor[Path] { - override def visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult = { - Files.delete(file) - FileVisitResult.CONTINUE - } - - override def postVisitDirectory(dir: Path, exc: IOException): FileVisitResult = { - Files.delete(dir) - FileVisitResult.CONTINUE - } - }) - } - Files.createDirectories(directory) - } - - def runAnalyses(program: Program, - externalFunctions: Set[ExternalFunction] = Set.empty, - globals: Set[SpecGlobal] = Set.empty, - globalOffsets: Map[BigInt, BigInt] = Map.empty): StaticAnalysisContext = { - - val ctx = IRContext(List.empty, externalFunctions, globals, globalOffsets, Specification(Set(), Map(), List(), List(), List(), Set()), program) - StaticAnalysis.analyse(ctx, StaticAnalysisConfig(), 1) - } - - test("indirect_call_example") { - val testName = "indirect_call" - val examplePath = System.getProperty("user.dir") + s"/examples/$testName/" - val basilConfig = BASILConfig( - loading = ILLoadingConfig(inputFile = examplePath + testName + ".adt", - relfFile = examplePath + testName + ".relf", - dumpIL = Some(tempPath + testName), - ), - outputPrefix = tempPath + testName, - staticAnalysis = Some(StaticAnalysisConfig(None, None, None)), - ) - val result = loadAndTranslate(basilConfig) - /* in this example we must find: - -- IndirectCall to R1 (print function) - ++ DirectCall to puts - - -- IndirectCall to R0 (green function) - ++ DirectCall to greet - */ - val expectedCallTransform = mutable.Map( - "%000003ad" -> ("puts", "R1"), - "%000003bc" -> ("greet", "R0") - ) - - - // Traverse the statements in the main function - result.ir.program.mainProcedure.blocks.foreach { - block => - block.statements.lastOption match { - case Some(directCall: DirectCall) if expectedCallTransform.contains(directCall.label.getOrElse("")) => - val callTransform = expectedCallTransform(directCall.label.getOrElse("")) - assert(callTransform._1 == directCall.target.name) - expectedCallTransform.remove(directCall.label.getOrElse("")) - case _ => - } - } - assert(expectedCallTransform.isEmpty) - } - - test("indirect_call_gcc_example") { - val testName = "indirect_call" - val examplePath = System.getProperty("user.dir") + s"/src/test/correct/$testName/gcc/" - val basilConfig = BASILConfig( - loading = ILLoadingConfig(inputFile = examplePath + testName + ".adt", - relfFile = examplePath + testName + ".relf", - dumpIL = Some(tempPath + testName), - ), - outputPrefix = tempPath + testName, - staticAnalysis = Some(StaticAnalysisConfig(None, None, None)), - ) - val result = loadAndTranslate(basilConfig) - /* in this example we must find: - (print function pre-resolved by compiler) - - -- IndirectCall to R0 (green function) - ++ DirectCall to greet - */ - val expectedCallTransform = mutable.Map( - "%00000392" -> ("greet", "R0") - ) - - - // Traverse the statements in the main function - result.ir.program.mainProcedure.blocks.foreach { - block => - block.statements.lastOption match { - case Some(directCall: DirectCall) if expectedCallTransform.contains(directCall.label.getOrElse("")) => - val callTransform = expectedCallTransform(directCall.label.getOrElse("")) - assert(callTransform._1 == directCall.target.name) - expectedCallTransform.remove(directCall.label.getOrElse("")) - case _ => - } - } - assert(expectedCallTransform.isEmpty) - } - - test("indirect_call_clang_example") { - val testName = "indirect_call" - val examplePath = System.getProperty("user.dir") + s"/src/test/correct/$testName/clang/" - val basilConfig = BASILConfig( - loading = ILLoadingConfig(inputFile = examplePath + testName + ".adt", - relfFile = examplePath + testName + ".relf", - dumpIL = Some(tempPath + testName), - ), - outputPrefix = tempPath + testName, - staticAnalysis = Some(StaticAnalysisConfig(None, None, None)), - ) - val result = loadAndTranslate(basilConfig) - /* in this example we must find: - (print function pre-resolved by compiler) - - -- IndirectCall to R8 (green function) - ++ DirectCall to greet - */ - val expectedCallTransform = mutable.Map( - "%000003b6" -> ("greet", "R8") - ) - - - // Traverse the statements in the main function - result.ir.program.mainProcedure.blocks.foreach { - block => - block.statements.lastOption match { - case Some(directCall: DirectCall) if expectedCallTransform.contains(directCall.label.getOrElse("")) => - val callTransform = expectedCallTransform(directCall.label.getOrElse("")) - assert(callTransform._1 == directCall.target.name) - expectedCallTransform.remove(directCall.label.getOrElse("")) - case _ => - } - } - assert(expectedCallTransform.isEmpty) - } - - test("jumptable2_example") { - val testName = "jumptable2" - val examplePath = System.getProperty("user.dir") + s"/examples/$testName/" - val basilConfig = BASILConfig( - loading = ILLoadingConfig(inputFile = examplePath + testName + ".adt", - relfFile = examplePath + testName + ".relf", - dumpIL = Some(tempPath + testName), - ), - outputPrefix = tempPath + testName, - staticAnalysis = Some(StaticAnalysisConfig(None, None, None)), - ) - val result = loadAndTranslate(basilConfig) - /* in this example we must find: - -- IndirectCall to R0 %000004f7 - ++ DirectCall to add_two - - -- IndirectCall to R0 %00000512 - ++ DirectCall to add_six - - -- IndirectCall to R0 %0000052d - ++ DirectCall to sub_seven - */ - val expectedCallTransform = mutable.Map( - "%000004f7" -> ("add_two", "R0"), - "%00000512" -> ("add_six", "R0"), - "%0000052d" -> ("sub_seven", "R0") - ) - - - // Traverse the statements in the main function - result.ir.program.mainProcedure.blocks.foreach { - block => - block.statements.lastOption match { - case Some(directCall: DirectCall) if expectedCallTransform.contains(directCall.label.getOrElse("")) => - val callTransform = expectedCallTransform(directCall.label.getOrElse("")) - assert(callTransform._1 == directCall.target.name) - expectedCallTransform.remove(directCall.label.getOrElse("")) - case _ => - } - } - assert(expectedCallTransform.isEmpty) - } - - test("jumptable2_gcc_example") { - val testName = "jumptable2" - val examplePath = System.getProperty("user.dir") + s"/src/test/correct/$testName/gcc/" - val basilConfig = BASILConfig( - loading = ILLoadingConfig(inputFile = examplePath + testName + ".adt", - relfFile = examplePath + testName + ".relf", - dumpIL = Some(tempPath + testName), - ), - outputPrefix = tempPath + testName, - staticAnalysis = Some(StaticAnalysisConfig(None, None, None)), - ) - val result = loadAndTranslate(basilConfig) - /* in this example we must find: - -- IndirectCall to R0 %0000043c - ++ DirectCall to add_two - - -- IndirectCall to R0 %00000456 - ++ DirectCall to add_six - - -- IndirectCall to R0 %00000470 - ++ DirectCall to sub_seven - */ - val expectedCallTransform = mutable.Map( - "%0000043c" -> ("add_two", "R0"), - "%00000456" -> ("add_six", "R0"), - "%00000470" -> ("sub_seven", "R0") - ) - - - // Traverse the statements in the main function - result.ir.program.mainProcedure.blocks.foreach { - block => - block.statements.lastOption match { - case Some(directCall: DirectCall) if expectedCallTransform.contains(directCall.label.getOrElse("")) => - val callTransform = expectedCallTransform(directCall.label.getOrElse("")) - assert(callTransform._1 == directCall.target.name) - expectedCallTransform.remove(directCall.label.getOrElse("")) - case _ => - } - } - assert(expectedCallTransform.isEmpty) - } - - test("jumptable2_clang_example") { - val testName = "jumptable2" - val examplePath = System.getProperty("user.dir") + s"/src/test/correct/$testName/clang/" - val basilConfig = BASILConfig( - loading = ILLoadingConfig(inputFile = examplePath + testName + ".adt", - relfFile = examplePath + testName + ".relf", - dumpIL = Some(tempPath + testName), - ), - outputPrefix = tempPath + testName, - staticAnalysis = Some(StaticAnalysisConfig(None, None, None)), - ) - val result = loadAndTranslate(basilConfig) - /* in this example we must find: - -- IndirectCall to R8 %00000420 - ++ DirectCall to add_two - - -- IndirectCall to R8 %00000436 - ++ DirectCall to add_six - - -- IndirectCall to R8 %0000044c - ++ DirectCall to sub_seven - */ - val expectedCallTransform = mutable.Map( - "%00000420" -> ("add_two", "R0"), - "%00000436" -> ("add_six", "R0"), - "%0000044c" -> ("sub_seven", "R0") - ) - - // Traverse the statements in the main function - result.ir.program.mainProcedure.blocks.foreach { - block => - block.statements.lastOption match { - case Some(directCall: DirectCall) if expectedCallTransform.contains(directCall.label.getOrElse("")) => - val callTransform = expectedCallTransform(directCall.label.getOrElse("")) - assert(callTransform._1 == directCall.target.name) - expectedCallTransform.remove(directCall.label.getOrElse("")) - case _ => - } - } - assert(expectedCallTransform.isEmpty) - } - - test("jumptable_example") { - val testName = "jumptable" - val examplePath = System.getProperty("user.dir") + s"/examples/$testName/" - val basilConfig = BASILConfig( - loading = ILLoadingConfig(inputFile = examplePath + testName + ".adt", - relfFile = examplePath + testName + ".relf", - dumpIL = Some(tempPath + testName), - ), - outputPrefix = tempPath + testName, - staticAnalysis = Some(StaticAnalysisConfig(None, None, None)), - ) - val result = loadAndTranslate(basilConfig) - /* in this example we must find: - -- IndirectCall to R0 %00000595 - ++ DirectCall to add_two - - -- IndirectCall to R0 %000005a4 - ++ DirectCall to add_six - - -- IndirectCall to R0 %000005b3 - ++ DirectCall to sub_seven - */ - val expectedCallTransform = mutable.Map( - "%00000595" -> ("add_two", "R0"), - "%000005a4" -> ("add_six", "R0"), - "%000005b3" -> ("sub_seven", "R0") - ) - - - // Traverse the statements in the main function - result.ir.program.mainProcedure.blocks.foreach { - block => - block.statements.lastOption match { - case Some(directCall: DirectCall) if expectedCallTransform.contains(directCall.label.getOrElse("")) => - val callTransform = expectedCallTransform(directCall.label.getOrElse("")) - assert(callTransform._1 == directCall.target.name) - expectedCallTransform.remove(directCall.label.getOrElse("")) - case _ => - } - } - assert(expectedCallTransform.isEmpty) - } - - test("functionpointer_example") { - val testName = "functionpointer" - val examplePath = System.getProperty("user.dir") + s"/examples/$testName/" - val basilConfig = BASILConfig( - loading = ILLoadingConfig(inputFile = examplePath + testName + ".adt", - relfFile = examplePath + testName + ".relf", - dumpIL = Some(tempPath + testName), - ), - outputPrefix = tempPath + testName, - staticAnalysis = Some(StaticAnalysisConfig(Some("functionpointer"), None, None)), - ) - val result = loadAndTranslate(basilConfig) - /* in this example we must find: - -- IndirectCall to R0 %00000503 - ++ DirectCall to set_six - ++ DirectCall to set_two - ++ DirectCall to set_seven - */ - val expectedCallTransform = mutable.Map( - "l000004f3set_six" -> ("set_six", "R0"), - "l000004f3set_two" -> ("set_two", "R0"), - "l000004f3set_seven" -> ("set_seven", "R0") - ) - - // Traverse the statements in the main function - result.ir.program.mainProcedure.blocks.foreach { - block => - block.statements.lastOption match { - case Some(directCall: DirectCall) if expectedCallTransform.contains(block.label) => - val callTransform = expectedCallTransform(block.label) - assert(callTransform._1 == directCall.target.name) - expectedCallTransform.remove(block.label) - case _ => - } - } - assert(expectedCallTransform.isEmpty) - } - - test("functionpointer_gcc_example") { - val testName = "functionpointer" - val examplePath = System.getProperty("user.dir") + s"/src/test/correct/$testName/gcc/" - val basilConfig = BASILConfig( - loading = ILLoadingConfig(inputFile = examplePath + testName + ".adt", - relfFile = examplePath + testName + ".relf", - dumpIL = Some(tempPath + testName), - ), - outputPrefix = tempPath + testName, - staticAnalysis = Some(StaticAnalysisConfig(None, None, None)), - ) - val result = loadAndTranslate(basilConfig) - /* in this example we must find: - -- IndirectCall to R0 %00000451 - ++ DirectCall to set_six - ++ DirectCall to set_two - ++ DirectCall to set_seven - */ - val expectedCallTransform = mutable.Map( - "l00000441set_six" -> ("set_six", "R0"), - "l00000441set_two" -> ("set_two", "R0"), - "l00000441set_seven" -> ("set_seven", "R0") - ) - - // Traverse the statements in the main function - result.ir.program.mainProcedure.blocks.foreach { - block => - block.statements.lastOption match { - case Some(directCall: DirectCall) if expectedCallTransform.contains(block.label) => - val callTransform = expectedCallTransform(block.label) - assert(callTransform._1 == directCall.target.name) - expectedCallTransform.remove(block.label) - case _ => - } - } - assert(expectedCallTransform.isEmpty) - } - - test("functionpointer_clang_example") { - val testName = "functionpointer" - val examplePath = System.getProperty("user.dir") + s"/src/test/correct/$testName/clang/" - val basilConfig = BASILConfig( - loading = ILLoadingConfig(inputFile = examplePath + testName + ".adt", - relfFile = examplePath + testName + ".relf", - dumpIL = Some(tempPath + testName), - ), - outputPrefix = tempPath + testName, - staticAnalysis = Some(StaticAnalysisConfig(None, None, None)), - ) - val result = loadAndTranslate(basilConfig) - /* in this example we must find: - -- IndirectCall to R8 %0000045d - ++ DirectCall to set_six - ++ DirectCall to set_two - ++ DirectCall to set_seven - */ - val expectedCallTransform = mutable.Map( - "l0000044dset_six" -> ("set_six", "R0"), - "l0000044dset_two" -> ("set_two", "R0"), - "l0000044dset_seven" -> ("set_seven", "R0") - ) - result.ir.program.mainProcedure.blocks.foreach { - block => - block.statements.lastOption match { - case Some(directCall: DirectCall) if expectedCallTransform.contains(block.label) => - val callTransform = expectedCallTransform(block.label) - assert(callTransform._1 == directCall.target.name) - expectedCallTransform.remove(block.label) - case _ => - } - } - - // Traverse the statements in the main function - assert(expectedCallTransform.isEmpty) - } - - test("arrays_example") { - val testName = "arrays" - val examplePath = System.getProperty("user.dir") + s"/examples/$testName/" - val basilConfig = BASILConfig( - loading = ILLoadingConfig(inputFile = examplePath + testName + ".adt", - relfFile = examplePath + testName + ".relf", - dumpIL = Some(tempPath + testName), - ), - outputPrefix = tempPath + testName, - staticAnalysis = Some(StaticAnalysisConfig(None, None, None)), - ) - val result = loadAndTranslate(basilConfig) - /* in this example we must find: - -- IndirectCall to R0 %00000662 - ++ DirectCall to __stack_chk_fail - */ - val expectedCallTransform = mutable.Map( - "%00000662" -> ("__stack_chk_fail", "R0"), - ) - - - // Traverse the statements in the main function - result.ir.program.mainProcedure.blocks.foreach { - block => - block.statements.lastOption match { - case Some(directCall: DirectCall) if expectedCallTransform.contains(directCall.label.getOrElse("")) => - val callTransform = expectedCallTransform(directCall.label.getOrElse("")) - assert(callTransform._1 == directCall.target.name) - expectedCallTransform.remove(directCall.label.getOrElse("")) - case _ => - } - } - assert(expectedCallTransform.isEmpty) - } - - test("arrays_simple_example") { - val testName = "arrays_simple" - val examplePath = System.getProperty("user.dir") + s"/examples/$testName/" - val basilConfig = BASILConfig( - loading = ILLoadingConfig(inputFile = examplePath + testName + ".adt", - relfFile = examplePath + testName + ".relf", - dumpIL = Some(tempPath + testName), - ), - outputPrefix = tempPath + testName, - staticAnalysis = Some(StaticAnalysisConfig(None, None, None)), - ) - val result = loadAndTranslate(basilConfig) - /* in this example we must find: - -- IndirectCall to R0 %00000607 - ++ DirectCall to __stack_chk_fail - */ - val expectedCallTransform = mutable.Map( - "%00000607" -> ("__stack_chk_fail", "R0"), - ) - - - // Traverse the statements in the main function - result.ir.program.mainProcedure.blocks.foreach { - block => - block.statements.lastOption match { - case Some(directCall: DirectCall) if expectedCallTransform.contains(directCall.label.getOrElse("")) => - val callTransform = expectedCallTransform(directCall.label.getOrElse("")) - assert(callTransform._1 == directCall.target.name) - expectedCallTransform.remove(directCall.label.getOrElse("")) - case _ => - } - } - assert(expectedCallTransform.isEmpty) - } - - test("function_got_example") { - val testName = "function_got" - val examplePath = System.getProperty("user.dir") + s"/examples/$testName/" - val basilConfig = BASILConfig( - loading = ILLoadingConfig(inputFile = examplePath + testName + ".adt", - relfFile = examplePath + testName + ".relf", - dumpIL = Some(tempPath + testName), - ), - outputPrefix = tempPath + testName, - staticAnalysis = Some(StaticAnalysisConfig(None, None, None)), - ) - val result = loadAndTranslate(basilConfig) - /* in this example we must find: - -- IndirectCall to R0 %000003ed - ++ DirectCall to get_two - */ - val expectedCallTransform = mutable.Map( - "%000003ed" -> ("get_two", "R0"), - ) - - - // Traverse the statements in the main function - result.ir.program.mainProcedure.blocks.foreach { - block => - block.statements.lastOption match { - case Some(directCall: DirectCall) if expectedCallTransform.contains(directCall.label.getOrElse("")) => - val callTransform = expectedCallTransform(directCall.label.getOrElse("")) - assert(callTransform._1 == directCall.target.name) - expectedCallTransform.remove(directCall.label.getOrElse("")) - case _ => - } - } - assert(expectedCallTransform.isEmpty) - } -} diff --git a/src/test/scala/InterpretTestConstProp.scala b/src/test/scala/InterpretTestConstProp.scala index d3a13afae..7385e6d9a 100644 --- a/src/test/scala/InterpretTestConstProp.scala +++ b/src/test/scala/InterpretTestConstProp.scala @@ -33,7 +33,7 @@ class ConstPropInterpreterValidate extends AnyFunSuite { ictx = IRTransform.doCleanup(ictx) val analysisres = RunUtils.staticAnalysis(StaticAnalysisConfig(None, None, None), ictx) - val breaks : List[BreakPoint] = analysisres.constPropResult.collect { + val breaks : List[BreakPoint] = analysisres.intraProcConstProp.collect { // convert analysis result to a list of breakpoints, each which evaluates an expression describing // the invariant inferred by the analysis (the assignment of registers) at a corresponding program point diff --git a/src/test/scala/IrreducibleLoop.scala b/src/test/scala/IrreducibleLoop.scala index adddf6064..bf52e1272 100644 --- a/src/test/scala/IrreducibleLoop.scala +++ b/src/test/scala/IrreducibleLoop.scala @@ -22,7 +22,7 @@ class IrreducibleLoop extends AnyFunSuite { def load(conf: ILLoadingConfig) : Program = { val bapProgram = IRLoading.loadBAP(conf.inputFile) - val (_, _, _, _, mainAddress) = IRLoading.loadReadELF(conf.relfFile, conf) + val (_, _, _, _, _, mainAddress) = IRLoading.loadReadELF(conf.relfFile, conf) val IRTranslator = BAPToIR(bapProgram, mainAddress) val IRProgram = IRTranslator.translate IRProgram diff --git a/src/test/scala/LiveVarsAnalysisTests.scala b/src/test/scala/LiveVarsAnalysisTests.scala index 2910b88cb..c3da7e297 100644 --- a/src/test/scala/LiveVarsAnalysisTests.scala +++ b/src/test/scala/LiveVarsAnalysisTests.scala @@ -1,6 +1,6 @@ import analysis.{InterLiveVarsAnalysis, TwoElementTop} import ir.dsl.* -import ir.{BitVecLiteral, BitVecType, dsl, Assign, LocalVar, Program, Register, Statement, Variable, transforms, cilvisitor, Procedure} +import ir.{BitVecLiteral, BitVecType, dsl, LocalAssign, LocalVar, Program, Register, Statement, Variable, transforms, cilvisitor, Procedure} import util.{Logger, LogLevel} import org.scalatest.funsuite.AnyFunSuite import test_util.BASILTest @@ -31,10 +31,10 @@ class LiveVarsAnalysisTests extends AnyFunSuite, BASILTest { def differentCalleesBothLive(): Unit = { val constant1 = bv64(1) - val r0ConstantAssign = Assign(R0, constant1, Some("00001")) - val r1ConstantAssign = Assign(R1, constant1, Some("00002")) - val r2r0Assign = Assign(R2, R0, Some("00003")) - val r2r1Assign = Assign(R2, R1, Some("00004")) + val r0ConstantAssign = LocalAssign(R0, constant1, Some("00001")) + val r1ConstantAssign = LocalAssign(R1, constant1, Some("00002")) + val r2r0Assign = LocalAssign(R2, R0, Some("00003")) + val r2r1Assign = LocalAssign(R2, R1, Some("00004")) val program: Program = prog( proc("main", @@ -71,11 +71,11 @@ class LiveVarsAnalysisTests extends AnyFunSuite, BASILTest { def differentCalleesOneAlive(): Unit = { val constant1 = bv64(1) - val r0ConstantAssign = Assign(R0, constant1, Some("00001")) - val r1ConstantAssign = Assign(R1, constant1, Some("00002")) - val r2r0Assign = Assign(R2, R0, Some("00003")) - val r2r1Assign = Assign(R2, R1, Some("00004")) - val r1Reassign = Assign(R1, BitVecLiteral(2, 64), Some("00005")) + val r0ConstantAssign = LocalAssign(R0, constant1, Some("00001")) + val r1ConstantAssign = LocalAssign(R1, constant1, Some("00002")) + val r2r0Assign = LocalAssign(R2, R0, Some("00003")) + val r2r1Assign = LocalAssign(R2, R1, Some("00004")) + val r1Reassign = LocalAssign(R1, BitVecLiteral(2, 64), Some("00005")) val program: Program = prog( proc("main", @@ -109,9 +109,9 @@ class LiveVarsAnalysisTests extends AnyFunSuite, BASILTest { def twoCallers(): Unit = { val constant1 = bv64(1) - val r0ConstantAssign = Assign(R0, constant1, Some("00001")) - val r1Assign = Assign(R0, R1, Some("00002")) - val r2Assign = Assign(R0, R2, Some("00003")) + val r0ConstantAssign = LocalAssign(R0, constant1, Some("00001")) + val r1Assign = LocalAssign(R0, R1, Some("00002")) + val r2Assign = LocalAssign(R0, R2, Some("00003")) val program = prog( proc("main", @@ -130,7 +130,7 @@ class LiveVarsAnalysisTests extends AnyFunSuite, BASILTest { createSimpleProc("callee3", Seq(r2Assign)), proc("wrapper1", block("wrapper1_first_call", - Assign(R1, constant1), + LocalAssign(R1, constant1), directCall("callee"), goto("wrapper1_second_call") ), @@ -141,7 +141,7 @@ class LiveVarsAnalysisTests extends AnyFunSuite, BASILTest { ), proc("wrapper2", block("wrapper2_first_call", - Assign(R2, constant1), + LocalAssign(R2, constant1), directCall("callee"), goto("wrapper2_second_call") ), block("wrapper2_second_call", @@ -168,11 +168,11 @@ class LiveVarsAnalysisTests extends AnyFunSuite, BASILTest { directCall("killer"), goto("aftercall") ), block("aftercall", - Assign(R0, R1), + LocalAssign(R0, R1), ret ) ), - createSimpleProc("killer", Seq(Assign(R1, bv64(1)))) + createSimpleProc("killer", Seq(LocalAssign(R1, bv64(1)))) ) cilvisitor.visit_prog(transforms.ReplaceReturns(), program) @@ -187,8 +187,8 @@ class LiveVarsAnalysisTests extends AnyFunSuite, BASILTest { } def simpleBranch(): Unit = { - val r1Assign = Assign(R0, R1, Some("00001")) - val r2Assign = Assign(R0, R2, Some("00002")) + val r1Assign = LocalAssign(R0, R1, Some("00001")) + val r2Assign = LocalAssign(R0, R2, Some("00002")) val program : Program = prog( proc( @@ -229,11 +229,11 @@ class LiveVarsAnalysisTests extends AnyFunSuite, BASILTest { proc("main", block( "lmain", - Assign(R0, R1), + LocalAssign(R0, R1), directCall("main"), goto("return") ), block("return", - Assign(R0, R2), + LocalAssign(R0, R2), ret ) ) @@ -252,7 +252,7 @@ class LiveVarsAnalysisTests extends AnyFunSuite, BASILTest { val program: Program = prog( proc("main", block("lmain", - Assign(R0, R1), + LocalAssign(R0, R1), goto("recursion", "non-recursion") ), block( @@ -260,7 +260,7 @@ class LiveVarsAnalysisTests extends AnyFunSuite, BASILTest { directCall("main"), goto("assign") ), block("assign", - Assign(R0, R2), + LocalAssign(R0, R2), goto("return") ), block( diff --git a/src/test/scala/MemoryRegionAnalysisMiscTest.scala b/src/test/scala/MemoryRegionAnalysisMiscTest.scala deleted file mode 100644 index a7d7e4e73..000000000 --- a/src/test/scala/MemoryRegionAnalysisMiscTest.scala +++ /dev/null @@ -1,116 +0,0 @@ -import analysis.{LiftedElement, MemoryRegion} -import org.scalatest.Inside.inside -import org.scalatest.* -import org.scalatest.funsuite.* -import util.RunUtils -import ir.* -import util.{BASILConfig, BoogieGeneratorConfig, BoogieMemoryAccessMode, ILLoadingConfig, StaticAnalysisConfig, BASILResult} - -import java.io.{File, OutputStream, PrintStream, PrintWriter} -class MemoryRegionAnalysisMiscTest extends AnyFunSuite with OneInstancePerTest { - - //C:\workdir\bil-to-boogie-translator\examples - private val examplesPath = System.getProperty("user.dir") + "/examples/" - private val expectedPath = System.getProperty("user.dir") + "/src/test/analysis/dotExpected/" - private val tempPath = System.getProperty("user.dir") + "/src/test/analysis/dump/" - def runMain(name: String, dump: Boolean = false): Unit = { - var expected = "" - var actual = "" - var output: Map[CFGPosition, LiftedElement[Set[MemoryRegion]]] = Map() - val results = RunUtils.loadAndTranslate( - BASILConfig( - loading = ILLoadingConfig( - inputFile = examplesPath + s"$name/$name.adt", - relfFile = examplesPath + s"$name/$name.relf", - specFile = None, - dumpIL = None, - ), - staticAnalysis = Some(StaticAnalysisConfig()), - boogieTranslation = BoogieGeneratorConfig(), - outputPrefix = "boogie_out", - ) - ) - try { - // create dump folder if it does not exist - val dumpFolder = File(tempPath) - if (!dumpFolder.exists) { - dumpFolder.mkdir() - } - - output = results.analysis.get.memoryRegionResult - val outFile = new File(tempPath + s"$name") - val pw = new PrintWriter(outFile, "UTF-8") - output.foreach { case (k, v) => - pw.write(s"$k -> $v") - pw.write("\n") - } - pw.close() - val actualFile = scala.io.Source.fromFile(tempPath + s"$name") - actual = actualFile.mkString - actualFile.close() - val expectedFile = scala.io.Source.fromFile(expectedPath + s"$name") - expected = expectedFile.mkString - expectedFile.close() - } catch { - case e: Exception => - if (dump) { - val outFile = new File(expectedPath + s"$name") - val pw = new PrintWriter(outFile, "UTF-8") - output.foreach { case (k, v) => - pw.write(s"$k -> $v") - pw.write("\n") - } - pw.close() - assert(true) - return - } - throw new Exception("TEST NOT SUPPORTED: Expected file not found " + expectedPath + s"$name") - } - assert(actual.split("\n").toList.sorted.map(_.trim) == expected.split("\n").toList.sorted.map(_.trim)) - } - -// def compareDots(name: String): Unit = { -// val exampleFile = scala.io.Source.fromFile(examplesPath.replace("examples/", "test.dot")) -// val expectedFile = scala.io.Source.fromFile(expectedPath + s"${name}.dot") -// val output = exampleFile.mkString -// print(output) -// val expected = expectedFile.mkString -// exampleFile.close() -// expectedFile.close() -// -// assert(output == expected) -// } - - test("ifglobal") { - runMain("ifglobal") - } - - test("iflocal") { - runMain("iflocal") - } - - test("secret_write") { - runMain("secret_write") - } - - test("basic_arrays_read") { - runMain("basic_arrays_read") - } - - test("basic_arrays_write") { - runMain("basic_arrays_write") - } - - test("basicfree") { - runMain("basicfree") - } - - test("arrays") { - runMain("arrays") - } - - // used to generate the expected files (DO NOT RUN) -// test("generate") { -// runMain("arrays", true); -// } -} diff --git a/src/test/scala/PointsToTest.scala b/src/test/scala/PointsToTest.scala index 230a482d7..7c39c303b 100644 --- a/src/test/scala/PointsToTest.scala +++ b/src/test/scala/PointsToTest.scala @@ -17,9 +17,10 @@ class PointsToTest extends AnyFunSuite with OneInstancePerTest { def runAnalyses(program: Program, externalFunctions: Set[ExternalFunction] = Set.empty, globals: Set[SpecGlobal] = Set.empty, + funcEntries: Set[FuncEntry] = Set.empty, globalOffsets: Map[BigInt, BigInt] = Map.empty): StaticAnalysisContext = { - val ctx = IRContext(List.empty, externalFunctions, globals, globalOffsets, Specification(Set(), Map(), List(), List(), List(), Set()), program) + val ctx = IRContext(List.empty, externalFunctions, globals, funcEntries, globalOffsets, Specification(Set(), Set(), Map(), List(), List(), List(), Set()), program) StaticAnalysis.analyse(ctx, StaticAnalysisConfig(), 1) } @@ -30,11 +31,11 @@ class PointsToTest extends AnyFunSuite with OneInstancePerTest { var program: Program = prog( proc("main", block("0x0", - Assign(R6, R31), + LocalAssign(R6, R31), goto("0x1") ), block("0x1", - MemoryAssign(mem, BinaryExpr(BVADD, R6, bv64(4)), bv64(10), LittleEndian, 64), + MemoryStore(mem, BinaryExpr(BVADD, R6, bv64(4)), bv64(10), LittleEndian, 64), goto("returntarget") ), block("returntarget", @@ -49,7 +50,7 @@ class PointsToTest extends AnyFunSuite with OneInstancePerTest { val results = runAnalyses(program) results.mmmResults.pushContext("main") assert(results.mmmResults.findStackObject(BigInt(4)).isDefined) - assert(results.mmmResults.findStackObject(BigInt(4)).get.start == bv64(4)) + assert(results.mmmResults.findStackObject(BigInt(4)).get.start == BigInt(4)) assert(results.mmmResults.findStackObject(BigInt(4)).get.regionIdentifier == "stack_1") } @@ -60,8 +61,8 @@ class PointsToTest extends AnyFunSuite with OneInstancePerTest { var program: Program = prog( proc("main", block("0x0", - Assign(R1, MemoryLoad(mem, BinaryExpr(BVADD, R31, bv64(6)), LittleEndian, 64)), - Assign(R3, MemoryLoad(mem, BinaryExpr(BVADD, R31, bv64(4)), LittleEndian, 64)), + MemoryLoad(R1, mem, BinaryExpr(BVADD, R31, bv64(6)), LittleEndian, 64), + MemoryLoad(R3, mem, BinaryExpr(BVADD, R31, bv64(4)), LittleEndian, 64), goto("0x1") ), block("0x1", @@ -82,10 +83,10 @@ class PointsToTest extends AnyFunSuite with OneInstancePerTest { assert(results.mmmResults.findStackObject(BigInt(6)).isDefined) assert(results.mmmResults.findStackObject(BigInt(10)).isDefined) - assert(results.mmmResults.findStackObject(BigInt(4)).get.start == bv64(4)) - assert(results.mmmResults.findStackObject(BigInt(5)).get.start == bv64(4)) - assert(results.mmmResults.findStackObject(BigInt(6)).get.start == bv64(6)) - assert(results.mmmResults.findStackObject(BigInt(10)).get.start == bv64(6)) + assert(results.mmmResults.findStackObject(BigInt(4)).get.start == BigInt(4)) + assert(results.mmmResults.findStackObject(BigInt(5)).get.start == BigInt(4)) + assert(results.mmmResults.findStackObject(BigInt(6)).get.start == BigInt(6)) + assert(results.mmmResults.findStackObject(BigInt(10)).get.start == BigInt(6)) } // /** @@ -135,8 +136,8 @@ class PointsToTest extends AnyFunSuite with OneInstancePerTest { val program: Program = prog( proc("main", block("0x0", - Assign(R0, MemoryLoad(mem, BinaryExpr(BVADD, R31, bv64(6)), LittleEndian, 64)), - Assign(R1, BinaryExpr(BVADD, R31, bv64(10))), + MemoryLoad(R0, mem, BinaryExpr(BVADD, R31, bv64(6)), LittleEndian, 64), + LocalAssign(R1, BinaryExpr(BVADD, R31, bv64(10))), goto("0x1") ), block("0x1", @@ -148,8 +149,8 @@ class PointsToTest extends AnyFunSuite with OneInstancePerTest { ), proc("p2", block("l_p2", - Assign(R3, R0), - Assign(R2, MemoryLoad(mem, R1, LittleEndian, 64)), + LocalAssign(R3, R0), + MemoryLoad(R2, mem, R1, LittleEndian, 64), goto("l_p2_1"), ), block("l_p2_1", @@ -165,7 +166,7 @@ class PointsToTest extends AnyFunSuite with OneInstancePerTest { results.mmmResults.pushContext("main") assert(results.mmmResults.findStackObject(BigInt(6)).isDefined) - assert(results.mmmResults.findStackObject(BigInt(6)).get.start == bv64(6)) + assert(results.mmmResults.findStackObject(BigInt(6)).get.start == BigInt(6)) /* ------------------------------------------------------------------------- */ @@ -173,8 +174,8 @@ class PointsToTest extends AnyFunSuite with OneInstancePerTest { assert(results.mmmResults.findSharedStackObject(BigInt(6)).nonEmpty) assert(results.mmmResults.findSharedStackObject(BigInt(10)).nonEmpty) - assert(results.mmmResults.findSharedStackObject(BigInt(6)).head.start == bv64(6)) - assert(results.mmmResults.findSharedStackObject(BigInt(10)).head.start == bv64(10)) + assert(results.mmmResults.findSharedStackObject(BigInt(6)).head.start == BigInt(6)) + assert(results.mmmResults.findSharedStackObject(BigInt(10)).head.start == BigInt(10)) } /** @@ -184,8 +185,8 @@ class PointsToTest extends AnyFunSuite with OneInstancePerTest { val program: Program = prog( proc("main", block("0x0", - Assign(R0, MemoryLoad(mem, BinaryExpr(BVADD, R31, bv64(6)), LittleEndian, 64)), - Assign(R1, BinaryExpr(BVADD, R31, bv64(10))), + MemoryLoad(R0, mem, BinaryExpr(BVADD, R31, bv64(6)), LittleEndian, 64), + LocalAssign(R1, BinaryExpr(BVADD, R31, bv64(10))), goto("0x1") ), block("0x1", @@ -197,8 +198,8 @@ class PointsToTest extends AnyFunSuite with OneInstancePerTest { ), proc("foo", block("l_foo", - Assign(R0, MemoryLoad(mem, BinaryExpr(BVADD, R31, bv64(6)), LittleEndian, 64)), - Assign(R1, BinaryExpr(BVADD, R31, bv64(10))), + MemoryLoad(R0, mem, BinaryExpr(BVADD, R31, bv64(6)), LittleEndian, 64), + LocalAssign(R1, BinaryExpr(BVADD, R31, bv64(10))), directCall("p2"), goto("l_foo_1") ), block("l_foo_1", @@ -207,8 +208,8 @@ class PointsToTest extends AnyFunSuite with OneInstancePerTest { ), proc("p2", block("l_p2", - Assign(R3, R0), - Assign(R2, MemoryLoad(mem, R1, LittleEndian, 64)), + LocalAssign(R3, R0), + MemoryLoad(R2, mem, R1, LittleEndian, 64), goto("l_p2_1"), ), block("l_p2_1", @@ -224,7 +225,7 @@ class PointsToTest extends AnyFunSuite with OneInstancePerTest { results.mmmResults.pushContext("main") assert(results.mmmResults.findStackObject(BigInt(6)).isDefined) - assert(results.mmmResults.findStackObject(BigInt(6)).get.start == bv64(6)) + assert(results.mmmResults.findStackObject(BigInt(6)).get.start == BigInt(6)) /* ------------------------------------------------------------------------- */ diff --git a/src/test/scala/SystemTests.scala b/src/test/scala/SystemTests.scala index 49d971541..0013e0f93 100644 --- a/src/test/scala/SystemTests.scala +++ b/src/test/scala/SystemTests.scala @@ -176,8 +176,8 @@ trait SystemTests extends AnyFunSuite, BASILTest { } class SystemTestsBAP extends SystemTests { - runTests("correct", TestConfig(useBAPFrontend = true, expectVerify = true, logResults = true)) - runTests("incorrect", TestConfig(useBAPFrontend = true, expectVerify = false, logResults = true)) + runTests("correct", TestConfig(useBAPFrontend = true, expectVerify = true, checkExpected = true, logResults = true)) + runTests("incorrect", TestConfig(useBAPFrontend = true, expectVerify = false, checkExpected = true, logResults = true)) test("summary-BAP") { summary("testresult-BAP") } diff --git a/src/test/scala/TaintAnalysisTests.scala b/src/test/scala/TaintAnalysisTests.scala index f108e99c2..774a49381 100644 --- a/src/test/scala/TaintAnalysisTests.scala +++ b/src/test/scala/TaintAnalysisTests.scala @@ -7,12 +7,12 @@ import test_util.BASILTest class TaintAnalysisTests extends AnyFunSuite, BASILTest { def getTaintAnalysisResults(program: Program, taint: Map[CFGPosition, Set[Taintable]]): Map[CFGPosition, Set[Taintable]] = { - val constPropResults = ConstantPropagationSolver(program).analyze() + val constPropResults = InterProcConstantPropagation(program).analyze() TaintAnalysis(program, Map(), constPropResults, taint).analyze().map { (c, m) => (c, m.map { (v, _) => v }.toSet)} } def getVarDepResults(program: Program, procedure: Procedure): Map[CFGPosition, Map[Taintable, Set[Taintable]]] = { - val constPropResults = ConstantPropagationSolver(program).analyze() + val constPropResults = InterProcConstantPropagation(program).analyze() val variables = registers ProcVariableDependencyAnalysis(program, variables, Map(), constPropResults, Map(), procedure).analyze() } @@ -31,7 +31,7 @@ class TaintAnalysisTests extends AnyFunSuite, BASILTest { ), proc("f", block("assign", - Assign(R0, bv64(2), None), + LocalAssign(R0, bv64(2), None), goto("returnBlock"), ), block("returnBlock", @@ -65,7 +65,7 @@ class TaintAnalysisTests extends AnyFunSuite, BASILTest { ), proc("f", block("assign", - Assign(R0, BinaryExpr(BVADD, R0, R1), None), + LocalAssign(R0, BinaryExpr(BVADD, R0, R1), None), goto("returnBlock"), ), block("returnBlock", @@ -102,11 +102,11 @@ class TaintAnalysisTests extends AnyFunSuite, BASILTest { goto("a", "b"), ), block("a", - Assign(R0, R1, None), + LocalAssign(R0, R1, None), goto("returnBlock"), ), block("b", - Assign(R0, R2, None), + LocalAssign(R0, R2, None), goto("returnBlock"), ), block("returnBlock", @@ -143,12 +143,12 @@ class TaintAnalysisTests extends AnyFunSuite, BASILTest { goto("a", "b"), ), block("a", - Assign(R1, R1, None), + LocalAssign(R1, R1, None), directCall("g"), goto("returnBlock"), ), block("b", - Assign(R1, R2, None), + LocalAssign(R1, R2, None), directCall("g"), goto("returnBlock"), ), @@ -158,7 +158,7 @@ class TaintAnalysisTests extends AnyFunSuite, BASILTest { ), proc("g", block("body", - Assign(R0, R1, None), + LocalAssign(R0, R1, None), goto("returnBlock"), ), block("returnBlock", @@ -195,11 +195,11 @@ class TaintAnalysisTests extends AnyFunSuite, BASILTest { goto("a", "b"), ), block("a", - Assign(R0, BinaryExpr(BVADD, R0, R1), None), + LocalAssign(R0, BinaryExpr(BVADD, R0, R1), None), goto("branch"), ), block("b", - Assign(R0, R2, None), + LocalAssign(R0, R2, None), goto("returnBlock"), ), block("returnBlock", diff --git a/src/test/scala/ir/CILVisitorTest.scala b/src/test/scala/ir/CILVisitorTest.scala index b41b604fb..200cd3e78 100644 --- a/src/test/scala/ir/CILVisitorTest.scala +++ b/src/test/scala/ir/CILVisitorTest.scala @@ -44,7 +44,7 @@ class AddGammas extends CILVisitor { override def vstmt(s: Statement) = { s match { - case a: Assign => ChangeTo(List(a, Assign(gamma_v(a.lhs), gamma_e(a.rhs)))) + case a: LocalAssign => ChangeTo(List(a, LocalAssign(gamma_v(a.lhs), gamma_e(a.rhs)))) case _ => SkipChildren() } @@ -86,10 +86,10 @@ class CILVisitorTest extends AnyFunSuite { val program: Program = prog( proc( "main", - block("0x0", Assign(getRegister("R6"), getRegister("R31")), goto("0x1")), + block("0x0", LocalAssign(getRegister("R6"), getRegister("R31")), goto("0x1")), block( "0x1", - MemoryAssign(mem, BinaryExpr(BVADD, getRegister("R6"), bv64(4)), bv64(10), Endian.LittleEndian, 64), + MemoryStore(mem, BinaryExpr(BVADD, getRegister("R6"), bv64(4)), bv64(10), Endian.LittleEndian, 64), goto("returntarget") ), block("returntarget", ret) @@ -134,10 +134,10 @@ class CILVisitorTest extends AnyFunSuite { val program: Program = prog( proc( "main", - block("0x0", Assign(getRegister("R6"), getRegister("R31")), goto("0x1")), + block("0x0", LocalAssign(getRegister("R6"), getRegister("R31")), goto("0x1")), block( "0x1", - MemoryAssign(mem, BinaryExpr(BVADD, getRegister("R6"), bv64(4)), bv64(10), Endian.LittleEndian, 64), + MemoryStore(mem, BinaryExpr(BVADD, getRegister("R6"), bv64(4)), bv64(10), Endian.LittleEndian, 64), goto("returntarget") ), block("returntarget", ret) diff --git a/src/test/scala/ir/IRTest.scala b/src/test/scala/ir/IRTest.scala index 854389d90..069fa914e 100644 --- a/src/test/scala/ir/IRTest.scala +++ b/src/test/scala/ir/IRTest.scala @@ -95,13 +95,13 @@ class IRTest extends AnyFunSuite { val p = prog( proc("main", block("l_main", - Assign(R0, bv64(10)), - Assign(R1, bv64(10)), + LocalAssign(R0, bv64(10)), + LocalAssign(R1, bv64(10)), goto("newblock") ), block("l_main_1", - Assign(R0, bv64(22)), - directCall("p2"), + LocalAssign(R0, bv64(22)), + directCall("p2"), goto("returntarget") ), block("returntarget", @@ -109,7 +109,7 @@ class IRTest extends AnyFunSuite { ) ), proc("p2", - block("l_p2", Assign(R0, bv64(10)), goto("l_p2_1")), + block("l_p2", LocalAssign(R0, bv64(10)), goto("l_p2_1")), block("l_p2_1", ret) ) ) @@ -153,15 +153,15 @@ class IRTest extends AnyFunSuite { ) val b2 = block("newblock2", - Assign(R0, bv64(22)), - Assign(R0, bv64(22)), - Assign(R0, bv64(22)), + LocalAssign(R0, bv64(22)), + LocalAssign(R0, bv64(22)), + LocalAssign(R0, bv64(22)), goto("lmain2") ).resolve(p) val b1 = block("newblock1", - Assign(R0, bv64(22)), - Assign(R0, bv64(22)), - Assign(R0, bv64(22)), + LocalAssign(R0, bv64(22)), + LocalAssign(R0, bv64(22)), + LocalAssign(R0, bv64(22)), goto("lmain2") ).resolve(p) @@ -190,16 +190,16 @@ class IRTest extends AnyFunSuite { ) val b1 = block("newblock2", - Assign(R0, bv64(22)), - Assign(R0, bv64(22)), - Assign(R0, bv64(22)), + LocalAssign(R0, bv64(22)), + LocalAssign(R0, bv64(22)), + LocalAssign(R0, bv64(22)), directCall("main"), unreachable ).resolve(p) val b2 = block("newblock1", - Assign(R0, bv64(22)), - Assign(R0, bv64(22)), - Assign(R0, bv64(22)), + LocalAssign(R0, bv64(22)), + LocalAssign(R0, bv64(22)), + LocalAssign(R0, bv64(22)), ret ).resolve(p) @@ -217,7 +217,7 @@ class IRTest extends AnyFunSuite { assert(called.incomingCalls().isEmpty) val b3 = block("newblock3", - Assign(R0, bv64(22)), + LocalAssign(R0, bv64(22)), directCall("called"), unreachable ).resolve(p) @@ -253,8 +253,8 @@ class IRTest extends AnyFunSuite { val p = prog( proc("main", block("l_main", - Assign(R0, bv64(10)), - Assign(R1, bv64(10)), + LocalAssign(R0, bv64(10)), + LocalAssign(R1, bv64(10)), goto("returntarget") ), block("returntarget", @@ -284,13 +284,13 @@ class IRTest extends AnyFunSuite { val p = prog( proc("p1", block("b1", - Assign(R0, bv64(10)), + LocalAssign(R0, bv64(10)), ret ) ), proc("main", block("l_main", - Assign(R0, bv64(10)), + LocalAssign(R0, bv64(10)), directCall("p1"), goto("returntarget") ), block("returntarget", diff --git a/src/test/scala/ir/InterpreterTests.scala b/src/test/scala/ir/InterpreterTests.scala index 2735869cf..41e8a28f5 100644 --- a/src/test/scala/ir/InterpreterTests.scala +++ b/src/test/scala/ir/InterpreterTests.scala @@ -18,9 +18,7 @@ def load(s: InterpreterState, global: SpecGlobal): Option[BitVecLiteral] = { State.evaluate( s, - Eval.evalBV(f)( - MemoryLoad(SharedMemory("mem", 64, 8), BitVecLiteral(global.address, 64), Endian.LittleEndian, global.size) - ) + Eval.loadBV(f)("mem", Scalar(BitVecLiteral(global.address, 64)), Endian.LittleEndian, global.size) ) match { case Right(e) => Some(e) case Left(e) => { @@ -236,7 +234,7 @@ class InterpreterTests extends AnyFunSuite with BeforeAndAfter { prog( proc( "begin", - block("entry", Assign(R8, Register("R31", 64)), Assign(R0, bv64(n)), directCall("fib"), goto("done")), + block("entry", LocalAssign(R8, Register("R31", 64)), LocalAssign(R0, bv64(n)), directCall("fib"), goto("done")), block("done", Assert(BinaryExpr(BVEQ, R0, bv64(fib(n)))), ret) ), proc( @@ -248,22 +246,22 @@ class InterpreterTests extends AnyFunSuite with BeforeAndAfter { "dofib", Assume(BinaryExpr(BoolAND, BinaryExpr(BVNEQ, R0, bv64(0)), BinaryExpr(BVNEQ, R0, bv64(1)))), // R8 stack pointer preserved across calls - Assign(R7, BinaryExpr(BVADD, R8, bv64(8))), - MemoryAssign(stack, R7, R8, Endian.LittleEndian, 64), // sp - Assign(R8, R7), - Assign(R8, BinaryExpr(BVADD, R8, bv64(8))), // sp + 8 - MemoryAssign(stack, R8, R0, Endian.LittleEndian, 64), // [sp + 8] = arg0 - Assign(R0, BinaryExpr(BVSUB, R0, bv64(1))), + LocalAssign(R7, BinaryExpr(BVADD, R8, bv64(8))), + MemoryStore(stack, R7, R8, Endian.LittleEndian, 64), // sp + LocalAssign(R8, R7), + LocalAssign(R8, BinaryExpr(BVADD, R8, bv64(8))), // sp + 8 + MemoryStore(stack, R8, R0, Endian.LittleEndian, 64), // [sp + 8] = arg0 + LocalAssign(R0, BinaryExpr(BVSUB, R0, bv64(1))), directCall("fib"), - Assign(R2, R8), // sp + 8 - Assign(R8, BinaryExpr(BVADD, R8, bv64(8))), // sp + 16 - MemoryAssign(stack, R8, R0, Endian.LittleEndian, 64), // [sp + 16] = r1 - Assign(R0, MemoryLoad(stack, R2, Endian.LittleEndian, 64)), // [sp + 8] - Assign(R0, BinaryExpr(BVSUB, R0, bv64(2))), + LocalAssign(R2, R8), // sp + 8 + LocalAssign(R8, BinaryExpr(BVADD, R8, bv64(8))), // sp + 16 + MemoryStore(stack, R8, R0, Endian.LittleEndian, 64), // [sp + 16] = r1 + MemoryLoad(R0, stack, R2, Endian.LittleEndian, 64), // [sp + 8] + LocalAssign(R0, BinaryExpr(BVSUB, R0, bv64(2))), directCall("fib"), - Assign(R2, MemoryLoad(stack, R8, Endian.LittleEndian, 64)), // [sp + 16] (r1) - Assign(R0, BinaryExpr(BVADD, R0, R2)), - Assign(R8, MemoryLoad(stack, BinaryExpr(BVSUB, R8, bv64(16)), Endian.LittleEndian, 64)), + MemoryLoad(R2, stack, R8, Endian.LittleEndian, 64), // [sp + 16] (r1) + LocalAssign(R0, BinaryExpr(BVADD, R0, R2)), + MemoryLoad(R8, stack, BinaryExpr(BVSUB, R8, bv64(16)), Endian.LittleEndian, 64), ret ) ) @@ -338,7 +336,7 @@ class InterpreterTests extends AnyFunSuite with BeforeAndAfter { test("Capture IllegalArg") { val tp = prog( - proc("begin", block("shouldfail", Assign(R0, ZeroExtend(-1, BitVecLiteral(0, 64))), ret)) + proc("begin", block("shouldfail", LocalAssign(R0, ZeroExtend(-1, BitVecLiteral(0, 64))), ret)) ) val ir = interpret(tp) diff --git a/src/test/scala/ir/SingleCallInvariant.scala b/src/test/scala/ir/SingleCallInvariant.scala index d8efb6fc2..4e0061424 100644 --- a/src/test/scala/ir/SingleCallInvariant.scala +++ b/src/test/scala/ir/SingleCallInvariant.scala @@ -10,13 +10,13 @@ class InvariantTest extends AnyFunSuite { var program: Program = prog( proc("main", block("first_call", - Assign(R0, bv64(10)), - Assign(R1, bv64(10)), + LocalAssign(R0, bv64(10)), + LocalAssign(R1, bv64(10)), directCall("callee1"), ret ), block("second_call", - Assign(R0, bv64(10)), + LocalAssign(R0, bv64(10)), directCall("callee2"), ret ), @@ -35,14 +35,14 @@ class InvariantTest extends AnyFunSuite { var program: Program = prog( proc("main", block("first_call", - Assign(R0, bv64(10)), + LocalAssign(R0, bv64(10)), directCall("callee2"), - Assign(R1, bv64(10)), + LocalAssign(R1, bv64(10)), directCall("callee1"), ret ), block("second_call", - Assign(R0, bv64(10)), + LocalAssign(R0, bv64(10)), ret ), block("returnBlock", @@ -60,13 +60,13 @@ class InvariantTest extends AnyFunSuite { var program: Program = prog( proc("main", block("first_call", - Assign(R0, bv64(10)), - Assign(R1, bv64(10)), + LocalAssign(R0, bv64(10)), + LocalAssign(R1, bv64(10)), ret ), block("second_call", directCall("callee2"), - Assign(R0, bv64(10)), + LocalAssign(R0, bv64(10)), ret ), block("returnBlock",