package android.support.v7.widget;

import android.util.SparseIntArray;

public abstract class GridLayoutManager$b {
    final SparseIntArray ald = new SparseIntArray();
    private boolean ale = false;

    public abstract int bU(int i);

    /* Access modifiers changed, original: final */
    public final int ab(int i, int i2) {
        if (!this.ale) {
            return aa(i, i2);
        }
        int i3 = this.ald.get(i, -1);
        if (i3 != -1) {
            return i3;
        }
        i3 = aa(i, i2);
        this.ald.put(i, i3);
        return i3;
    }

    /* JADX WARNING: Removed duplicated region for block: B:21:0x0055  */
    /* JADX WARNING: Removed duplicated region for block: B:41:? A:{SYNTHETIC, RETURN} */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x006b  */
    public int aa(int r7, int r8) {
        /*
        r6 = this;
        r1 = 0;
        r4 = r6.bU(r7);
        if (r4 != r8) goto L_0x0008;
    L_0x0007:
        return r1;
    L_0x0008:
        r0 = r6.ale;
        if (r0 == 0) goto L_0x006d;
    L_0x000c:
        r0 = r6.ald;
        r0 = r0.size();
        if (r0 <= 0) goto L_0x006d;
    L_0x0014:
        r0 = r6.ald;
        r0 = r0.size();
        r0 = r0 + -1;
        r2 = r1;
    L_0x001d:
        if (r2 > r0) goto L_0x0031;
    L_0x001f:
        r3 = r2 + r0;
        r3 = r3 >>> 1;
        r5 = r6.ald;
        r5 = r5.keyAt(r3);
        if (r5 >= r7) goto L_0x002e;
    L_0x002b:
        r2 = r3 + 1;
        goto L_0x001d;
    L_0x002e:
        r0 = r3 + -1;
        goto L_0x001d;
    L_0x0031:
        r0 = r2 + -1;
        if (r0 < 0) goto L_0x0061;
    L_0x0035:
        r2 = r6.ald;
        r2 = r2.size();
        if (r0 >= r2) goto L_0x0061;
    L_0x003d:
        r2 = r6.ald;
        r0 = r2.keyAt(r0);
    L_0x0043:
        if (r0 < 0) goto L_0x006d;
    L_0x0045:
        r2 = r6.ald;
        r2 = r2.get(r0);
        r3 = r6.bU(r0);
        r2 = r2 + r3;
        r0 = r0 + 1;
    L_0x0052:
        r3 = r0;
    L_0x0053:
        if (r3 >= r7) goto L_0x0067;
    L_0x0055:
        r0 = r6.bU(r3);
        r2 = r2 + r0;
        if (r2 != r8) goto L_0x0063;
    L_0x005c:
        r0 = r1;
    L_0x005d:
        r3 = r3 + 1;
        r2 = r0;
        goto L_0x0053;
    L_0x0061:
        r0 = -1;
        goto L_0x0043;
    L_0x0063:
        if (r2 > r8) goto L_0x005d;
    L_0x0065:
        r0 = r2;
        goto L_0x005d;
    L_0x0067:
        r0 = r2 + r4;
        if (r0 > r8) goto L_0x0007;
    L_0x006b:
        r1 = r2;
        goto L_0x0007;
    L_0x006d:
        r0 = r1;
        r2 = r1;
        goto L_0x0052;
        */
        throw new UnsupportedOperationException("Method not decompiled: android.support.v7.widget.GridLayoutManager$b.aa(int, int):int");
    }

    public final int ac(int i, int i2) {
        int bU = bU(i);
        int i3 = 0;
        int i4 = 0;
        int i5 = 0;
        while (i3 < i) {
            int bU2 = bU(i3);
            int i6 = i5 + bU2;
            if (i6 == i2) {
                i4++;
                bU2 = 0;
            } else if (i6 > i2) {
                i4++;
            } else {
                bU2 = i6;
            }
            i3++;
            i5 = bU2;
        }
        if (i5 + bU > i2) {
            return i4 + 1;
        }
        return i4;
    }
}
