content: package okio;
  
  import kotlin.Metadata;
  import kotlin.jvm.internal.Intrinsics;
  
  @Metadata(bv = {1, 0, 3}, d1 = {"\u0000>\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\b\u0000\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\b\u0010\u000f\u001a\u00020\u0010H\u0016J\u0018\u0010\u0011\u001a\u00020\u000e2\u0006\u0010\u0012\u001a\u00020\u00062\u0006\u0010\u0013\u001a\u00020\u000eH\u0016J\b\u0010\u0014\u001a\u00020\u0015H\u0016R\u000e\u0010\u0005\u001a\u00020\u0006X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\nX\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u000b\u001a\u0004\u0018\u00010\fX\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\u000eX\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0004¢\u0006\u0002\n\u0000¨\u0006\u0016"}, d2 = {"Lokio/PeekSource;", "Lokio/Source;", "upstream", "Lokio/BufferedSource;", "(Lokio/BufferedSource;)V", "buffer", "Lokio/Buffer;", "closed", "", "expectedPos", "", "expectedSegment", "Lokio/Segment;", "pos", "", "close", "", "read", "sink", "byteCount", "timeout", "Lokio/Timeout;", "okio"}, k = 1, mv = {1, 4, 0})
  /* compiled from: PeekSource.kt */
  public final class PeekSource implements Source {
      private final Buffer buffer;
      private boolean closed;
      private int expectedPos;
      private Segment expectedSegment;
      private long pos;
      private final BufferedSource upstream;
  
      public PeekSource(BufferedSource upstream2) {
          Intrinsics.checkNotNullParameter(upstream2, "upstream");
          this.upstream = upstream2;
          Buffer buffer2 = upstream2.getBuffer();
          this.buffer = buffer2;
          this.expectedSegment = buffer2.head;
          Segment segment = buffer2.head;
          this.expectedPos = segment != null ? segment.pos : -1;
      }
  
      public void close() {
          this.closed = true;
      }
  
      /* JADX WARNING: Code restructure failed: missing block: B:12:0x002e, code lost:
          if (r2 == r5.pos) goto L_0x0030;
       */
      /* JADX WARNING: Removed duplicated region for block: B:15:0x0033  */
      /* JADX WARNING: Removed duplicated region for block: B:28:0x007f  */
      /* Code decompiled incorrectly, please refer to instructions dump. */
      public long read(okio.Buffer r9, long r10) {
          /*
              r8 = this;
              java.lang.String r0 = "sink"
              kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r9, r0)
              r0 = 0
              int r2 = (r10 > r0 ? 1 : (r10 == r0 ? 0 : -1))
              r3 = 0
              r4 = 1
              if (r2 < 0) goto L_0x0010
              r2 = r4
              goto L_0x0011
          L_0x0010:
              r2 = r3
          L_0x0011:
              if (r2 == 0) goto L_0x009f
              boolean r2 = r8.closed
              r2 = r2 ^ r4
              if (r2 == 0) goto L_0x008f
              okio.Segment r2 = r8.expectedSegment
              if (r2 == 0) goto L_0x0030
              okio.Buffer r5 = r8.buffer
              okio.Segment r5 = r5.head
              if (r2 != r5) goto L_0x0031
              int r2 = r8.expectedPos
              okio.Buffer r5 = r8.buffer
              okio.Segment r5 = r5.head
              kotlin.jvm.internal.Intrinsics.checkNotNull(r5)
              int r5 = r5.pos
              if (r2 != r5) goto L_0x0031
          L_0x0030:
              r3 = r4
          L_0x0031:
              if (r3 == 0) goto L_0x007f
              int r2 = (r10 > r0 ? 1 : (r10 == r0 ? 0 : -1))
              if (r2 != 0) goto L_0x0038
              return r0
          L_0x0038:
              okio.BufferedSource r0 = r8.upstream
              long r1 = r8.pos
              r3 = 1
              long r1 = r1 + r3
              boolean r0 = r0.request(r1)
              if (r0 != 0) goto L_0x0048
              r0 = -1
              return r0
          L_0x0048:
              okio.Segment r0 = r8.expectedSegment
              if (r0 != 0) goto L_0x0063
              okio.Buffer r0 = r8.buffer
              okio.Segment r0 = r0.head
              if (r0 == 0) goto L_0x0063
              okio.Buffer r0 = r8.buffer
              okio.Segment r0 = r0.head
              r8.expectedSegment = r0
              okio.Buffer r0 = r8.buffer
              okio.Segment r0 = r0.head
              kotlin.jvm.internal.Intrinsics.checkNotNull(r0)
              int r0 = r0.pos
              r8.expectedPos = r0
          L_0x0063:
              okio.Buffer r0 = r8.buffer
              long r0 = r0.size()
              long r2 = r8.pos
              long r0 = r0 - r2
              long r0 = java.lang.Math.min(r10, r0)
              okio.Buffer r2 = r8.buffer
              long r4 = r8.pos
              r3 = r9
              r6 = r0
              r2.copyTo((okio.Buffer) r3, (long) r4, (long) r6)
              long r2 = r8.pos
              long r2 = r2 + r0
              r8.pos = r2
              return r0
          L_0x007f:
              r0 = 0
              java.lang.IllegalStateException r0 = new java.lang.IllegalStateException
              java.lang.String r1 = "Peek source is invalid because upstream source was used"
              java.lang.String r1 = r1.toString()
              r0.<init>(r1)
              java.lang.Throwable r0 = (java.lang.Throwable) r0
              throw r0
          L_0x008f:
              r0 = 0
              java.lang.IllegalStateException r0 = new java.lang.IllegalStateException
              java.lang.String r1 = "closed"
              java.lang.String r1 = r1.toString()
              r0.<init>(r1)
              java.lang.Throwable r0 = (java.lang.Throwable) r0
              throw r0
          L_0x009f:
              r0 = 0
              java.lang.StringBuilder r1 = new java.lang.StringBuilder
              r1.<init>()
              java.lang.String r2 = "byteCount < 0: "
              java.lang.StringBuilder r1 = r1.append(r2)
              java.lang.StringBuilder r1 = r1.append(r10)
              java.lang.String r0 = r1.toString()
              java.lang.IllegalArgumentException r1 = new java.lang.IllegalArgumentException
              java.lang.String r0 = r0.toString()
              r1.<init>(r0)
              java.lang.Throwable r1 = (java.lang.Throwable) r1
              throw r1
          */
          throw new UnsupportedOperationException("Method not decompiled: okio.PeekSource.read(okio.Buffer, long):long");
      }
  
      public Timeout timeout() {
          return this.upstream.timeout();
      }
  }
  