package x;

import com.google.zxing.NotFoundException;

/* JADX INFO: loaded from: classes.dex */
public final class i {

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

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

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

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

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

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

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

    public i(tb.b bVar, int i10, int i11, int i12) throws NotFoundException {
        this.f34313g = bVar;
        int i13 = bVar.f33006b;
        this.f34307a = i13;
        int i14 = bVar.f33005a;
        this.f34308b = i14;
        int i15 = i10 / 2;
        int i16 = i11 - i15;
        this.f34309c = i16;
        int i17 = i11 + i15;
        this.f34310d = i17;
        int i18 = i12 - i15;
        this.f34312f = i18;
        int i19 = i12 + i15;
        this.f34311e = i19;
        if (i18 < 0 || i16 < 0 || i19 >= i13 || i17 >= i14) {
            throw NotFoundException.a();
        }
    }

    public final boolean a(int i10, int i11, int i12, boolean z10) {
        Object obj = this.f34313g;
        if (z10) {
            while (i10 <= i11) {
                if (((tb.b) obj).b(i10, i12)) {
                    return true;
                }
                i10++;
            }
            return false;
        }
        while (i10 <= i11) {
            if (((tb.b) obj).b(i12, i10)) {
                return true;
            }
            i10++;
        }
        return false;
    }

    public final ob.g[] b() throws NotFoundException {
        int i10;
        boolean z10;
        int i11;
        int i12 = this.f34309c;
        int i13 = this.f34310d;
        int i14 = this.f34312f;
        int i15 = this.f34311e;
        boolean z11 = false;
        boolean z12 = false;
        boolean z13 = false;
        boolean z14 = false;
        boolean z15 = true;
        do {
            i10 = this.f34308b;
            if (!z15) {
                z10 = false;
                break;
            }
            boolean z16 = false;
            boolean zA = true;
            while (true) {
                if ((!zA && z11) || i13 >= i10) {
                    break;
                }
                zA = a(i14, i15, i13, false);
                if (zA) {
                    i13++;
                    z11 = true;
                    z16 = true;
                } else if (!z11) {
                    i13++;
                }
            }
            if (i13 >= i10) {
                break;
            }
            boolean zA2 = true;
            while (true) {
                i11 = this.f34307a;
                if ((!zA2 && z12) || i15 >= i11) {
                    break;
                }
                zA2 = a(i12, i13, i15, true);
                if (zA2) {
                    i15++;
                    z12 = true;
                    z16 = true;
                } else if (!z12) {
                    i15++;
                }
            }
            if (i15 >= i11) {
                break;
            }
            boolean zA3 = true;
            while (true) {
                if ((!zA3 && z13) || i12 < 0) {
                    break;
                }
                zA3 = a(i14, i15, i12, false);
                if (zA3) {
                    i12--;
                    z13 = true;
                    z16 = true;
                } else if (!z13) {
                    i12--;
                }
            }
            if (i12 < 0) {
                break;
            }
            z15 = z16;
            boolean zA4 = true;
            while (true) {
                if ((!zA4 && z14) || i14 < 0) {
                    break;
                }
                zA4 = a(i12, i13, i14, true);
                if (zA4) {
                    i14--;
                    z15 = true;
                    z14 = true;
                } else if (!z14) {
                    i14--;
                }
            }
        } while (i14 >= 0);
        z10 = true;
        if (z10) {
            throw NotFoundException.a();
        }
        int i16 = i13 - i12;
        ob.g gVarC = null;
        ob.g gVarC2 = null;
        for (int i17 = 1; gVarC2 == null && i17 < i16; i17++) {
            gVarC2 = c(i12, i15 - i17, i12 + i17, i15);
        }
        if (gVarC2 == null) {
            throw NotFoundException.a();
        }
        ob.g gVarC3 = null;
        for (int i18 = 1; gVarC3 == null && i18 < i16; i18++) {
            gVarC3 = c(i12, i14 + i18, i12 + i18, i14);
        }
        if (gVarC3 == null) {
            throw NotFoundException.a();
        }
        ob.g gVarC4 = null;
        for (int i19 = 1; gVarC4 == null && i19 < i16; i19++) {
            gVarC4 = c(i13, i14 + i19, i13 - i19, i14);
        }
        if (gVarC4 == null) {
            throw NotFoundException.a();
        }
        for (int i20 = 1; gVarC == null && i20 < i16; i20++) {
            gVarC = c(i13, i15 - i20, i13 - i20, i15);
        }
        if (gVarC == null) {
            throw NotFoundException.a();
        }
        float f10 = i10 / 2.0f;
        float f11 = gVarC.f31472a;
        float f12 = gVarC2.f31472a;
        float f13 = gVarC4.f31472a;
        float f14 = gVarC3.f31472a;
        float f15 = gVarC.f31473b;
        float f16 = gVarC2.f31473b;
        float f17 = gVarC4.f31473b;
        float f18 = gVarC3.f31473b;
        return f11 < f10 ? new ob.g[]{new ob.g(f14 - 1.0f, f18 + 1.0f), new ob.g(f12 + 1.0f, f16 + 1.0f), new ob.g(f13 - 1.0f, f17 - 1.0f), new ob.g(f11 + 1.0f, f15 - 1.0f)} : new ob.g[]{new ob.g(f14 + 1.0f, f18 + 1.0f), new ob.g(f12 + 1.0f, f16 - 1.0f), new ob.g(f13 - 1.0f, f17 + 1.0f), new ob.g(f11 - 1.0f, f15 - 1.0f)};
    }

    public final ob.g c(float f10, float f11, float f12, float f13) {
        int iP = nb.g.P(nb.g.r(f10, f11, f12, f13));
        float f14 = iP;
        float f15 = (f12 - f10) / f14;
        float f16 = (f13 - f11) / f14;
        for (int i10 = 0; i10 < iP; i10++) {
            float f17 = i10;
            int iP2 = nb.g.P((f17 * f15) + f10);
            int iP3 = nb.g.P((f17 * f16) + f11);
            if (((tb.b) this.f34313g).b(iP2, iP3)) {
                return new ob.g(iP2, iP3);
            }
        }
        return null;
    }

    public i(tb.b bVar) {
        this(bVar, 10, bVar.f33005a / 2, bVar.f33006b / 2);
    }
}
