package com.google.android.gms.internal.ads;

import androidx.annotation.Nullable;
import java.util.Arrays;

/* JADX INFO: loaded from: classes2.dex */
public final class w81 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public long[] f17922a = new long[10];

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Object[] f17923b = new Object[10];

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

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

    @Nullable
    private final Object zzf() {
        ih1.b1(this.f17925d > 0);
        Object[] objArr = this.f17923b;
        int i10 = this.f17924c;
        Object obj = objArr[i10];
        objArr[i10] = null;
        this.f17924c = (i10 + 1) % objArr.length;
        this.f17925d--;
        return obj;
    }

    public final synchronized void a(long j10, Object obj) {
        try {
            if (this.f17925d > 0) {
                if (j10 <= this.f17922a[((this.f17924c + r0) - 1) % this.f17923b.length]) {
                    synchronized (this) {
                        this.f17924c = 0;
                        this.f17925d = 0;
                        Arrays.fill(this.f17923b, (Object) null);
                    }
                }
            }
            int length = this.f17923b.length;
            if (this.f17925d >= length) {
                int i10 = length + length;
                long[] jArr = new long[i10];
                Object[] objArr = new Object[i10];
                int i11 = this.f17924c;
                int i12 = length - i11;
                System.arraycopy(this.f17922a, i11, jArr, 0, i12);
                System.arraycopy(this.f17923b, this.f17924c, objArr, 0, i12);
                int i13 = this.f17924c;
                if (i13 > 0) {
                    System.arraycopy(this.f17922a, 0, jArr, i12, i13);
                    System.arraycopy(this.f17923b, 0, objArr, i12, this.f17924c);
                }
                this.f17922a = jArr;
                this.f17923b = objArr;
                this.f17924c = 0;
            }
            int i14 = this.f17924c;
            int i15 = this.f17925d;
            Object[] objArr2 = this.f17923b;
            int length2 = (i14 + i15) % objArr2.length;
            this.f17922a[length2] = j10;
            objArr2[length2] = obj;
            this.f17925d = i15 + 1;
        } catch (Throwable th) {
            throw th;
        }
    }

    public final synchronized int b() {
        return this.f17925d;
    }

    @Nullable
    public final synchronized Object zzd() {
        if (this.f17925d == 0) {
            return null;
        }
        return zzf();
    }

    @Nullable
    public final synchronized Object zze(long j10) {
        Object objZzf;
        objZzf = null;
        while (this.f17925d > 0 && j10 - this.f17922a[this.f17924c] >= 0) {
            objZzf = zzf();
        }
        return objZzf;
    }
}
