package f.a.t;

import f.a.w.g.l;
import f.a.w.h.e;
import java.util.ArrayList;
import java.util.Objects;

/* JADX INFO: compiled from: CompositeDisposable.java */
/* JADX INFO: loaded from: classes.dex */
public final class a implements b, f.a.w.a.a {

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

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

    @Override // f.a.w.a.a
    public boolean a(b bVar) {
        if (!c(bVar)) {
            return false;
        }
        ((l) bVar).dispose();
        return true;
    }

    @Override // f.a.w.a.a
    public boolean b(b bVar) {
        Objects.requireNonNull(bVar, "disposable is null");
        if (!this.f3719e) {
            synchronized (this) {
                if (!this.f3719e) {
                    e<b> eVar = this.f3718b;
                    if (eVar == null) {
                        eVar = new e<>();
                        this.f3718b = eVar;
                    }
                    eVar.a(bVar);
                    return true;
                }
            }
        }
        bVar.dispose();
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:26:0x0048  */
    /* JADX WARN: Removed duplicated region for block: B:27:0x0049 A[Catch: all -> 0x004d, DONT_GENERATE, TryCatch #0 {, blocks: (B:6:0x000c, B:8:0x0010, B:10:0x0012, B:12:0x0016, B:27:0x0049, B:15:0x002a, B:17:0x0030, B:19:0x0035, B:22:0x003c, B:24:0x0042, B:29:0x004b), top: B:34:0x000c }] */
    @Override // f.a.w.a.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean c(f.a.t.b r8) {
        /*
            r7 = this;
            java.lang.String r0 = "disposables is null"
            java.util.Objects.requireNonNull(r8, r0)
            boolean r0 = r7.f3719e
            r1 = 0
            if (r0 == 0) goto Lb
            return r1
        Lb:
            monitor-enter(r7)
            boolean r0 = r7.f3719e     // Catch: java.lang.Throwable -> L4d
            if (r0 == 0) goto L12
            monitor-exit(r7)     // Catch: java.lang.Throwable -> L4d
            return r1
        L12:
            f.a.w.h.e<f.a.t.b> r0 = r7.f3718b     // Catch: java.lang.Throwable -> L4d
            if (r0 == 0) goto L4b
            T[] r2 = r0.f4042d     // Catch: java.lang.Throwable -> L4d
            int r3 = r0.a     // Catch: java.lang.Throwable -> L4d
            int r4 = r8.hashCode()     // Catch: java.lang.Throwable -> L4d
            int r4 = f.a.w.h.e.b(r4)     // Catch: java.lang.Throwable -> L4d
            r4 = r4 & r3
            r5 = r2[r4]     // Catch: java.lang.Throwable -> L4d
            r6 = 1
            if (r5 != 0) goto L2a
        L28:
            r8 = r1
            goto L46
        L2a:
            boolean r5 = r5.equals(r8)     // Catch: java.lang.Throwable -> L4d
            if (r5 == 0) goto L35
            r0.c(r4, r2, r3)     // Catch: java.lang.Throwable -> L4d
        L33:
            r8 = r6
            goto L46
        L35:
            int r4 = r4 + r6
            r4 = r4 & r3
            r5 = r2[r4]     // Catch: java.lang.Throwable -> L4d
            if (r5 != 0) goto L3c
            goto L28
        L3c:
            boolean r5 = r5.equals(r8)     // Catch: java.lang.Throwable -> L4d
            if (r5 == 0) goto L35
            r0.c(r4, r2, r3)     // Catch: java.lang.Throwable -> L4d
            goto L33
        L46:
            if (r8 != 0) goto L49
            goto L4b
        L49:
            monitor-exit(r7)     // Catch: java.lang.Throwable -> L4d
            return r6
        L4b:
            monitor-exit(r7)     // Catch: java.lang.Throwable -> L4d
            return r1
        L4d:
            r8 = move-exception
            monitor-exit(r7)     // Catch: java.lang.Throwable -> L4d
            throw r8
        */
        throw new UnsupportedOperationException("Method not decompiled: f.a.t.a.c(f.a.t.b):boolean");
    }

    public void d() {
        if (this.f3719e) {
            return;
        }
        synchronized (this) {
            if (this.f3719e) {
                return;
            }
            e<b> eVar = this.f3718b;
            this.f3718b = null;
            e(eVar);
        }
    }

    @Override // f.a.t.b
    public void dispose() {
        if (this.f3719e) {
            return;
        }
        synchronized (this) {
            if (this.f3719e) {
                return;
            }
            this.f3719e = true;
            e<b> eVar = this.f3718b;
            this.f3718b = null;
            e(eVar);
        }
    }

    public void e(e<b> eVar) {
        if (eVar == null) {
            return;
        }
        ArrayList arrayList = null;
        for (b bVar : eVar.f4042d) {
            if (bVar instanceof b) {
                try {
                    bVar.dispose();
                } catch (Throwable th) {
                    d.i.c.a.L(th);
                    if (arrayList == null) {
                        arrayList = new ArrayList();
                    }
                    arrayList.add(th);
                }
            }
        }
        if (arrayList != null) {
            if (arrayList.size() != 1) {
                throw new f.a.u.a(arrayList);
            }
            throw f.a.w.h.c.a((Throwable) arrayList.get(0));
        }
    }
}
