BSDiff.smali

.class public Lcom/tencent/tinker/bsdiff/BSDiff;
.super Ljava/lang/Object;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;
    }
.end annotation


# static fields
.field private static final MAGIC_BYTES:[B


# direct methods
.method static constructor <clinit>()V
    .registers 1

    const/16 v0, 0x8

    new-array v0, v0, [B

    fill-array-data v0, :array_a

    sput-object v0, Lcom/tencent/tinker/bsdiff/BSDiff;->MAGIC_BYTES:[B

    return-void

    :array_a
    .array-data 1
        0x4dt
        0x69t
        0x63t
        0x72t
        0x6ft
        0x4dt
        0x73t
        0x67t
    .end array-data
.end method

.method public constructor <init>()V
    .registers 1

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static bsdiff(Ljava/io/File;Ljava/io/File;Ljava/io/File;)V
    .registers 9

    new-instance v0, Ljava/io/BufferedInputStream;

    new-instance v1, Ljava/io/FileInputStream;

    invoke-direct {v1, p0}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V

    invoke-direct {v0, v1}, Ljava/io/BufferedInputStream;-><init>(Ljava/io/InputStream;)V

    new-instance v1, Ljava/io/BufferedInputStream;

    new-instance v2, Ljava/io/FileInputStream;

    invoke-direct {v2, p1}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V

    invoke-direct {v1, v2}, Ljava/io/BufferedInputStream;-><init>(Ljava/io/InputStream;)V

    new-instance v2, Ljava/io/FileOutputStream;

    invoke-direct {v2, p2}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    :try_start_19
    invoke-virtual {p0}, Ljava/io/File;->length()J

    move-result-wide v4

    long-to-int v3, v4

    invoke-virtual {p1}, Ljava/io/File;->length()J

    move-result-wide v4

    long-to-int v4, v4

    invoke-static {v0, v3, v1, v4}, Lcom/tencent/tinker/bsdiff/BSDiff;->bsdiff(Ljava/io/InputStream;ILjava/io/InputStream;I)[B

    move-result-object v0

    invoke-virtual {v2, v0}, Ljava/io/OutputStream;->write([B)V
    :try_end_2a
    .catchall {:try_start_19 .. :try_end_2a} :catchall_2e

    invoke-virtual {v2}, Ljava/io/OutputStream;->close()V

    return-void

    :catchall_2e
    move-exception v0

    invoke-virtual {v2}, Ljava/io/OutputStream;->close()V

    throw v0
.end method

.method public static bsdiff(Ljava/io/InputStream;ILjava/io/InputStream;I)[B
    .registers 7

    const/4 v2, 0x0

    new-array v0, p1, [B

    invoke-static {p0, v0, v2, p1}, Lcom/tencent/tinker/bsdiff/BSUtil;->readFromStream(Ljava/io/InputStream;[BII)Z

    invoke-virtual {p0}, Ljava/io/InputStream;->close()V

    new-array v1, p3, [B

    invoke-static {p2, v1, v2, p3}, Lcom/tencent/tinker/bsdiff/BSUtil;->readFromStream(Ljava/io/InputStream;[BII)Z

    invoke-virtual {p2}, Ljava/io/InputStream;->close()V

    invoke-static {v0, p1, v1, p3}, Lcom/tencent/tinker/bsdiff/BSDiff;->bsdiff([BI[BI)[B

    move-result-object v0

    return-object v0
.end method

.method public static bsdiff([BI[BI)[B
    .registers 30

    add-int/lit8 v2, p1, 0x1

    new-array v2, v2, [I

    add-int/lit8 v3, p1, 0x1

    new-array v3, v3, [I

    move-object/from16 v0, p0

    move/from16 v1, p1

    invoke-static {v2, v3, v0, v1}, Lcom/tencent/tinker/bsdiff/BSDiff;->qsufsort([I[I[BI)V

    const/4 v8, 0x0

    move/from16 v0, p3

    new-array v0, v0, [B

    move-object/from16 v18, v0

    const/4 v6, 0x0

    move/from16 v0, p3

    new-array v0, v0, [B

    move-object/from16 v19, v0

    new-instance v20, Ljava/io/ByteArrayOutputStream;

    invoke-direct/range {v20 .. v20}, Ljava/io/ByteArrayOutputStream;-><init>()V

    new-instance v21, Ljava/io/DataOutputStream;

    move-object/from16 v0, v21

    move-object/from16 v1, v20

    invoke-direct {v0, v1}, Ljava/io/DataOutputStream;-><init>(Ljava/io/OutputStream;)V

    sget-object v3, Lcom/tencent/tinker/bsdiff/BSDiff;->MAGIC_BYTES:[B

    move-object/from16 v0, v21

    invoke-virtual {v0, v3}, Ljava/io/DataOutputStream;->write([B)V

    const-wide/16 v4, -0x1

    move-object/from16 v0, v21

    invoke-virtual {v0, v4, v5}, Ljava/io/DataOutputStream;->writeLong(J)V

    const-wide/16 v4, -0x1

    move-object/from16 v0, v21

    invoke-virtual {v0, v4, v5}, Ljava/io/DataOutputStream;->writeLong(J)V

    move/from16 v0, p3

    int-to-long v4, v0

    move-object/from16 v0, v21

    invoke-virtual {v0, v4, v5}, Ljava/io/DataOutputStream;->writeLong(J)V

    invoke-virtual/range {v21 .. v21}, Ljava/io/DataOutputStream;->flush()V

    new-instance v22, Ljava/util/zip/GZIPOutputStream;

    move-object/from16 v0, v22

    move-object/from16 v1, v21

    invoke-direct {v0, v1}, Ljava/util/zip/GZIPOutputStream;-><init>(Ljava/io/OutputStream;)V

    new-instance v23, Ljava/io/DataOutputStream;

    move-object/from16 v0, v23

    move-object/from16 v1, v22

    invoke-direct {v0, v1}, Ljava/io/DataOutputStream;-><init>(Ljava/io/OutputStream;)V

    const/4 v7, 0x0

    const/4 v12, 0x0

    const/4 v5, 0x0

    const/4 v4, 0x0

    const/4 v3, 0x0

    new-instance v10, Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;

    const/4 v9, 0x0

    invoke-direct {v10, v9}, Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;-><init>(Lcom/tencent/tinker/bsdiff/BSDiff$1;)V

    move v13, v3

    move v14, v4

    move v15, v5

    move/from16 v16, v6

    move/from16 v17, v8

    move v3, v12

    :goto_70
    move/from16 v0, p3

    if-ge v7, v0, :cond_1d7

    const/4 v11, 0x0

    add-int/2addr v7, v3

    move v12, v7

    :goto_77
    move/from16 v0, p3

    if-ge v7, v0, :cond_259

    const/4 v8, 0x0

    move-object/from16 v3, p0

    move/from16 v4, p1

    move-object/from16 v5, p2

    move/from16 v6, p3

    move/from16 v9, p1

    invoke-static/range {v2 .. v10}, Lcom/tencent/tinker/bsdiff/BSDiff;->search([I[BI[BIIIILcom/tencent/tinker/bsdiff/BSDiff$IntByRef;)I

    move-result v4

    move v5, v12

    move v3, v11

    :goto_8c
    add-int v6, v7, v4

    if-ge v5, v6, :cond_a3

    add-int v6, v5, v13

    move/from16 v0, p1

    if-ge v6, v0, :cond_a0

    add-int v6, v5, v13

    aget-byte v6, p0, v6

    aget-byte v8, p2, v5

    if-ne v6, v8, :cond_a0

    add-int/lit8 v3, v3, 0x1

    :cond_a0
    add-int/lit8 v5, v5, 0x1

    goto :goto_8c

    :cond_a3
    if-ne v4, v3, :cond_a7

    if-nez v4, :cond_256

    :cond_a7
    add-int/lit8 v6, v3, 0x8

    if-le v4, v6, :cond_df

    move v12, v4

    :goto_ac
    if-ne v12, v3, :cond_b2

    move/from16 v0, p3

    if-ne v7, v0, :cond_253

    :cond_b2
    const/4 v4, 0x0

    const/4 v3, 0x0

    const/4 v9, 0x0

    const/4 v5, 0x0

    move/from16 v25, v3

    move v3, v4

    move v4, v5

    move/from16 v5, v25

    :cond_bc
    :goto_bc
    add-int v6, v15, v4

    if-ge v6, v7, :cond_f5

    add-int v6, v14, v4

    move/from16 v0, p1

    if-ge v6, v0, :cond_f5

    add-int v6, v14, v4

    aget-byte v6, p0, v6

    add-int v8, v15, v4

    aget-byte v8, p2, v8

    if-ne v6, v8, :cond_d2

    add-int/lit8 v3, v3, 0x1

    :cond_d2
    add-int/lit8 v4, v4, 0x1

    mul-int/lit8 v6, v3, 0x2

    sub-int/2addr v6, v4

    mul-int/lit8 v8, v5, 0x2

    sub-int/2addr v8, v9

    if-le v6, v8, :cond_bc

    move v9, v4

    move v5, v3

    goto :goto_bc

    :cond_df
    add-int v6, v7, v13

    move/from16 v0, p1

    if-ge v6, v0, :cond_ef

    add-int v6, v7, v13

    aget-byte v6, p0, v6

    aget-byte v8, p2, v7

    if-ne v6, v8, :cond_ef

    add-int/lit8 v3, v3, -0x1

    :cond_ef
    add-int/lit8 v7, v7, 0x1

    move v12, v5

    move v11, v3

    move v3, v4

    goto :goto_77

    :cond_f5
    const/4 v5, 0x0

    move/from16 v0, p3

    if-ge v7, v0, :cond_123

    const/4 v4, 0x0

    const/4 v3, 0x0

    const/4 v6, 0x1

    :goto_fd
    add-int v8, v15, v6

    if-lt v7, v8, :cond_123

    # getter for: Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->value:I
    invoke-static {v10}, Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->access$000(Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;)I

    move-result v8

    if-lt v8, v6, :cond_123

    # getter for: Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->value:I
    invoke-static {v10}, Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->access$000(Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;)I

    move-result v8

    sub-int/2addr v8, v6

    aget-byte v8, p0, v8

    sub-int v11, v7, v6

    aget-byte v11, p2, v11

    if-ne v8, v11, :cond_116

    add-int/lit8 v4, v4, 0x1

    :cond_116
    mul-int/lit8 v8, v4, 0x2

    sub-int/2addr v8, v6

    mul-int/lit8 v11, v3, 0x2

    sub-int/2addr v11, v5

    if-le v8, v11, :cond_120

    move v3, v4

    move v5, v6

    :cond_120
    add-int/lit8 v6, v6, 0x1

    goto :goto_fd

    :cond_123
    move v8, v5

    add-int v3, v15, v9

    sub-int v4, v7, v8

    if-le v3, v4, :cond_24f

    add-int v3, v15, v9

    sub-int v4, v7, v8

    sub-int v13, v3, v4

    const/4 v3, 0x0

    const/4 v6, 0x0

    const/4 v5, 0x0

    const/4 v4, 0x0

    move v11, v4

    move v4, v5

    :goto_136
    if-ge v11, v13, :cond_16d

    add-int v5, v15, v9

    sub-int/2addr v5, v13

    add-int/2addr v5, v11

    aget-byte v5, p2, v5

    add-int v24, v14, v9

    sub-int v24, v24, v13

    add-int v24, v24, v11

    aget-byte v24, p0, v24

    move/from16 v0, v24

    if-ne v5, v0, :cond_14c

    add-int/lit8 v3, v3, 0x1

    :cond_14c
    sub-int v5, v7, v8

    add-int/2addr v5, v11

    aget-byte v5, p2, v5

    # getter for: Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->value:I
    invoke-static {v10}, Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->access$000(Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;)I

    move-result v24

    sub-int v24, v24, v8

    add-int v24, v24, v11

    aget-byte v24, p0, v24

    move/from16 v0, v24

    if-ne v5, v0, :cond_24c

    add-int/lit8 v5, v3, -0x1

    :goto_161
    if-le v5, v6, :cond_248

    add-int/lit8 v3, v11, 0x1

    move v4, v5

    :goto_166
    add-int/lit8 v6, v11, 0x1

    move v11, v6

    move v6, v4

    move v4, v3

    move v3, v5

    goto :goto_136

    :cond_16d
    sub-int v3, v4, v13

    add-int v5, v9, v3

    sub-int v3, v8, v4

    move v4, v5

    :goto_174
    const/4 v5, 0x0

    :goto_175
    if-ge v5, v4, :cond_188

    add-int v6, v17, v5

    add-int v8, v15, v5

    aget-byte v8, p2, v8

    add-int v9, v14, v5

    aget-byte v9, p0, v9

    sub-int/2addr v8, v9

    int-to-byte v8, v8

    aput-byte v8, v18, v6

    add-int/lit8 v5, v5, 0x1

    goto :goto_175

    :cond_188
    const/4 v5, 0x0

    :goto_189
    sub-int v6, v7, v3

    add-int v8, v15, v4

    sub-int/2addr v6, v8

    if-ge v5, v6, :cond_19c

    add-int v6, v16, v5

    add-int v8, v15, v4

    add-int/2addr v8, v5

    aget-byte v8, p2, v8

    aput-byte v8, v19, v6

    add-int/lit8 v5, v5, 0x1

    goto :goto_189

    :cond_19c
    add-int v8, v17, v4

    sub-int v5, v7, v3

    add-int v6, v15, v4

    sub-int/2addr v5, v6

    add-int v6, v16, v5

    move-object/from16 v0, v23

    invoke-virtual {v0, v4}, Ljava/io/DataOutputStream;->writeInt(I)V

    sub-int v5, v7, v3

    add-int v9, v15, v4

    sub-int/2addr v5, v9

    move-object/from16 v0, v23

    invoke-virtual {v0, v5}, Ljava/io/DataOutputStream;->writeInt(I)V

    # getter for: Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->value:I
    invoke-static {v10}, Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->access$000(Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;)I

    move-result v5

    sub-int/2addr v5, v3

    add-int/2addr v4, v14

    sub-int v4, v5, v4

    move-object/from16 v0, v23

    invoke-virtual {v0, v4}, Ljava/io/DataOutputStream;->writeInt(I)V

    sub-int v5, v7, v3

    # getter for: Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->value:I
    invoke-static {v10}, Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->access$000(Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;)I

    move-result v4

    sub-int/2addr v4, v3

    # getter for: Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->value:I
    invoke-static {v10}, Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->access$000(Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;)I

    move-result v3

    sub-int/2addr v3, v7

    move v13, v3

    move v14, v4

    move v15, v5

    move/from16 v16, v6

    move/from16 v17, v8

    move v3, v12

    goto/16 :goto_70

    :cond_1d7
    invoke-virtual/range {v23 .. v23}, Ljava/io/DataOutputStream;->flush()V

    invoke-virtual/range {v22 .. v22}, Ljava/util/zip/GZIPOutputStream;->finish()V

    invoke-virtual/range {v21 .. v21}, Ljava/io/DataOutputStream;->size()I

    move-result v2

    add-int/lit8 v2, v2, -0x20

    new-instance v3, Ljava/util/zip/GZIPOutputStream;

    move-object/from16 v0, v21

    invoke-direct {v3, v0}, Ljava/util/zip/GZIPOutputStream;-><init>(Ljava/io/OutputStream;)V

    const/4 v4, 0x0

    move-object/from16 v0, v18

    move/from16 v1, v17

    invoke-virtual {v3, v0, v4, v1}, Ljava/util/zip/GZIPOutputStream;->write([BII)V

    invoke-virtual {v3}, Ljava/util/zip/GZIPOutputStream;->finish()V

    invoke-virtual {v3}, Ljava/util/zip/GZIPOutputStream;->flush()V

    invoke-virtual/range {v21 .. v21}, Ljava/io/DataOutputStream;->size()I

    move-result v3

    sub-int/2addr v3, v2

    add-int/lit8 v3, v3, -0x20

    new-instance v4, Ljava/util/zip/GZIPOutputStream;

    move-object/from16 v0, v21

    invoke-direct {v4, v0}, Ljava/util/zip/GZIPOutputStream;-><init>(Ljava/io/OutputStream;)V

    const/4 v5, 0x0

    move-object/from16 v0, v19

    move/from16 v1, v16

    invoke-virtual {v4, v0, v5, v1}, Ljava/util/zip/GZIPOutputStream;->write([BII)V

    invoke-virtual {v4}, Ljava/util/zip/GZIPOutputStream;->finish()V

    invoke-virtual {v4}, Ljava/util/zip/GZIPOutputStream;->flush()V

    invoke-virtual/range {v21 .. v21}, Ljava/io/DataOutputStream;->close()V

    new-instance v4, Ljava/io/ByteArrayOutputStream;

    const/16 v5, 0x20

    invoke-direct {v4, v5}, Ljava/io/ByteArrayOutputStream;-><init>(I)V

    new-instance v5, Ljava/io/DataOutputStream;

    invoke-direct {v5, v4}, Ljava/io/DataOutputStream;-><init>(Ljava/io/OutputStream;)V

    sget-object v6, Lcom/tencent/tinker/bsdiff/BSDiff;->MAGIC_BYTES:[B

    invoke-virtual {v5, v6}, Ljava/io/DataOutputStream;->write([B)V

    int-to-long v6, v2

    invoke-virtual {v5, v6, v7}, Ljava/io/DataOutputStream;->writeLong(J)V

    int-to-long v2, v3

    invoke-virtual {v5, v2, v3}, Ljava/io/DataOutputStream;->writeLong(J)V

    move/from16 v0, p3

    int-to-long v2, v0

    invoke-virtual {v5, v2, v3}, Ljava/io/DataOutputStream;->writeLong(J)V

    invoke-virtual {v5}, Ljava/io/DataOutputStream;->close()V

    invoke-virtual/range {v20 .. v20}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B

    move-result-object v2

    invoke-virtual {v4}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B

    move-result-object v3

    const/4 v4, 0x0

    const/4 v5, 0x0

    array-length v6, v3

    invoke-static {v3, v4, v2, v5, v6}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V

    return-object v2

    :cond_248
    move v3, v4

    move v4, v6

    goto/16 :goto_166

    :cond_24c
    move v5, v3

    goto/16 :goto_161

    :cond_24f
    move v3, v8

    move v4, v9

    goto/16 :goto_174

    :cond_253
    move v3, v12

    goto/16 :goto_70

    :cond_256
    move v12, v4

    goto/16 :goto_ac

    :cond_259
    move v12, v3

    move v3, v11

    goto/16 :goto_ac
.end method

.method private static matchlen([BII[BII)I
    .registers 10

    sub-int v0, p1, p2

    sub-int v1, p4, p5

    invoke-static {v0, v1}, Ljava/lang/Math;->min(II)I

    move-result v1

    const/4 v0, 0x0

    :goto_9
    if-ge v0, v1, :cond_19

    add-int v2, p2, v0

    aget-byte v2, p0, v2

    add-int v3, p5, v0

    aget-byte v3, p3, v3

    if-eq v2, v3, :cond_16

    :goto_15
    return v0

    :cond_16
    add-int/lit8 v0, v0, 0x1

    goto :goto_9

    :cond_19
    move v0, v1

    goto :goto_15
.end method

.method private static memcmp([BII[BII)I
    .registers 11

    const/4 v1, 0x0

    sub-int v0, p1, p2

    sub-int v2, p4, p5

    if-le v0, v2, :cond_9

    sub-int v0, p4, p5

    :cond_9
    move v2, v1

    :goto_a
    if-ge v2, v0, :cond_27

    add-int v3, v2, p2

    aget-byte v3, p0, v3

    add-int v4, v2, p5

    aget-byte v4, p3, v4

    if-eq v3, v4, :cond_24

    add-int v0, v2, p2

    aget-byte v0, p0, v0

    add-int v1, v2, p5

    aget-byte v1, p3, v1

    if-ge v0, v1, :cond_22

    const/4 v0, -0x1

    :goto_21
    return v0

    :cond_22
    const/4 v0, 0x1

    goto :goto_21

    :cond_24
    add-int/lit8 v2, v2, 0x1

    goto :goto_a

    :cond_27
    move v0, v1

    goto :goto_21
.end method

.method private static qsufsort([I[I[BI)V
    .registers 12

    const/4 v7, -0x1

    const/16 v6, 0x100

    const/4 v0, 0x1

    const/4 v1, 0x0

    new-array v3, v6, [I

    move v2, v1

    :goto_8
    if-ge v2, p3, :cond_17

    aget-byte v4, p2, v2

    and-int/lit16 v4, v4, 0xff

    aget v5, v3, v4

    add-int/lit8 v5, v5, 0x1

    aput v5, v3, v4

    add-int/lit8 v2, v2, 0x1

    goto :goto_8

    :cond_17
    move v2, v0

    :goto_18
    if-ge v2, v6, :cond_26

    aget v4, v3, v2

    add-int/lit8 v5, v2, -0x1

    aget v5, v3, v5

    add-int/2addr v4, v5

    aput v4, v3, v2

    add-int/lit8 v2, v2, 0x1

    goto :goto_18

    :cond_26
    const/16 v2, 0xff

    :goto_28
    if-lez v2, :cond_33

    add-int/lit8 v4, v2, -0x1

    aget v4, v3, v4

    aput v4, v3, v2

    add-int/lit8 v2, v2, -0x1

    goto :goto_28

    :cond_33
    aput v1, v3, v1

    move v2, v1

    :goto_36
    if-ge v2, p3, :cond_47

    aget-byte v4, p2, v2

    and-int/lit16 v4, v4, 0xff

    aget v5, v3, v4

    add-int/lit8 v5, v5, 0x1

    aput v5, v3, v4

    aput v2, p0, v5

    add-int/lit8 v2, v2, 0x1

    goto :goto_36

    :cond_47
    aput p3, p0, v1

    move v2, v1

    :goto_4a
    if-ge v2, p3, :cond_57

    aget-byte v4, p2, v2

    and-int/lit16 v4, v4, 0xff

    aget v4, v3, v4

    aput v4, p1, v2

    add-int/lit8 v2, v2, 0x1

    goto :goto_4a

    :cond_57
    aput v1, p1, p3

    move v2, v0

    :goto_5a
    if-ge v2, v6, :cond_6d

    aget v4, v3, v2

    add-int/lit8 v5, v2, -0x1

    aget v5, v3, v5

    add-int/lit8 v5, v5, 0x1

    if-ne v4, v5, :cond_6a

    aget v4, v3, v2

    aput v7, p0, v4

    :cond_6a
    add-int/lit8 v2, v2, 0x1

    goto :goto_5a

    :cond_6d
    aput v7, p0, v1

    :goto_6f
    aget v2, p0, v1

    add-int/lit8 v3, p3, 0x1

    neg-int v3, v3

    if-eq v2, v3, :cond_a3

    move v2, v1

    move v3, v1

    :goto_78
    add-int/lit8 v4, p3, 0x1

    if-ge v2, v4, :cond_9b

    aget v4, p0, v2

    if-gez v4, :cond_87

    aget v4, p0, v2

    sub-int/2addr v3, v4

    aget v4, p0, v2

    sub-int/2addr v2, v4

    goto :goto_78

    :cond_87
    if-eqz v3, :cond_8e

    sub-int v4, v2, v3

    neg-int v3, v3

    aput v3, p0, v4

    :cond_8e
    aget v3, p0, v2

    aget v3, p1, v3

    add-int/lit8 v3, v3, 0x1

    sub-int/2addr v3, v2

    invoke-static {p0, p1, v2, v3, v0}, Lcom/tencent/tinker/bsdiff/BSDiff;->split([I[IIII)V

    add-int/2addr v2, v3

    move v3, v1

    goto :goto_78

    :cond_9b
    if-eqz v3, :cond_a1

    sub-int/2addr v2, v3

    neg-int v3, v3

    aput v3, p0, v2

    :cond_a1
    add-int/2addr v0, v0

    goto :goto_6f

    :cond_a3
    move v0, v1

    :goto_a4
    add-int/lit8 v1, p3, 0x1

    if-ge v0, v1, :cond_af

    aget v1, p1, v0

    aput v0, p0, v1

    add-int/lit8 v0, v0, 0x1

    goto :goto_a4

    :cond_af
    return-void
.end method

.method private static search([I[BI[BIIIILcom/tencent/tinker/bsdiff/BSDiff$IntByRef;)I
    .registers 26

    sub-int v1, p7, p6

    const/4 v2, 0x2

    if-ge v1, v2, :cond_38

    aget v3, p0, p6

    move-object/from16 v1, p1

    move/from16 v2, p2

    move-object/from16 v4, p3

    move/from16 v5, p4

    move/from16 v6, p5

    invoke-static/range {v1 .. v6}, Lcom/tencent/tinker/bsdiff/BSDiff;->matchlen([BII[BII)I

    move-result v7

    aget v3, p0, p7

    move-object/from16 v1, p1

    move/from16 v2, p2

    move-object/from16 v4, p3

    move/from16 v5, p4

    move/from16 v6, p5

    invoke-static/range {v1 .. v6}, Lcom/tencent/tinker/bsdiff/BSDiff;->matchlen([BII[BII)I

    move-result v1

    if-le v7, v1, :cond_30

    aget v1, p0, p6

    move-object/from16 v0, p8

    # setter for: Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->value:I
    invoke-static {v0, v1}, Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->access$002(Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;I)I

    move v1, v7

    :goto_2f
    return v1

    :cond_30
    aget v2, p0, p7

    move-object/from16 v0, p8

    # setter for: Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->value:I
    invoke-static {v0, v2}, Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;->access$002(Lcom/tencent/tinker/bsdiff/BSDiff$IntByRef;I)I

    goto :goto_2f

    :cond_38
    sub-int v1, p7, p6

    div-int/lit8 v1, v1, 0x2

    add-int v7, p6, v1

    aget v3, p0, v7

    move-object/from16 v1, p1

    move/from16 v2, p2

    move-object/from16 v4, p3

    move/from16 v5, p4

    move/from16 v6, p5

    invoke-static/range {v1 .. v6}, Lcom/tencent/tinker/bsdiff/BSDiff;->memcmp([BII[BII)I

    move-result v1

    if-gez v1, :cond_65

    move-object/from16 v1, p0

    move-object/from16 v2, p1

    move/from16 v3, p2

    move-object/from16 v4, p3

    move/from16 v5, p4

    move/from16 v6, p5

    move/from16 v8, p7

    move-object/from16 v9, p8

    invoke-static/range {v1 .. v9}, Lcom/tencent/tinker/bsdiff/BSDiff;->search([I[BI[BIIIILcom/tencent/tinker/bsdiff/BSDiff$IntByRef;)I

    move-result v1

    goto :goto_2f

    :cond_65
    move-object/from16 v8, p0

    move-object/from16 v9, p1

    move/from16 v10, p2

    move-object/from16 v11, p3

    move/from16 v12, p4

    move/from16 v13, p5

    move/from16 v14, p6

    move v15, v7

    move-object/from16 v16, p8

    invoke-static/range {v8 .. v16}, Lcom/tencent/tinker/bsdiff/BSDiff;->search([I[BI[BIIIILcom/tencent/tinker/bsdiff/BSDiff$IntByRef;)I

    move-result v1

    goto :goto_2f
.end method

.method private static split([I[IIII)V
    .registers 15

    const/4 v9, -0x1

    const/4 v3, 0x1

    const/4 v2, 0x0

    const/16 v0, 0x10

    if-ge p3, v0, :cond_60

    move v5, p2

    :goto_8
    add-int v0, p2, p3

    if-ge v5, v0, :cond_105

    aget v0, p0, v5

    add-int/2addr v0, p4

    aget v0, p1, v0

    move v1, v3

    move v4, v3

    :goto_13
    add-int v6, v5, v4

    add-int v7, p2, p3

    if-ge v6, v7, :cond_48

    add-int v6, v5, v4

    aget v6, p0, v6

    add-int/2addr v6, p4

    aget v6, p1, v6

    if-ge v6, v0, :cond_2a

    add-int v0, v5, v4

    aget v0, p0, v0

    add-int/2addr v0, p4

    aget v0, p1, v0

    move v1, v2

    :cond_2a
    add-int v6, v5, v4

    aget v6, p0, v6

    add-int/2addr v6, p4

    aget v6, p1, v6

    if-ne v6, v0, :cond_45

    add-int v6, v5, v1

    aget v6, p0, v6

    add-int v7, v5, v1

    add-int v8, v5, v4

    aget v8, p0, v8

    aput v8, p0, v7

    add-int v7, v5, v4

    aput v6, p0, v7

    add-int/lit8 v1, v1, 0x1

    :cond_45
    add-int/lit8 v4, v4, 0x1

    goto :goto_13

    :cond_48
    move v0, v2

    :goto_49
    if-ge v0, v1, :cond_58

    add-int v4, v5, v0

    aget v4, p0, v4

    add-int v6, v5, v1

    add-int/lit8 v6, v6, -0x1

    aput v6, p1, v4

    add-int/lit8 v0, v0, 0x1

    goto :goto_49

    :cond_58
    if-ne v1, v3, :cond_5c

    aput v9, p0, v5

    :cond_5c
    add-int v0, v5, v1

    move v5, v0

    goto :goto_8

    :cond_60
    div-int/lit8 v0, p3, 0x2

    add-int/2addr v0, p2

    aget v0, p0, v0

    add-int/2addr v0, p4

    aget v4, p1, v0

    move v1, v2

    move v0, v2

    move v3, p2

    :goto_6b
    add-int v5, p2, p3

    if-ge v3, v5, :cond_84

    aget v5, p0, v3

    add-int/2addr v5, p4

    aget v5, p1, v5

    if-ge v5, v4, :cond_78

    add-int/lit8 v0, v0, 0x1

    :cond_78
    aget v5, p0, v3

    add-int/2addr v5, p4

    aget v5, p1, v5

    if-ne v5, v4, :cond_81

    add-int/lit8 v1, v1, 0x1

    :cond_81
    add-int/lit8 v3, v3, 0x1

    goto :goto_6b

    :cond_84
    add-int v5, v0, p2

    add-int v6, v1, v5

    move v0, v2

    move v1, v2

    move v3, p2

    :goto_8b
    if-ge v3, v5, :cond_bc

    aget v7, p0, v3

    add-int/2addr v7, p4

    aget v7, p1, v7

    if-ge v7, v4, :cond_97

    add-int/lit8 v3, v3, 0x1

    goto :goto_8b

    :cond_97
    aget v7, p0, v3

    add-int/2addr v7, p4

    aget v7, p1, v7

    if-ne v7, v4, :cond_ad

    aget v7, p0, v3

    add-int v8, v5, v1

    aget v8, p0, v8

    aput v8, p0, v3

    add-int v8, v5, v1

    aput v7, p0, v8

    add-int/lit8 v1, v1, 0x1

    goto :goto_8b

    :cond_ad
    aget v7, p0, v3

    add-int v8, v6, v0

    aget v8, p0, v8

    aput v8, p0, v3

    add-int v8, v6, v0

    aput v7, p0, v8

    add-int/lit8 v0, v0, 0x1

    goto :goto_8b

    :cond_bc
    :goto_bc
    add-int v3, v5, v1

    if-ge v3, v6, :cond_df

    add-int v3, v5, v1

    aget v3, p0, v3

    add-int/2addr v3, p4

    aget v3, p1, v3

    if-ne v3, v4, :cond_cc

    add-int/lit8 v1, v1, 0x1

    goto :goto_bc

    :cond_cc
    add-int v3, v5, v1

    aget v3, p0, v3

    add-int v7, v5, v1

    add-int v8, v6, v0

    aget v8, p0, v8

    aput v8, p0, v7

    add-int v7, v6, v0

    aput v3, p0, v7

    add-int/lit8 v0, v0, 0x1

    goto :goto_bc

    :cond_df
    if-le v5, p2, :cond_e6

    sub-int v0, v5, p2

    invoke-static {p0, p1, p2, v0, p4}, Lcom/tencent/tinker/bsdiff/BSDiff;->split([I[IIII)V

    :cond_e6
    :goto_e6
    sub-int v0, v6, v5

    if-ge v2, v0, :cond_f5

    add-int v0, v5, v2

    aget v0, p0, v0

    add-int/lit8 v1, v6, -0x1

    aput v1, p1, v0

    add-int/lit8 v2, v2, 0x1

    goto :goto_e6

    :cond_f5
    add-int/lit8 v0, v6, -0x1

    if-ne v5, v0, :cond_fb

    aput v9, p0, v5

    :cond_fb
    add-int v0, p2, p3

    if-le v0, v6, :cond_105

    add-int v0, p2, p3

    sub-int/2addr v0, v6

    invoke-static {p0, p1, v6, v0, p4}, Lcom/tencent/tinker/bsdiff/BSDiff;->split([I[IIII)V

    :cond_105
    return-void
.end method