package 㴹.K.㗗;

import io.reactivex.internal.disposables.DisposableHelper;
import io.reactivex.internal.util.NotificationLite;
import ඓ.ⁱ.K.ඓ.C1252;
import 㴹.K.AbstractC2520;
import 㴹.K.Ԕ.ᨨ.C2455;
import 㴹.K.㑃.AbstractC2514;

/* renamed from: 㴹.K.㗗.K  reason: contains not printable characters */
/* compiled from: SerializedObserver */
public final class C2516<T> implements AbstractC2520<T>, AbstractC2514 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public final boolean f8517 = false;

    /* renamed from: ඓ  reason: contains not printable characters */
    public boolean f8518;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final AbstractC2520<? super T> f8519;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public volatile boolean f8520;

    /* renamed from: 㴹  reason: contains not printable characters */
    public C2455<Object> f8521;

    /* renamed from: 㸾  reason: contains not printable characters */
    public AbstractC2514 f8522;

    public C2516(AbstractC2520<? super T> r1) {
        this.f8519 = r1;
    }

    @Override // 㴹.K.㑃.AbstractC2514
    public void dispose() {
        this.f8522.dispose();
    }

    @Override // 㴹.K.㑃.AbstractC2514
    public boolean isDisposed() {
        return this.f8522.isDisposed();
    }

    @Override // 㴹.K.AbstractC2520
    public void onComplete() {
        if (!this.f8520) {
            synchronized (this) {
                if (!this.f8520) {
                    if (this.f8518) {
                        C2455<Object> k = this.f8521;
                        if (k == null) {
                            k = new C2455<>(4);
                            this.f8521 = k;
                        }
                        k.m6498(NotificationLite.complete());
                        return;
                    }
                    this.f8520 = true;
                    this.f8518 = true;
                    this.f8519.onComplete();
                }
            }
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:22:0x003a, code lost:
        if (r1 == false) goto L_0x0040;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:23:0x003c, code lost:
        ඓ.ⁱ.K.ඓ.C1252.m3349(r4);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:24:0x003f, code lost:
        return;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:25:0x0040, code lost:
        r3.f8519.onError(r4);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:26:0x0045, code lost:
        return;
     */
    @Override // 㴹.K.AbstractC2520
    public void onError(Throwable th) {
        if (this.f8520) {
            C1252.m3349(th);
            return;
        }
        synchronized (this) {
            boolean z = false;
            if (this.f8520) {
                z = true;
            } else if (this.f8518) {
                this.f8520 = true;
                C2455<Object> k = this.f8521;
                if (k == null) {
                    k = new C2455<>(4);
                    this.f8521 = k;
                }
                Object error = NotificationLite.error(th);
                if (this.f8517) {
                    k.m6498(error);
                } else {
                    k.f8408[0] = error;
                }
            } else {
                this.f8520 = true;
                this.f8518 = true;
            }
        }
    }

    @Override // 㴹.K.AbstractC2520
    public void onNext(T t) {
        if (!this.f8520) {
            if (t == null) {
                this.f8522.dispose();
                onError(new NullPointerException("onNext called with null. Null values are generally not allowed in 2.x operators and sources."));
                return;
            }
            synchronized (this) {
                if (!this.f8520) {
                    if (this.f8518) {
                        C2455<Object> k = this.f8521;
                        if (k == null) {
                            k = new C2455<>(4);
                            this.f8521 = k;
                        }
                        k.m6498(NotificationLite.next(t));
                        return;
                    }
                    this.f8518 = true;
                    this.f8519.onNext(t);
                    m6567();
                }
            }
        }
    }

    @Override // 㴹.K.AbstractC2520
    public void onSubscribe(AbstractC2514 r2) {
        if (DisposableHelper.validate(this.f8522, r2)) {
            this.f8522 = r2;
            this.f8519.onSubscribe(this);
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:10:0x0014, code lost:
        if (r3 == null) goto L_0x002e;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:11:0x0016, code lost:
        r4 = 0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:12:0x0017, code lost:
        if (r4 >= r0) goto L_0x0029;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:13:0x0019, code lost:
        r5 = r3[r4];
     */
    /* JADX WARNING: Code restructure failed: missing block: B:14:0x001b, code lost:
        if (r5 != null) goto L_0x001e;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:16:0x0022, code lost:
        if (io.reactivex.internal.util.NotificationLite.acceptFull(r5, r2) == false) goto L_0x0026;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:17:0x0024, code lost:
        r1 = true;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:18:0x0026, code lost:
        r4 = r4 + 1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:19:0x0029, code lost:
        r3 = r3[r0];
     */
    /* JADX WARNING: Code restructure failed: missing block: B:28:0x002e, code lost:
        continue;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:9:0x000e, code lost:
        r2 = r6.f8519;
        r3 = r0.f8408;
        r0 = r0.f8409;
     */
    /* renamed from: K  reason: contains not printable characters */
    public void m6567() {
        boolean z;
        do {
            synchronized (this) {
                C2455<Object> k = this.f8521;
                z = false;
                if (k == null) {
                    this.f8518 = false;
                    return;
                }
                this.f8521 = null;
            }
        } while (!z);
    }
}
