avast / avast/retdec

Incorrect decompile (x % 10)

Open
#1,089 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Hey!

This function does not decompile correctly:

modby10: movabsq $-3689348814741910323, %rdx
mov %rdi, %rax
mul %rdx
mov %rdx, %rax
shr $3, %rax
lea (%rax,%rax,4), %rdx
mov %rdi, %rax
add %rdx, %rdx
sub %rdx, %rax
ret

Correct decompile would be:

uint64_t modby10(int64_t arg1) {
return arg1 % 10;
}

current decompile is:

int64_t modby10(int64_t result)
return result;
}

Tuxifan

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the supplied modby10 x86-64 sequence and trace how its multiply, shift, and subtraction operations are recognized. Confirm the decompiler emits a modulo expression rather than returning the input; the payload names no source file or test, so locate the relevant arithmetic or decompilation regression entry point before changing code.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, reverse-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.