skylot / jadx

Dex to Java decompiler
Apache License 2.0
41.96k stars 4.9k forks source link

[core] "Code restructure failed" (bad branches) #2339

Open pubiqq opened 3 weeks ago

pubiqq commented 3 weeks ago

Issue details

Smali

``` ###### Class conditions.TestBadBranches (conditions.TestBadBranches) .class public Lconditions/TestBadBranches; .super Ljava/lang/Object; .source "SourceFile" # instance fields .field public final data:[B # direct methods .method public constructor ([B)V .registers 3 const-string v0, "data" invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V invoke-direct {p0}, Ljava/lang/Object;->()V iput-object p1, p0, Lconditions/TestBadBranches;->data:[B return-void .end method # virtual methods .method public final compareTo(Ljava/lang/Object;)I .registers 11 check-cast p1, Lconditions/TestBadBranches; const-string v0, "other" invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V invoke-virtual {p0}, Lconditions/TestBadBranches;->getSize()I move-result v0 invoke-virtual {p1}, Lconditions/TestBadBranches;->getSize()I move-result v1 invoke-static {v0, v1}, Ljava/lang/Math;->min(II)I move-result v2 const/4 v3, 0x0 move v4, v3 :goto_15 const/4 v5, 0x1 const/4 v6, -0x1 if-ge v4, v2, :cond_30 invoke-virtual {p0, v4}, Lconditions/TestBadBranches;->get(I)B move-result v7 and-int/lit16 v7, v7, 0xff invoke-virtual {p1, v4}, Lconditions/TestBadBranches;->get(I)B move-result v8 and-int/lit16 v8, v8, 0xff if-ne v7, v8, :cond_2a add-int/lit8 v4, v4, 0x1 goto :goto_15 :cond_2a if-ge v7, v8, :cond_2e :goto_2c move v3, v6 goto :goto_36 :cond_2e move v3, v5 goto :goto_36 :cond_30 if-ne v0, v1, :cond_33 goto :goto_36 :cond_33 if-ge v0, v1, :cond_2e goto :goto_2c :goto_36 return v3 .end method .method public getSize()I .registers 2 iget-object v0, p0, Lconditions/TestBadBranches;->data:[B array-length v0, v0 return v0 .end method .method public get(I)B .registers 3 iget-object v0, p0, Lconditions/TestBadBranches;->data:[B aget-byte p1, v0, p1 return p1 .end method ```

Actual result

```java package conditions; import kotlin.jvm.internal.Intrinsics; /* loaded from: .\conditions\TestBadBranches.smali */ public class TestBadBranches { public final byte[] data; public TestBadBranches(byte[] bArr) { Intrinsics.checkNotNullParameter(bArr, "data"); this.data = bArr; } /* JADX WARN: Code restructure failed: missing block: B:10:0x0036, code lost: return -1; */ /* JADX WARN: Code restructure failed: missing block: B:13:?, code lost: return 1; */ /* JADX WARN: Code restructure failed: missing block: B:16:0x0033, code lost: if (r0 < r1) goto L9; */ /* JADX WARN: Code restructure failed: missing block: B:8:0x002a, code lost: if (r7 < r8) goto L9; */ /* Code decompiled incorrectly, please refer to instructions dump. */ public final int compareTo(Object obj) { TestBadBranches testBadBranches = (TestBadBranches) obj; Intrinsics.checkNotNullParameter(testBadBranches, "other"); int size = getSize(); int size2 = testBadBranches.getSize(); int min = Math.min(size, size2); for (int i = 0; i < min; i++) { int i2 = get(i) & 255; int i3 = testBadBranches.get(i) & 255; if (i2 == i3) { } } if (size == size2) { return 0; } } public byte get(int i) { return this.data[i]; } public int getSize() { return this.data.length; } } ```