package g.i.a.c.q;

import io.netty.handler.codec.dns.DnsRecord;
import io.netty.handler.codec.memcache.binary.BinaryMemcacheOpcodes;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;

/* JADX INFO: loaded from: classes.dex */
public class d {
    public byte[] A;
    public byte[] D;
    public int E;
    public int F;
    public int G;
    public int H;
    public int I;
    public int J;
    public int K;
    public boolean N;
    public byte[] P;
    public List<h> Q;
    public byte[] R;
    public List<h> S;
    public byte[] T;
    public List<b> U;
    public int V;
    public int W;
    public int a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public boolean f5666b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f5667c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f5668d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f5669e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f5670f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public boolean f5671g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f5672h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f5673i;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f5676l;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public boolean f5680p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public boolean f5681q;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public boolean f5683s;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public boolean f5686v;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f5674j = 3;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f5675k = 0;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f5677m = 0;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public int f5678n = 0;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public int f5679o = 2;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f5682r = 1;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public int f5684t = 0;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public boolean f5685u = true;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public int f5687w = 0;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public int f5688x = 0;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public int f5689y = 0;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public boolean f5690z = false;
    public int B = 256;
    public int C = 0;
    public int L = 0;
    public int M = 1;
    public int O = 0;

    public final void a() {
        if (!this.N) {
            if (this.f5684t != 1) {
                this.M = 1;
                return;
            } else if (this.C != 0) {
                this.M = 3;
                return;
            }
        }
        this.M = 2;
    }

    public void b(byte[] bArr, int i2) {
        int length = bArr.length - i2;
        byte[] bArr2 = this.P;
        if (bArr2 == null || bArr2.length <= 0) {
            byte[] bArr3 = new byte[length];
            this.P = bArr3;
            System.arraycopy(bArr, i2, bArr3, 0, length);
        } else {
            byte[] bArr4 = new byte[bArr2.length + length];
            System.arraycopy(bArr2, 0, bArr4, 0, bArr2.length);
            System.arraycopy(bArr, i2, bArr4, this.P.length, length);
            this.P = bArr4;
        }
        i();
    }

    public void c(int i2, byte[] bArr) {
        if (this.U == null) {
            this.U = new ArrayList();
        }
        this.U.add(new b(i2, bArr));
    }

    public void d(byte[] bArr) {
        byte[] bArr2 = this.T;
        if (bArr2 == null || bArr2.length <= 0) {
            this.T = bArr;
        } else {
            byte[] bArr3 = new byte[bArr2.length + bArr.length];
            System.arraycopy(bArr2, 0, bArr3, 0, bArr2.length);
            System.arraycopy(bArr, 0, bArr3, this.T.length, bArr.length);
            this.T = bArr3;
        }
        i();
    }

    /* JADX WARN: Code restructure failed: missing block: B:10:0x0012, code lost:
    
        b(r5, 1);
     */
    /* JADX WARN: Code restructure failed: missing block: B:11:0x0016, code lost:
    
        f(r5, 1);
     */
    /* JADX WARN: Code restructure failed: missing block: B:22:0x002c, code lost:
    
        if (r5[0] == 0) goto L10;
     */
    /* JADX WARN: Code restructure failed: missing block: B:29:?, code lost:
    
        return;
     */
    /* JADX WARN: Code restructure failed: missing block: B:30:?, code lost:
    
        return;
     */
    /* JADX WARN: Code restructure failed: missing block: B:9:0x0010, code lost:
    
        if (r5[0] == 0) goto L10;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void e(byte[] r5) {
        /*
            r4 = this;
            int r0 = r4.a
            r1 = 0
            r2 = 1
            r3 = 20
            if (r0 != r3) goto L1b
            if (r5 == 0) goto L1a
            int r0 = r5.length
            if (r0 >= r2) goto Le
            goto L1a
        Le:
            r0 = r5[r1]
            if (r0 != 0) goto L16
        L12:
            r4.b(r5, r2)
            goto L33
        L16:
            r4.f(r5, r2)
            goto L33
        L1a:
            return
        L1b:
            r3 = 17
            if (r0 != r3) goto L30
            int r0 = r4.f5675k
            r3 = 6
            if (r0 < r3) goto L30
            if (r5 == 0) goto L2f
            int r0 = r5.length
            if (r0 >= r2) goto L2a
            goto L2f
        L2a:
            r0 = r5[r1]
            if (r0 != 0) goto L16
            goto L12
        L2f:
            return
        L30:
            r4.b(r5, r1)
        L33:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: g.i.a.c.q.d.e(byte[]):void");
    }

    public void f(byte[] bArr, int i2) {
        int length = bArr.length - i2;
        byte[] bArr2 = this.R;
        if (bArr2 == null || bArr2.length <= 0) {
            byte[] bArr3 = new byte[length];
            this.R = bArr3;
            System.arraycopy(bArr, i2, bArr3, 0, length);
        } else {
            byte[] bArr4 = new byte[bArr2.length + bArr.length];
            System.arraycopy(bArr2, 0, bArr4, 0, bArr2.length);
            System.arraycopy(bArr, i2, bArr4, this.R.length, bArr.length - i2);
            this.R = bArr4;
        }
        k();
    }

    public final void g() {
        this.O = 0;
        for (int i2 = 0; i2 < 16; i2++) {
            int i3 = (this.L >> (i2 * 2)) & 3;
            if (i3 == 1) {
                if (this.O == 0) {
                    this.O = 2;
                }
            } else if (i3 == 2) {
                this.O = 1;
            }
        }
        this.N = this.O != 0;
        g.h.a.i.U3(String.format("imageVersionIndicator = 0x%08x, bankEnabled=%b, updateBankIndicator=0x%02X", Integer.valueOf(this.L), Boolean.valueOf(this.N), Integer.valueOf(this.O)));
    }

    /* JADX WARN: Code restructure failed: missing block: B:13:0x0019, code lost:
    
        if (r4.C != 0) goto L14;
     */
    /* JADX WARN: Code restructure failed: missing block: B:14:0x001b, code lost:
    
        r4.M = 3;
     */
    /* JADX WARN: Code restructure failed: missing block: B:20:0x0027, code lost:
    
        if (r4.C != 0) goto L14;
     */
    /* JADX WARN: Code restructure failed: missing block: B:22:0x002a, code lost:
    
        return;
     */
    /* JADX WARN: Code restructure failed: missing block: B:24:?, code lost:
    
        return;
     */
    /* JADX WARN: Code restructure failed: missing block: B:5:0x0008, code lost:
    
        if (r4.f5684t == 1) goto L6;
     */
    /* JADX WARN: Code restructure failed: missing block: B:6:0x000a, code lost:
    
        r4.M = 2;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void h() {
        /*
            r4 = this;
            int r0 = r4.f5675k
            r1 = 2
            r2 = 1
            if (r0 != 0) goto L10
            int r0 = r4.f5684t
            if (r0 != r2) goto Ld
        La:
            r4.M = r1
            goto L2a
        Ld:
            r4.M = r2
            goto L2a
        L10:
            r3 = 3
            if (r0 != r2) goto L1e
            int r0 = r4.f5684t
            if (r0 != r2) goto Ld
            int r0 = r4.C
            if (r0 == 0) goto La
        L1b:
            r4.M = r3
            goto L2a
        L1e:
            if (r0 != r1) goto L21
            goto Ld
        L21:
            int r0 = r4.f5684t
            if (r0 != r2) goto Ld
            int r0 = r4.C
            if (r0 == 0) goto La
            goto L1b
        L2a:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: g.i.a.c.q.d.h():void");
    }

    public final void i() {
        int i2;
        int i3;
        int i4;
        int i5;
        int i6;
        byte b2;
        int i7 = this.a;
        if (i7 != 20) {
            int i8 = 17;
            if (i7 != 17 || this.f5675k < 6) {
                g.h.a.i.U3(String.format("updateImageVersionWithBitNumber:indicator = 0x%08x, \nvalues = %s", Integer.valueOf(this.L), g.h.a.i.y(this.P)));
                ArrayList arrayList = new ArrayList();
                int i9 = 0;
                int i10 = 0;
                int i11 = 0;
                while (i9 < 16) {
                    int i12 = (this.L >> (i9 * 2)) & 3;
                    if (i12 == 0) {
                        h hVar = new h(i9, i12, -1, 0);
                        g.h.a.i.U3(hVar.toString());
                        arrayList.add(hVar);
                    } else {
                        byte[] bArr = this.P;
                        if (bArr == null || (i5 = i10 + 3) >= bArr.length) {
                            g.a.a.a.a.b0("imageVersion loss, offset=", i10);
                            i2 = 0;
                        } else {
                            if (this.a == i8 && this.f5675k >= 5 && i9 == 2) {
                                i6 = ((bArr[i10] << BinaryMemcacheOpcodes.FLUSHQ) & (-16777216)) | ((bArr[i10 + 1] << 16) & 16711680) | ((bArr[i10 + 2] << 8) & 65280);
                                b2 = bArr[i5];
                            } else {
                                i6 = ((bArr[i5] << BinaryMemcacheOpcodes.FLUSHQ) & (-16777216)) | ((bArr[i10 + 2] << 16) & 16711680) | ((bArr[i10 + 1] << 8) & 65280);
                                b2 = bArr[i10];
                            }
                            i2 = i6 | (b2 & 255);
                            i10 += 4;
                        }
                        byte[] bArr2 = this.T;
                        if (bArr2 == null || (i4 = i11 + 3) >= bArr2.length) {
                            g.a.a.a.a.b0("sectionsize loss, offset=", i11);
                            i3 = 0;
                        } else {
                            i3 = (bArr2[i11] & 255) | ((bArr2[i4] << BinaryMemcacheOpcodes.FLUSHQ) & (-16777216)) | (16711680 & (bArr2[i11 + 2] << 16)) | (65280 & (bArr2[i11 + 1] << 8));
                            i11 += 4;
                        }
                        h hVar2 = new h(i9, i12, i2, i3);
                        g.h.a.i.U3(hVar2.toString());
                        arrayList.add(hVar2);
                    }
                    i9++;
                    i8 = 17;
                }
                this.Q = arrayList;
                a();
                return;
            }
        }
        j();
    }

    public final void j() {
        int i2;
        int i3;
        g.h.a.i.U3(String.format("wrapperImageVersionWithImageId, indicator = 0x%08x, \nvalues = %s", Integer.valueOf(this.L), g.h.a.i.y(this.P)));
        byte[] bArr = this.P;
        if (bArr == null || bArr.length <= 0) {
            this.Q = new ArrayList();
            return;
        }
        int i4 = bArr[0] & 255;
        ArrayList arrayList = new ArrayList();
        HashMap map = new HashMap();
        HashMap map2 = new HashMap();
        int i5 = 1;
        for (int i6 = 0; i6 < i4; i6++) {
            byte[] bArr2 = this.P;
            if (bArr2 != null && (i3 = i5 + 5) < bArr2.length) {
                int i7 = (bArr2[i5] & 255) | ((bArr2[i5 + 1] << 8) & 65280);
                map.put(Integer.valueOf(i7), Integer.valueOf(i7 == 10128 ? (bArr2[i3] & 255) | ((bArr2[i5 + 2] << BinaryMemcacheOpcodes.FLUSHQ) & (-16777216)) | ((bArr2[i5 + 3] << 16) & 16711680) | ((bArr2[i5 + 4] << 8) & 65280) : (bArr2[i5 + 2] & 255) | ((bArr2[i3] << BinaryMemcacheOpcodes.FLUSHQ) & (-16777216)) | ((bArr2[i5 + 4] << 16) & 16711680) | ((bArr2[i5 + 3] << 8) & 65280)));
            }
            byte[] bArr3 = this.T;
            if (bArr3 != null && (i2 = i5 + 5) < bArr3.length) {
                map2.put(Integer.valueOf(((bArr3[i5 + 1] << 8) & 65280) | (bArr3[i5] & 255)), Integer.valueOf((bArr3[i5 + 2] & 255) | ((bArr3[i2] << BinaryMemcacheOpcodes.FLUSHQ) & (-16777216)) | (16711680 & (bArr3[i5 + 4] << 16)) | ((bArr3[i5 + 3] << 8) & 65280)));
            }
            i5 += 6;
        }
        Iterator it = map.keySet().iterator();
        while (it.hasNext()) {
            int iIntValue = ((Integer) it.next()).intValue();
            int i8 = this.O;
            h hVar = new h(DnsRecord.CLASS_ANY, i8 == 1 ? 2 : i8 == 2 ? 1 : 3, (!map.containsKey(Integer.valueOf(iIntValue)) || map.get(Integer.valueOf(iIntValue)) == null) ? 0 : ((Integer) map.get(Integer.valueOf(iIntValue))).intValue(), (!map2.containsKey(Integer.valueOf(iIntValue)) || map2.get(Integer.valueOf(iIntValue)) == null) ? 0 : ((Integer) map2.get(Integer.valueOf(iIntValue))).intValue(), iIntValue);
            g.h.a.i.U3(hVar.toString());
            arrayList.add(hVar);
        }
        this.Q = arrayList;
        a();
    }

    public final void k() {
        int i2;
        int i3;
        h hVar;
        int i4;
        int i5;
        int i6;
        byte b2;
        int i7 = this.a;
        if (i7 != 20) {
            int i8 = 17;
            if (i7 != 17 || this.f5675k < 6) {
                int i9 = 0;
                g.h.a.i.U3(String.format("imageVersionIndicator = 0x%08x, \ninactiveImageVersionValues = %s", Integer.valueOf(this.L), g.h.a.i.y(this.R)));
                ArrayList arrayList = new ArrayList();
                int i10 = 0;
                int i11 = 0;
                int i12 = 0;
                while (i10 < 16) {
                    int i13 = (this.L >> (i10 * 2)) & 3;
                    if (i13 == 0) {
                        hVar = new h(i10, i13, -1, i9);
                        g.h.a.i.U3(hVar.toString());
                    } else {
                        byte[] bArr = this.R;
                        if (bArr == null || (i5 = i11 + 3) >= bArr.length) {
                            g.h.a.i.V3(true, "imageVersion loss, offset=" + i11);
                            i2 = 0;
                        } else {
                            if (this.a == i8 && this.f5675k >= 5 && i10 == 2) {
                                i6 = ((bArr[i11] << BinaryMemcacheOpcodes.FLUSHQ) & (-16777216)) | ((bArr[i11 + 1] << 16) & 16711680) | ((bArr[i11 + 2] << 8) & 65280);
                                b2 = bArr[i5];
                            } else {
                                i6 = ((bArr[i5] << BinaryMemcacheOpcodes.FLUSHQ) & (-16777216)) | ((bArr[i11 + 2] << 16) & 16711680) | ((bArr[i11 + 1] << 8) & 65280);
                                b2 = bArr[i11];
                            }
                            i2 = i6 | (b2 & 255);
                            i11 += 4;
                        }
                        byte[] bArr2 = this.T;
                        if (bArr2 == null || (i4 = i12 + 3) >= bArr2.length) {
                            g.h.a.i.V3(true, "sectionsize loss, offset=" + i12);
                            i3 = 0;
                        } else {
                            i3 = (bArr2[i12] & 255) | ((bArr2[i12 + 2] << 16) & 16711680) | ((bArr2[i4] << BinaryMemcacheOpcodes.FLUSHQ) & (-16777216)) | ((bArr2[i12 + 1] << 8) & 65280);
                            i12 += 4;
                        }
                        hVar = new h(i10, i13, i2, i3);
                        g.h.a.i.U3(hVar.toString());
                    }
                    arrayList.add(hVar);
                    i10++;
                    i8 = 17;
                    i9 = 0;
                }
                this.S = arrayList;
                return;
            }
        }
        r();
    }

    public int l() {
        int i2 = this.O;
        if (i2 == 1) {
            return 1;
        }
        return i2 == 2 ? 0 : 15;
    }

    public h m(int i2) {
        List<h> list = this.Q;
        if (list != null && list.size() > 0) {
            for (h hVar : this.Q) {
                if (hVar.f5725f == i2) {
                    return hVar;
                }
            }
        }
        return null;
    }

    public h n(int i2) {
        List<h> list = this.Q;
        if (list == null || list.size() <= 0) {
            return null;
        }
        for (h hVar : this.Q) {
            if (hVar.f5726m == i2) {
                return hVar;
            }
        }
        return null;
    }

    /* JADX WARN: Removed duplicated region for block: B:55:0x007f  */
    /* JADX WARN: Removed duplicated region for block: B:56:0x0084  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public int o() {
        /*
            r11 = this;
            int r0 = r11.a
            r1 = 10
            r2 = 8
            r3 = 7
            r4 = 4
            r5 = 12
            r6 = 9
            r7 = 3
            r8 = 6
            r9 = 5
            r10 = 16
            if (r0 != r10) goto L2c
            int r0 = r11.f5674j
            if (r0 > r7) goto L19
            goto L84
        L19:
            if (r0 == r9) goto L7f
            if (r0 == r6) goto L7f
            if (r0 != r5) goto L21
            goto L7f
        L21:
            if (r0 == r4) goto L7f
            if (r0 == r8) goto L7f
            if (r0 == r3) goto L7f
            if (r0 == r2) goto L7f
            if (r0 != r1) goto L84
            goto L7f
        L2c:
            r10 = 17
            if (r0 != r10) goto L51
            int r0 = r11.f5674j
            if (r0 > r7) goto L35
            goto L84
        L35:
            if (r0 == r9) goto L7f
            if (r0 == r6) goto L7f
            if (r0 != r5) goto L3c
            goto L7f
        L3c:
            if (r0 == r4) goto L46
            if (r0 == r8) goto L46
            if (r0 == r3) goto L46
            if (r0 == r2) goto L46
            if (r0 != r1) goto L84
        L46:
            int r0 = r11.f5675k
            if (r0 < r8) goto L7f
            r0 = 10131(0x2793, float:1.4197E-41)
            g.i.a.c.q.h r0 = r11.n(r0)
            goto L85
        L51:
            int r0 = r11.f5675k
            if (r0 != 0) goto L58
            int r0 = r11.F
            return r0
        L58:
            r10 = 1
            if (r0 < r10) goto L84
            int r0 = r11.f5674j
            if (r0 > r7) goto L6e
            int r0 = r11.O
            r1 = 2
            if (r0 != r1) goto L69
            g.i.a.c.q.h r0 = r11.m(r1)
            goto L85
        L69:
            g.i.a.c.q.h r0 = r11.m(r10)
            goto L85
        L6e:
            if (r0 == r9) goto L7f
            if (r0 == r6) goto L7f
            if (r0 != r5) goto L75
            goto L7f
        L75:
            if (r0 == r4) goto L7f
            if (r0 == r8) goto L7f
            if (r0 == r3) goto L7f
            if (r0 == r2) goto L7f
            if (r0 != r1) goto L84
        L7f:
            g.i.a.c.q.h r0 = r11.m(r9)
            goto L85
        L84:
            r0 = 0
        L85:
            if (r0 == 0) goto L8a
            int r0 = r0.f5728o
            return r0
        L8a:
            r0 = 0
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: g.i.a.c.q.d.o():int");
    }

    public h p(int i2) {
        List<h> list = this.S;
        if (list == null || list.size() <= 0) {
            return null;
        }
        for (h hVar : this.S) {
            if (hVar.f5726m == i2) {
                return hVar;
            }
        }
        return null;
    }

    /* JADX WARN: Removed duplicated region for block: B:52:0x0074  */
    /* JADX WARN: Removed duplicated region for block: B:57:0x007f  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public int q() {
        /*
            r12 = this;
            int r0 = r12.a
            r1 = 10
            r2 = 8
            r3 = 7
            r4 = 12
            r5 = 9
            r6 = 5
            r7 = 3
            r8 = 6
            r9 = 0
            r10 = 4
            r11 = 16
            if (r0 != r11) goto L2b
            int r0 = r12.f5674j
            if (r0 > r7) goto L19
            goto L5e
        L19:
            if (r0 == r6) goto L74
            if (r0 == r5) goto L74
            if (r0 != r4) goto L20
            goto L74
        L20:
            if (r0 == r10) goto L74
            if (r0 == r8) goto L74
            if (r0 == r3) goto L74
            if (r0 == r2) goto L74
            if (r0 != r1) goto L7f
            goto L74
        L2b:
            r11 = 17
            if (r0 != r11) goto L50
            int r0 = r12.f5674j
            if (r0 > r7) goto L34
            goto L5e
        L34:
            if (r0 == r6) goto L74
            if (r0 == r5) goto L74
            if (r0 != r4) goto L3b
            goto L74
        L3b:
            if (r0 == r10) goto L45
            if (r0 == r8) goto L45
            if (r0 == r3) goto L45
            if (r0 == r2) goto L45
            if (r0 != r1) goto L7f
        L45:
            int r0 = r12.f5675k
            if (r0 < r8) goto L74
            r0 = 10130(0x2792, float:1.4195E-41)
            g.i.a.c.q.h r0 = r12.n(r0)
            goto L80
        L50:
            int r0 = r12.f5675k
            if (r0 != 0) goto L57
            int r0 = r12.E
            return r0
        L57:
            r11 = 1
            if (r0 != r11) goto L79
            int r0 = r12.f5674j
            if (r0 > r7) goto L63
        L5e:
            g.i.a.c.q.h r0 = r12.m(r9)
            goto L80
        L63:
            if (r0 == r6) goto L74
            if (r0 == r5) goto L74
            if (r0 != r4) goto L6a
            goto L74
        L6a:
            if (r0 == r10) goto L74
            if (r0 == r8) goto L74
            if (r0 == r3) goto L74
            if (r0 == r2) goto L74
            if (r0 != r1) goto L7f
        L74:
            g.i.a.c.q.h r0 = r12.m(r10)
            goto L80
        L79:
            r1 = 2
            if (r0 != r1) goto L7f
            int r0 = r12.E
            return r0
        L7f:
            r0 = 0
        L80:
            if (r0 == 0) goto L85
            int r0 = r0.f5728o
            return r0
        L85:
            return r9
        */
        throw new UnsupportedOperationException("Method not decompiled: g.i.a.c.q.d.q():int");
    }

    public final void r() {
        int i2;
        int i3;
        byte b2;
        g.h.a.i.U3(String.format("imageVersionIndicator = 0x%08x, \ninactiveImageVersionValues = %s", Integer.valueOf(this.L), g.h.a.i.y(this.R)));
        byte[] bArr = this.R;
        if (bArr == null || bArr.length <= 0) {
            this.S = new ArrayList();
            return;
        }
        int i4 = bArr[0] & 255;
        ArrayList arrayList = new ArrayList();
        HashMap map = new HashMap();
        HashMap map2 = new HashMap();
        int i5 = 1;
        for (int i6 = 0; i6 < i4; i6++) {
            byte[] bArr2 = this.R;
            if (bArr2 != null && (i2 = i5 + 5) < bArr2.length) {
                int i7 = (bArr2[i5] & 255) | ((bArr2[i5 + 1] << 8) & 65280);
                if (i7 == 10128) {
                    i3 = ((bArr2[i5 + 2] << BinaryMemcacheOpcodes.FLUSHQ) & (-16777216)) | ((bArr2[i5 + 3] << 16) & 16711680) | ((bArr2[i5 + 4] << 8) & 65280);
                    b2 = bArr2[i2];
                } else {
                    i3 = ((bArr2[i2] << BinaryMemcacheOpcodes.FLUSHQ) & (-16777216)) | ((bArr2[i5 + 4] << 16) & 16711680) | ((bArr2[i5 + 3] << 8) & 65280);
                    b2 = bArr2[i5 + 2];
                }
                map.put(Integer.valueOf(i7), Integer.valueOf(i3 | (b2 & 255)));
            }
            byte[] bArr3 = this.T;
            if (bArr3 != null && (i5 * 4) + 3 < bArr3.length) {
                map2.put(Integer.valueOf(((bArr3[i5 + 1] << 8) & 65280) | (bArr3[i5] & 255)), Integer.valueOf((bArr3[i5 + 2] & 255) | ((bArr3[i5 + 5] << BinaryMemcacheOpcodes.FLUSHQ) & (-16777216)) | ((bArr3[i5 + 4] << 16) & 16711680) | ((bArr3[i5 + 3] << 8) & 65280)));
            }
            i5 += 6;
        }
        Iterator it = map.keySet().iterator();
        while (it.hasNext()) {
            int iIntValue = ((Integer) it.next()).intValue();
            int i8 = this.O;
            h hVar = new h(DnsRecord.CLASS_ANY, i8 == 1 ? 2 : i8 == 2 ? 1 : 3, (!map.containsKey(Integer.valueOf(iIntValue)) || map.get(Integer.valueOf(iIntValue)) == null) ? 0 : ((Integer) map.get(Integer.valueOf(iIntValue))).intValue(), (!map2.containsKey(Integer.valueOf(iIntValue)) || map2.get(Integer.valueOf(iIntValue)) == null) ? 0 : ((Integer) map2.get(Integer.valueOf(iIntValue))).intValue(), iIntValue);
            g.h.a.i.U3(hVar.toString());
            arrayList.add(hVar);
        }
        this.S = arrayList;
    }

    /* JADX WARN: Code restructure failed: missing block: B:58:0x0143, code lost:
    
        if (r12.L == 0) goto L59;
     */
    /* JADX WARN: Code restructure failed: missing block: B:59:0x0145, code lost:
    
        r12.N = false;
     */
    /* JADX WARN: Code restructure failed: missing block: B:60:0x0148, code lost:
    
        g();
     */
    /* JADX WARN: Code restructure failed: missing block: B:73:0x0189, code lost:
    
        if (r12.L == 0) goto L59;
     */
    /* JADX WARN: Code restructure failed: missing block: B:83:?, code lost:
    
        return;
     */
    /* JADX WARN: Code restructure failed: missing block: B:84:?, code lost:
    
        return;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void s(byte[] r13, int r14) {
        /*
            Method dump skipped, instruction units count: 405
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: g.i.a.c.q.d.s(byte[], int):void");
    }

    public void t(byte[] bArr) {
        if (bArr == null) {
            return;
        }
        ByteBuffer byteBufferWrap = ByteBuffer.wrap(bArr);
        byteBufferWrap.order(ByteOrder.LITTLE_ENDIAN);
        int iRemaining = byteBufferWrap.remaining();
        if (iRemaining <= 0) {
            return;
        }
        int i2 = iRemaining - 0;
        try {
            this.f5674j = byteBufferWrap.get(0) & 255;
            byte b2 = (byte) (byteBufferWrap.get(1) & BinaryMemcacheOpcodes.PREPEND);
            this.f5675k = b2;
            if (b2 < 4) {
                if (i2 >= 3) {
                    this.f5676l = byteBufferWrap.get(2) & 255;
                }
                if (i2 >= 4) {
                    int i3 = byteBufferWrap.get(3) & 255;
                    this.f5679o = i3;
                    this.f5680p = (i3 & 1) != 0;
                    this.f5681q = ((i3 & 2) >> 1) != 0;
                    this.f5682r = (i3 & 4) >> 2;
                    this.f5683s = ((i3 & 8) >> 3) != 0;
                    this.f5684t = (i3 & 16) >> 4;
                    this.f5686v = ((i3 & 32) >> 5) != 0;
                    this.f5687w = (i3 & 64) >> 6;
                    this.f5688x = (i3 & 128) >> 7;
                }
                if (i2 >= 5) {
                    this.f5689y = 1 & byteBufferWrap.get(4) & 255;
                }
                if (i2 >= 7) {
                    this.C = byteBufferWrap.get(6) & 255;
                }
                if (i2 >= 12) {
                    this.L = byteBufferWrap.getInt(8);
                }
            } else {
                if (i2 >= 3) {
                    int i4 = byteBufferWrap.get(2) & 255;
                    this.f5679o = i4;
                    this.f5680p = (i4 & 1) != 0;
                    this.f5681q = ((i4 & 2) >> 1) != 0;
                    this.f5682r = (i4 & 4) >> 2;
                    this.f5684t = (i4 & 8) >> 3;
                    this.f5685u = ((i4 & 16) >> 4) == 1;
                    this.f5690z = ((i4 & 32) >> 5) == 1;
                }
                if (i2 >= 4) {
                    int i5 = byteBufferWrap.get(3) & 255 & 3;
                    this.f5689y = i5;
                    this.f5687w = (12 & this.f5679o) >> 2;
                    this.f5686v = i5 == 2;
                }
                if (i2 >= 5) {
                    this.C = byteBufferWrap.get(4) & 255;
                }
                if (i2 >= 6) {
                    int i6 = byteBufferWrap.get(5) & 255;
                    if (i6 == 0) {
                        this.N = false;
                        this.O = 0;
                        this.L = 3;
                    } else if (i6 == 1) {
                        this.N = true;
                        this.O = 2;
                        this.L = 1;
                    } else if (i6 == 2) {
                        this.N = true;
                        this.O = 1;
                        this.L = 2;
                    }
                }
                if (i2 >= 7) {
                    this.V = byteBufferWrap.getShort(6) & 65535;
                }
            }
        } catch (Exception e2) {
            g.h.a.i.W3(e2.toString());
        }
        if (this.L == 0) {
            this.N = false;
        } else {
            g();
        }
        a();
    }

    public String toString() {
        String str;
        String str2;
        StringBuilder sbF = g.a.a.a.a.F("DeviceInfo{\n");
        sbF.append(String.format("IPV=%s\n", String.format("I%02XP%04XV%02XCID%02XPID%02X", Integer.valueOf(this.f5674j), Integer.valueOf(this.a), Integer.valueOf(this.f5675k), (byte) 0, (byte) 0)));
        boolean z2 = this.f5666b;
        if (z2) {
            sbF.append("PnP_ID:\n");
            Locale locale = Locale.US;
            sbF.append(String.format(locale, "\tvendorIdSource=0x%04X(%d)\n", Integer.valueOf(this.f5667c), Integer.valueOf(this.f5667c)));
            sbF.append(String.format(locale, "\tvendorId=0x%04X(%d)\n", Integer.valueOf(this.f5668d), Integer.valueOf(this.f5668d)));
            sbF.append(String.format(locale, "\tproductId=0x%04X(%d)\n", Integer.valueOf(this.f5669e), Integer.valueOf(this.f5669e)));
            str = String.format(locale, "\tproductVersion=0x%04X(%d)\n", Integer.valueOf(this.f5670f), Integer.valueOf(this.f5670f));
        } else {
            str = String.format("DIS=%b\n", Boolean.valueOf(z2));
        }
        sbF.append(str);
        boolean z3 = this.f5671g;
        sbF.append(z3 ? String.format(Locale.US, "primaryBat=0x%02X(%d), secondaryBat=0x%02X(%d)\n", Integer.valueOf(this.f5672h), Integer.valueOf(this.f5672h), Integer.valueOf(this.f5673i), Integer.valueOf(this.f5673i)) : String.format("BAS=%b\n", Boolean.valueOf(z3)));
        sbF.append(String.format("mode=0x%02X\n", Integer.valueOf(this.f5679o)));
        sbF.append(String.format("\tbufferCheckEnabled=%b\n", Boolean.valueOf(this.f5680p)));
        if (this.f5680p) {
            sbF.append(String.format(Locale.US, "\t\tmaxBuffercheckSize=0x%04X(%d)\n", Integer.valueOf(this.B), Integer.valueOf(this.B)));
        }
        sbF.append(String.format("\taesEncryptEnabled=%b", Boolean.valueOf(this.f5681q)));
        if (this.f5681q) {
            sbF.append(String.format("\t\taesEncryptMode=0x%02X\n", Integer.valueOf(this.f5682r)));
        }
        sbF.append(String.format("\n\tcopyImageEnabled=%b\n", Boolean.valueOf(this.f5683s)));
        sbF.append(String.format("\tupdateImageFlag=0x%02X\n", Integer.valueOf(this.f5684t)));
        sbF.append(String.format("\trwsEnabled=%b, rwsMode=0x%02X, budRole: 0x%02X\n", Boolean.valueOf(this.f5686v), Integer.valueOf(this.f5689y), Integer.valueOf(this.f5687w)));
        if (this.f5686v) {
            sbF.append(String.format("\t\trwsUpdateFlag:0x%02X, rwsBdAddr: %s\n", Integer.valueOf(this.f5688x), g.h.a.i.T0(this.A)));
        }
        Locale locale2 = Locale.US;
        sbF.append(String.format(locale2, "otaTempBufferSize=0x%04X(%d)\n", Integer.valueOf(this.C), Integer.valueOf(this.C)));
        sbF.append(String.format("mUpdateMechanism=0x%02X\n", Integer.valueOf(this.M)));
        int i2 = this.a;
        if (i2 == 0) {
            int i3 = this.f5675k;
            if (i3 == 0) {
                sbF.append(String.format(locale2, "\tpatchVersion=0x%04X\n", Integer.valueOf(this.E)));
                sbF.append(String.format(locale2, "\tpatchFreeBank=0x%02X\n", Integer.valueOf(this.f5678n)));
                sbF.append(String.format(locale2, "\tappVersion=0x%04X\n", Integer.valueOf(this.F)));
                sbF.append(String.format("\tappFreeBank=0x%02X\n", Integer.valueOf(this.f5677m)));
                sbF.append(String.format(locale2, "\tpatchExtensionVersion=%d\n", Integer.valueOf(this.G)));
                if (this.f5674j > 3) {
                    sbF.append(String.format(locale2, "\tappData0=%d\n", Integer.valueOf(this.H)));
                    sbF.append(String.format(locale2, "\tappData1=%d\n", Integer.valueOf(this.I)));
                    sbF.append(String.format(locale2, "\tappData2=%d\n", Integer.valueOf(this.J)));
                    str2 = String.format(locale2, "\tappData3=%d\n", Integer.valueOf(this.K));
                    sbF.append(str2);
                }
            } else {
                if (i3 == 1) {
                    sbF.append(String.format(locale2, "\tsecureVersion=0x%04X(%d)\n", Integer.valueOf(this.f5676l), Integer.valueOf(this.f5676l)));
                    sbF.append(String.format(locale2, "\timageVersionIndicator=0x%08X\n", Integer.valueOf(this.L)));
                    str2 = String.format(locale2, "\tupdateBankIndicator=0x%02X\n", Integer.valueOf(this.O));
                } else if (i3 == 2) {
                    sbF.append(String.format(locale2, "\tnoTempImageId=0x%04X\n", Integer.valueOf(this.W)));
                    str2 = String.format(locale2, "\tpatchVersion=0x%04X\n", Integer.valueOf(this.E));
                }
                sbF.append(str2);
            }
        } else {
            if (i2 == 17) {
                sbF.append(String.format(locale2, "\tsecureVersion=0x%04X(%d)\n", Integer.valueOf(this.f5676l), Integer.valueOf(this.f5676l)));
                sbF.append(String.format(locale2, "\timageVersionIndicator=0x%08X\n", Integer.valueOf(this.L)));
                sbF.append(String.format(locale2, "\tupdateBankIndicator=0x%02X(%d)\n", Integer.valueOf(this.O), Integer.valueOf(this.O)));
                if (this.f5675k >= 6) {
                    str2 = String.format(locale2, "\tmtu=0x%04X\n", Integer.valueOf(this.V));
                }
            } else {
                sbF.append(String.format(locale2, "\tsecureVersion=0x%04X(%d)\n", Integer.valueOf(this.f5676l), Integer.valueOf(this.f5676l)));
                sbF.append(String.format(locale2, "\timageVersionIndicator=0x%08X\n", Integer.valueOf(this.L)));
                str2 = String.format(locale2, "\tupdateBankIndicator=0x%02X(%d)\n", Integer.valueOf(this.O), Integer.valueOf(this.O));
            }
            sbF.append(str2);
        }
        sbF.append(String.format("bankEnabled=%b\n", Boolean.valueOf(this.N)));
        List<h> list = this.Q;
        if (list != null && list.size() > 0) {
            sbF.append("activeImages:\n");
            for (h hVar : this.Q) {
                StringBuilder sbF2 = g.a.a.a.a.F("\t");
                sbF2.append(hVar.toString());
                sbF2.append("\n");
                sbF.append(sbF2.toString());
            }
        }
        List<h> list2 = this.S;
        if (list2 != null && list2.size() > 0) {
            sbF.append("inactiveImages:\n");
            Iterator<h> it = this.S.iterator();
            while (it.hasNext()) {
                sbF.append(it.next().toString() + "\n");
            }
        }
        sbF.append("}");
        return sbF.toString();
    }

    public void u(byte[] bArr) {
        if (bArr == null) {
            return;
        }
        ByteBuffer byteBufferWrap = ByteBuffer.wrap(bArr);
        byteBufferWrap.order(ByteOrder.LITTLE_ENDIAN);
        int iRemaining = byteBufferWrap.remaining();
        if (iRemaining <= 0) {
            return;
        }
        int i2 = iRemaining - 0;
        try {
            this.f5674j = byteBufferWrap.get(0) & 255;
            this.f5675k = (byte) (byteBufferWrap.get(1) & BinaryMemcacheOpcodes.PREPEND);
            if (i2 >= 3) {
                int i3 = byteBufferWrap.get(2) & 255;
                this.f5679o = i3;
                this.f5680p = (i3 & 1) != 0;
                this.f5681q = ((i3 & 2) >> 1) != 0;
                this.f5682r = (i3 & 4) >> 2;
                this.f5684t = (i3 & 8) >> 3;
                this.f5685u = ((i3 & 16) >> 4) == 1;
                this.f5690z = ((i3 & 32) >> 5) == 1;
            }
            if (i2 >= 4) {
                int i4 = byteBufferWrap.get(3) & 255 & 3;
                this.f5689y = i4;
                this.f5687w = (this.f5679o & 12) >> 2;
                this.f5686v = i4 == 2;
            }
            if (i2 >= 6) {
                this.C = byteBufferWrap.getShort(4) & 65535;
            }
            if (i2 >= 7) {
                int i5 = byteBufferWrap.get(6) & 255;
                if (i5 == 0) {
                    this.N = false;
                    this.O = 0;
                    this.L = 3;
                } else if (i5 == 1) {
                    this.N = true;
                    this.O = 2;
                    this.L = 1;
                } else if (i5 == 2) {
                    this.N = true;
                    this.O = 1;
                    this.L = 2;
                }
            }
            if (i2 >= 8) {
                this.V = byteBufferWrap.getShort(7) & 65535;
            }
        } catch (Exception e2) {
            g.h.a.i.W3(e2.toString());
        }
        if (this.L == 0) {
            this.N = false;
        } else {
            g();
        }
        a();
    }

    public void v(byte[] bArr) {
        this.T = bArr;
        g.h.a.i.U3(String.format("imageVersionIndicator = 0x%08x, \nimageSectionSizeValues=%s", Integer.valueOf(this.L), g.h.a.i.y(this.T)));
        i();
    }

    public void w(byte[] bArr) {
        int i2 = this.a;
        if (i2 == 20) {
            if (bArr == null || bArr.length < 1) {
                return;
            }
            byte b2 = bArr[0];
            int length = bArr.length - 1;
            byte[] bArr2 = new byte[length];
            System.arraycopy(bArr, 1, bArr2, 0, length);
            if (b2 == 0) {
                this.P = bArr2;
                i();
            } else {
                this.R = bArr2;
                k();
                return;
            }
        }
        if (i2 != 17 || this.f5675k < 6) {
            this.P = bArr;
        } else {
            if (bArr == null || bArr.length < 1) {
                return;
            }
            byte b3 = bArr[0];
            int length2 = bArr.length - 1;
            byte[] bArr3 = new byte[length2];
            System.arraycopy(bArr, 1, bArr3, 0, length2);
            if (b3 != 0) {
                this.R = bArr3;
                k();
                return;
            }
            this.P = bArr3;
        }
        i();
    }

    public void x(int i2) {
        this.f5679o = i2;
        this.f5680p = (i2 & 1) != 0;
        this.f5681q = ((i2 & 2) >> 1) != 0;
        this.f5682r = (i2 & 4) >> 2;
        this.f5683s = ((i2 & 8) >> 3) != 0;
        this.f5684t = (i2 & 16) >> 4;
        this.f5686v = ((i2 & 32) >> 5) != 0;
        h();
    }

    public void y(byte[] bArr) {
        if (bArr == null || bArr.length < 7) {
            this.f5666b = false;
            this.f5667c = 0;
            this.f5668d = 0;
            this.f5669e = 0;
            this.f5670f = 0;
            return;
        }
        this.f5666b = true;
        this.f5667c = bArr[0];
        this.f5668d = (bArr[2] << 8) | bArr[1];
        this.f5669e = (bArr[4] << 8) | bArr[3];
        this.f5670f = bArr[5] | (bArr[6] << 8);
    }
}
