package d.a.p;

import a.a.a.a.c.n0;
import d.a.s.g.j;
import d.a.s.h.d;
import d.a.s.h.f;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public final class a implements b, d.a.s.a.a {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public f<b> f5677b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public volatile boolean f5678c;

    /* JADX WARN: Removed duplicated region for block: B:25:0x0045  */
    /* JADX WARN: Removed duplicated region for block: B:26:0x0046 A[Catch: all -> 0x004a, DONT_GENERATE, TryCatch #0 {, blocks: (B:6:0x000c, B:8:0x0010, B:10:0x0012, B:12:0x0016, B:26:0x0046, B:15:0x002a, B:17:0x0030, B:18:0x0035, B:21:0x003c, B:28:0x0048), top: B:33:0x000c }] */
    @Override // d.a.s.a.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean a(d.a.p.b r8) {
        /*
            r7 = this;
            java.lang.String r0 = "Disposable item is null"
            java.util.Objects.requireNonNull(r8, r0)
            boolean r0 = r7.f5678c
            r1 = 0
            if (r0 == 0) goto Lb
            return r1
        Lb:
            monitor-enter(r7)
            boolean r0 = r7.f5678c     // Catch: java.lang.Throwable -> L4a
            if (r0 == 0) goto L12
            monitor-exit(r7)     // Catch: java.lang.Throwable -> L4a
            return r1
        L12:
            d.a.s.h.f<d.a.p.b> r0 = r7.f5677b     // Catch: java.lang.Throwable -> L4a
            if (r0 == 0) goto L48
            T[] r2 = r0.f5920d     // Catch: java.lang.Throwable -> L4a
            int r3 = r0.f5917a     // Catch: java.lang.Throwable -> L4a
            int r4 = r8.hashCode()     // Catch: java.lang.Throwable -> L4a
            int r4 = d.a.s.h.f.b(r4)     // Catch: java.lang.Throwable -> L4a
            r4 = r4 & r3
            r5 = r2[r4]     // Catch: java.lang.Throwable -> L4a
            r6 = 1
            if (r5 != 0) goto L2a
        L28:
            r8 = r1
            goto L43
        L2a:
            boolean r5 = r5.equals(r8)     // Catch: java.lang.Throwable -> L4a
            if (r5 == 0) goto L35
        L30:
            r0.c(r4, r2, r3)     // Catch: java.lang.Throwable -> L4a
            r8 = r6
            goto L43
        L35:
            int r4 = r4 + r6
            r4 = r4 & r3
            r5 = r2[r4]     // Catch: java.lang.Throwable -> L4a
            if (r5 != 0) goto L3c
            goto L28
        L3c:
            boolean r5 = r5.equals(r8)     // Catch: java.lang.Throwable -> L4a
            if (r5 == 0) goto L35
            goto L30
        L43:
            if (r8 != 0) goto L46
            goto L48
        L46:
            monitor-exit(r7)     // Catch: java.lang.Throwable -> L4a
            return r6
        L48:
            monitor-exit(r7)     // Catch: java.lang.Throwable -> L4a
            return r1
        L4a:
            r8 = move-exception
            monitor-exit(r7)     // Catch: java.lang.Throwable -> L4a
            throw r8
        */
        throw new UnsupportedOperationException("Method not decompiled: d.a.p.a.a(d.a.p.b):boolean");
    }

    @Override // d.a.s.a.a
    public boolean b(b bVar) {
        if (!a(bVar)) {
            return false;
        }
        ((j) bVar).dispose();
        return true;
    }

    @Override // d.a.s.a.a
    public boolean c(b bVar) {
        if (!this.f5678c) {
            synchronized (this) {
                if (!this.f5678c) {
                    f<b> fVar = this.f5677b;
                    if (fVar == null) {
                        fVar = new f<>();
                        this.f5677b = fVar;
                    }
                    fVar.a(bVar);
                    return true;
                }
            }
        }
        bVar.dispose();
        return false;
    }

    @Override // d.a.p.b
    public void dispose() {
        if (this.f5678c) {
            return;
        }
        synchronized (this) {
            if (this.f5678c) {
                return;
            }
            this.f5678c = true;
            f<b> fVar = this.f5677b;
            ArrayList arrayList = null;
            this.f5677b = null;
            if (fVar == null) {
                return;
            }
            for (b bVar : fVar.f5920d) {
                if (bVar instanceof b) {
                    try {
                        bVar.dispose();
                    } catch (Throwable th) {
                        n0.y(th);
                        if (arrayList == null) {
                            arrayList = new ArrayList();
                        }
                        arrayList.add(th);
                    }
                }
            }
            if (arrayList != null) {
                if (arrayList.size() != 1) {
                    throw new d.a.q.a(arrayList);
                }
                throw d.a((Throwable) arrayList.get(0));
            }
        }
    }

    @Override // d.a.p.b
    public boolean isDisposed() {
        return this.f5678c;
    }
}
