Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rellic produces semantically non-equivalent code #325

Open
vmihalko opened this issue May 18, 2023 · 1 comment
Open

Rellic produces semantically non-equivalent code #325

vmihalko opened this issue May 18, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@vmihalko
Copy link

Used version:

0.2.3. (current)

Reproducer:
#include <stdio.h>
int main(int argc, const char** argv) {
	int i = argc;
	if ( i == 1 ) { // no args
		putchar(4 + '0');
		i += 1;
		goto n5;	
	}
	if ( i > 1 ) { // args
		putchar( 5 + '0');
		goto n7;
	}
n5:
	putchar( 6 + '0');
n7:
	putchar( 7 + '0');
}
Steps to reproduce:
clang error.c -o error
clang error.c -S -emit-llvm -o error.ll
rellic-decomp --input error.ll --output de-error.c
clang de-error.c -o de-error
Expected behavior:

Executing error results in: "467"

Current behavior:

But executing de-error results in: "47"

Rellics output:
int main(int arg0, char **arg1);
unsigned int putchar(unsigned int arg0);
int main(int arg0, char **arg1) {
    unsigned int var0;
    unsigned int var1;
    char **var2;
    unsigned int var3;
    var0 = 0U;
    var1 = arg0;
    var2 = arg1;
    var3 = var1;
    if (var3 != 1U && (int)var3 > 1) {
        putchar(53U);
    }
    if (var3 == 1U) {
        putchar(52U);
        var3 = var3 + 1U;
    }
    if (var3 == 1U || (int)var3 <= 1) {
        putchar(54U);
    }
    putchar(55U);
    return var0;
}
@frabert frabert added the bug Something isn't working label May 19, 2023
@frabert
Copy link
Collaborator

frabert commented May 19, 2023

Can reproduce 👍

frabert added a commit that referenced this issue May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants