NAME=x86:LE:32:default:gcc
ARGS=-a x86
FILE=malloc://2048
EXPECT=<<EOF
            0x00000000      89e1           mov ecx, esp
type: mov
----
            0x00000000      a168a00408     mov eax, dword [0x804a068]  ; [0x804a068:4]=-1
type: mov
----
            0x00000000      a368a00408     mov dword [0x804a068], eax  ; [0x804a068:4]=-1
type: mov
----
            0x00000000      8945f0         mov dword [ebp - 0x10], eax
type: mov
----
            0x00000000      8b4510         mov eax, dword [ebp + 0x10]
type: mov
----
            0x00000000      0f4c0d0300..   cmovl ecx, dword [3]        ; [0x3:4]=3
type: cmov
----
            0x00000000      cd80           int 0x80
type: swi
----
            0x00000000      55             push ebp
type: rpush
----
            0x00000000      6a00           push 0
type: push
----
            0x00000000      5d             pop ebp
type: pop
----
            0x00000000      83f853         cmp eax, 0x53               ; 'S'
type: cmp
----
            0x00000000      85c0           test eax, eax
type: acmp
----
            0x00000000      83c410         add esp, 0x10
type: add
----
            0x00000000      81ec88100000   sub esp, 0x1088
type: sub
----
            0x00000000      f7ea           imul edx
type: mul
----
            0x00000000      f7f2           div edx
type: div
----
            0x00000000      d1e8           shr eax, 1
type: shr
----
            0x00000000      d1e0           shl eax, 1
type: shl
----
            0x00000000      d1f8           sar eax, 1
type: sar
----
            0x00000000      0b25f0ff0000   or esp, dword [0xfff0]      ; [0xfff0:4]=-1
type: or
----
            0x00000000      2325f0ff0000   and esp, dword [0xfff0]     ; [0xfff0:4]=-1
type: and
----
            0x00000000      3325f0ff0000   xor esp, dword [0xfff0]     ; [0xfff0:4]=-1
type: xor
----
            0x00000000      8703           xchg dword [ebx], eax
type: mov
EOF
CMDS=<<EOF
e asm.cpu=x86
e asm.bits=32
pdga
wx 89e1
pd 1
ao | grep type
?e ----
wx a168a00408
pd 1
ao | grep type
?e ----
wx a368a00408
pd 1
ao | grep type
?e ----
wx 8945f0
pd 1
ao | grep type
?e ----
wx 8b4510
pd 1
ao | grep type
?e ----
wx 0f4c0d03000000
pd 1
ao | grep type
?e ----
wx cd80
pd 1
ao | grep type
?e ----
wx 55
pd 1
ao | grep type
?e ----
wx 6a00
pd 1
ao | grep type
?e ----
wx 5d
pd 1
ao | grep type
?e ----
wx 83f853
pd 1
ao | grep type
?e ----
wx 85c0
pd 1
ao | grep type
?e ----
wx 83c410
pd 1
ao | grep type
?e ----
wx 81ec88100000
pd 1
ao | grep type
?e ----
wx f7ea
pd 1
ao | grep type
?e ----
wx f7f2
pd 1
ao | grep type
?e ----
wx d1e8
pd 1
ao | grep type
?e ----
wx d1e0
pd 1
ao | grep type
?e ----
wx d1f8
pd 1
ao | grep type
?e ----
wx 0b25f0ff0000
pd 1
ao | grep type
?e ----
wx 2325f0ff0000
pd 1
ao | grep type
?e ----
wx 3325f0ff0000
pd 1
ao | grep type
?e ----
wx 8703
pd 1
ao | grep type
EOF
RUN

NAME=AARCH64:LE:64:v8A:gcc
FILE=malloc://2048
EXPECT=<<EOF
            0x00000000      298947f9       ldr x9, [x9, #0xf10]
type: load
----
            0x00000200      690200f9       str x9, [x19]
type: store
EOF
CMDS=<<EOF
e asm.arch=r2ghidra
e asm.cpu=arm
e asm.bits=64
wx 298947f9
pd 1
ao | grep type
?e ----
wx 690200f9 @ 0x200
pd 1 @ 0x200
ao @ 0x200| grep type
EOF
RUN

NAME=v850cmp
ARGS=-e asm.arch=r2ghidra -e asm.bits=32 -e asm.cpu=v850
FILE=-
CMDS=<<EOF
pdga
e anal.arch
e anal.cpu
wx e731
ao 1~!pseudo
EOF
EXPECT=<<EOF
r2ghidra
address: 0x0
opcode: cmp r7, r6
esilcost: 0
disasm: cmp r7, r6
mnemonic: cmp
mask: ffff
id: 0
bytes: e731
size: 2
sign: true
type: cmp
cycles: 0
esil: r6,NUM,r7,NUM,-,1,32,<<,1,-,&,psw,NUM,4294967287,&,1,32,<<,1,-,&,r6,NUM,r7,NUM,<,DUP,DUP,3,<<,1,32,<<,1,-,&,4,PICK,2,PICK,|,1,32,<<,1,-,&,psw,=,r6,NUM,r7,NUM,2,PICK,2,PICK,-,1,32,<<,1,-,&,3,PICK,31,>>,1,32,<<,1,-,&,DUP,0,>>,1,8,<<,1,-,&,4,PICK,31,>>,1,32,<<,1,-,&,DUP,0,>>,1,8,<<,1,-,&,5,PICK,31,>>,1,32,<<,1,-,&,DUP,0,>>,1,8,<<,1,-,&,DUP,1,&,1,8,<<,1,-,&,psw,NUM,4294967291,&,1,32,<<,1,-,&,7,PICK,6,PICK,-,!,!,6,PICK,4,PICK,-,!,2,PICK,2,PICK,&,1,8,<<,1,-,&,DUP,DUP,2,<<,1,32,<<,1,-,&,6,PICK,2,PICK,|,1,32,<<,1,-,&,psw,=,psw,NUM,4294967293,&,1,32,<<,1,-,&,22,PICK,0,32,~,SWAP,32,~,SWAP,<,DUP,DUP,1,<<,1,32,<<,1,-,&,4,PICK,2,PICK,|,1,32,<<,1,-,&,psw,=,psw,NUM,4294967294,&,1,32,<<,1,-,&,26,PICK,0,-,!,DUP,3,PICK,2,PICK,|,1,32,<<,1,-,&,psw,=
family: cpu
EOF
RUN

NAME=v850load
ARGS=-e asm.arch=r2ghidra -e asm.bits=32 -e asm.cpu=v850
FILE=-
CMDS=<<EOF
pdga
e anal.arch
e anal.cpu
wx 3d5f0500
ao 1~!pseudo
EOF
EXPECT=<<EOF
r2ghidra
address: 0x0
opcode: ld.w 0x4[r29], r11
esilcost: 4
disasm: ld.w 0x4[r29], r11
mnemonic: ld.w
mask: ffffffff
id: 0
bytes: 3d5f0500
size: 4
sign: true
type: load
cycles: 0
esil: r29,NUM,4,+,1,32,<<,1,-,&,DUP,[4],r11,=
family: cpu
EOF
RUN

NAME=AARCH64 esil
FILE=malloc://2048
CMDS=<<EOF
e log.level=0
e asm.arch=r2ghidra
e asm.cpu=arm
e asm.bits=64
wx 298947f9
ao 1~type
ao 1~esil
?e ----
wx 690200f9
ao 1~type
ao 1~esil
EOF
EXPECT=<<EOF
type: load
esilcost: 8
esil: x9,NUM,3856,+,1,64,<<,1,-,&,DUP,[8],x9,=
----
type: store
esilcost: 24
esil: x19,NUM,x9,NUM,2,PICK,=[8]
EOF
RUN

NAME=v850 esil
ARGS=-e asm.arch=r2ghidra -e asm.bits=32 -e asm.cpu=v850
FILE=-
CMDS=<<EOF
e log.level=0
wx e731
ao 1~type
ao 1~esilcost
EOF
EXPECT=<<EOF
type: cmp
esilcost: 0
EOF
RUN
