LLM4Decompile icon indicating copy to clipboard operation
LLM4Decompile copied to clipboard

Problem about compiling the humanEval testset

Open wang-yongpan opened this issue 1 year ago • 2 comments

hi,

I would like to know how the assembly code in the decompile-eval-executable-gcc-obj.json data you released was compiled. I found that your assembly code is different from mine. For example,

char *func0(const char *a, const char *b) {
    int len_a = strlen(a);
    int len_b = strlen(b);
    int min_len = len_a < len_b ? len_a : len_b;
    char *output = malloc((min_len + 1) * sizeof(char));
    if (!output) return NULL;

    for (int i = 0; i < min_len; i++) {
        output[i] = (a[i] == b[i]) ? '0' : '1';
    }
    output[min_len] = '\0';
    return output;
}

Your assembly code:

<func0>:
...
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rdi
call   10a0 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rdi
call   10a0 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edx
...

compile ins:

gcc -o 1.o 1.c -O1 -shared -fPIC -lm

My results:

...
mov    $0xffffffffffffffff,%rbx
mov    $0x0,%eax
mov    %rbx,%rcx
repnz scas %es:(%rdi),%al
not    %rcx
lea    (%rcx,%rbx,1),%rdx
mov    %rbx,%rcx
mov    %rsi,%rdi
repnz scas %es:(%rdi),%al
...

Obviously, the strlen function is optimized to the repnz instruction, but your result is not optimized.

Thankx!

wang-yongpan avatar Dec 24 '24 07:12 wang-yongpan

And I found that if i use option -fno-builtin, i can get your results. Did you use this to get the results?

wang-yongpan avatar Dec 24 '24 07:12 wang-yongpan