Skip to content

bytecode peephole optimization non-looping-loops #186

@Janmm14

Description

@Janmm14

In the original obfuscation the long j is not set to 0, but I can easily edit the bytecode so that its a 0.

long j = 0L;
long j0 = 3154942220328664823L;
while((j ^ j0) != -4097245258586862040L) {
    {
        j = -8987102950668834246L;
        j0 = 4928288597787943954L;
    }
}

I think it should be possible to optimize these never-looping-loops relatively easy, but I'm struggling with such generic bytecode analysis.
bytecode of sample above:

L10:    lconst_0 
L11:    ldc2_w 3154942220328664823L 
L14:    goto L23 

        .stack full 
            [redacted]
        .end stack 
L17:    ldc2_w -8987102950668834246L 
L20:    ldc2_w 4928288597787943954L 

        .stack full 
            [redacted]
        .end stack 
L23:    lxor 
L24:    ldc2_w -4097245258586862040L 
L27:    lcmp 
L28:    ifne L17 

other sample of similar never looping thing:

long j = 0L;
long j0 = 6913978580415874324L;
while(true) {
    int i = (j < j0) ? -1 : (j == j0) ? 0 : 1;
    if (i == 0) {
        break;
    }
    if (i != -1) {
        j = 1371682301368612379L;
        j0 = 98363365008051593L;
    } else {
        // real code
        break;
    }
}

#185

Edit: maybe that whole thing is also in another non-looping-loop:

label0: while(true) {
    long j1 = 0L;
    long j2 = 5954778881033184416L;
    while(true) {
        int i0 = (j1 < j2) ? -1 : (j1 == j2) ? 0 : 1;
        if (i0 == 0) {
            break;
        }
        if (i0 == -1) {
            break label0;
       }
        j1 = 234223452657458715L;
        j2 = 6736292361240488430L;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions