(function (_, kotlin_kotlin, kotlin_org_jetbrains_kotlinx_atomicfu, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core) {
  'use strict';
  //region block: imports
  var imul = Math.imul;
  var ensureNotNull = kotlin_kotlin.$_$.ui;
  var Unit_instance = kotlin_kotlin.$_$.m5;
  var toString = kotlin_kotlin.$_$.zc;
  var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.u1;
  var toLong = kotlin_kotlin.$_$.xc;
  var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.a2;
  var CoroutineImpl = kotlin_kotlin.$_$.ta;
  var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.fa;
  var protoOf = kotlin_kotlin.$_$.uc;
  var classMeta = kotlin_kotlin.$_$.jb;
  var setMetadataFor = kotlin_kotlin.$_$.vc;
  var Long = kotlin_kotlin.$_$.vh;
  var VOID = kotlin_kotlin.$_$.f;
  var atomic$ref$1 = kotlin_org_jetbrains_kotlinx_atomicfu.$_$.e;
  var atomic$long$1 = kotlin_org_jetbrains_kotlinx_atomicfu.$_$.d;
  var atomic$int$1 = kotlin_org_jetbrains_kotlinx_atomicfu.$_$.f;
  var THROW_CCE = kotlin_kotlin.$_$.ci;
  var CancellationException_init_$Create$ = kotlin_kotlin.$_$.a1;
  var CancellationException = kotlin_kotlin.$_$.ea;
  var CancellationException_init_$Init$ = kotlin_kotlin.$_$.z;
  var captureStack = kotlin_kotlin.$_$.db;
  var EmptyCoroutineContext_getInstance = kotlin_kotlin.$_$.t4;
  var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.x1;
  var interfaceMeta = kotlin_kotlin.$_$.vb;
  var cancel$default = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.m;
  var invokeOnCompletion$default = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.n;
  var Job = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.z1;
  var Key_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.s;
  var launch = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.k2;
  var isInterface = kotlin_kotlin.$_$.ec;
  var Key_instance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.w;
  var Dispatchers_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.u;
  var equals = kotlin_kotlin.$_$.mb;
  var IntCompanionObject_instance = kotlin_kotlin.$_$.y4;
  var StringBuilder_init_$Create$ = kotlin_kotlin.$_$.e1;
  var charSequenceLength = kotlin_kotlin.$_$.hb;
  var objectMeta = kotlin_kotlin.$_$.tc;
  var hashCode = kotlin_kotlin.$_$.ub;
  var toString_0 = kotlin_kotlin.$_$.vg;
  var objectCreate = kotlin_kotlin.$_$.sc;
  var Exception = kotlin_kotlin.$_$.rh;
  var Exception_init_$Init$ = kotlin_kotlin.$_$.m1;
  var numberToChar = kotlin_kotlin.$_$.oc;
  var coerceAtLeast = kotlin_kotlin.$_$.hd;
  var coerceAtMost = kotlin_kotlin.$_$.jd;
  var Companion_getInstance = kotlin_kotlin.$_$.g5;
  var Char__toInt_impl_vasixd = kotlin_kotlin.$_$.b3;
  var toByte = kotlin_kotlin.$_$.wc;
  var _UShort___get_data__impl__g0245 = kotlin_kotlin.$_$.k4;
  var coerceAtMost_0 = kotlin_kotlin.$_$.id;
  var coerceAtLeast_0 = kotlin_kotlin.$_$.gd;
  var copyOf = kotlin_kotlin.$_$.z6;
  var UnsupportedOperationException_init_$Create$ = kotlin_kotlin.$_$.r2;
  var toShort = kotlin_kotlin.$_$.yc;
  var _UShort___init__impl__jigrne = kotlin_kotlin.$_$.j4;
  var Companion_getInstance_0 = kotlin_kotlin.$_$.l5;
  var charSequenceGet = kotlin_kotlin.$_$.gb;
  var isLowSurrogate = kotlin_kotlin.$_$.ef;
  var isHighSurrogate = kotlin_kotlin.$_$.df;
  var Job_0 = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.y1;
  var lazy = kotlin_kotlin.$_$.aj;
  var KProperty1 = kotlin_kotlin.$_$.td;
  var getPropertyCallableRef = kotlin_kotlin.$_$.sb;
  var IndexOutOfBoundsException_init_$Create$ = kotlin_kotlin.$_$.e2;
  var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.u2;
  var replace = kotlin_kotlin.$_$.sf;
  var getStringHashCode = kotlin_kotlin.$_$.tb;
  var extendThrowable = kotlin_kotlin.$_$.nb;
  var charSequenceSubSequence = kotlin_kotlin.$_$.ib;
  var IndexOutOfBoundsException_init_$Create$_0 = kotlin_kotlin.$_$.d2;
  var Exception_init_$Init$_0 = kotlin_kotlin.$_$.o1;
  var isCharSequence = kotlin_kotlin.$_$.ac;
  var trim = kotlin_kotlin.$_$.eh;
  var decodeToString = kotlin_kotlin.$_$.qe;
  var setOf = kotlin_kotlin.$_$.i9;
  var fillArrayVal = kotlin_kotlin.$_$.ob;
  //endregion
  //region block: pre-declaration
  setMetadataFor($awaitAtLeastNBytesAvailableForWriteCOROUTINE$0, '$awaitAtLeastNBytesAvailableForWriteCOROUTINE$0', classMeta, CoroutineImpl);
  setMetadataFor($awaitAtLeastNBytesAvailableForReadCOROUTINE$1, '$awaitAtLeastNBytesAvailableForReadCOROUTINE$1', classMeta, CoroutineImpl);
  setMetadataFor($writeFullyCOROUTINE$9, '$writeFullyCOROUTINE$9', classMeta, CoroutineImpl);
  setMetadataFor($writeFullyCOROUTINE$10, '$writeFullyCOROUTINE$10', classMeta, CoroutineImpl);
  setMetadataFor($readRemainingCOROUTINE$26, '$readRemainingCOROUTINE$26', classMeta, CoroutineImpl);
  setMetadataFor($readRemainingSuspendCOROUTINE$27, '$readRemainingSuspendCOROUTINE$27', classMeta, CoroutineImpl);
  setMetadataFor($readAvailableCOROUTINE$30, '$readAvailableCOROUTINE$30', classMeta, CoroutineImpl);
  setMetadataFor($readAvailableCOROUTINE$33, '$readAvailableCOROUTINE$33', classMeta, CoroutineImpl);
  setMetadataFor($awaitInternalAtLeast1COROUTINE$38, '$awaitInternalAtLeast1COROUTINE$38', classMeta, CoroutineImpl);
  setMetadataFor($awaitSuspendCOROUTINE$39, '$awaitSuspendCOROUTINE$39', classMeta, CoroutineImpl);
  function readRemaining$default(limit, $completion, $super) {
    var tmp;
    if (limit === VOID) {
      Companion_getInstance();
      tmp = new Long(-1, 2147483647);
    } else {
      tmp = limit;
    }
    limit = tmp;
    return $super === VOID ? this.x2c(limit, $completion) : $super.x2c.call(this, limit, $completion);
  }
  setMetadataFor(ByteReadChannel_1, 'ByteReadChannel', interfaceMeta, VOID, VOID, VOID, VOID, VOID, [3, 1, 2, 0, 5]);
  setMetadataFor(ByteChannelSequentialBase, 'ByteChannelSequentialBase', classMeta, VOID, [ByteReadChannel_1], VOID, VOID, VOID, [1, 3, 0, 2, 5]);
  setMetadataFor(ClosedWriteChannelException, 'ClosedWriteChannelException', classMeta, CancellationException);
  setMetadataFor(CloseElement, 'CloseElement', classMeta);
  setMetadataFor(WriterScope, 'WriterScope', interfaceMeta, VOID, [CoroutineScope]);
  setMetadataFor(ChannelJob, 'ChannelJob', classMeta, VOID, [Job], VOID, VOID, VOID, [0]);
  setMetadataFor(ChannelScope, 'ChannelScope', classMeta, VOID, [CoroutineScope, WriterScope]);
  setMetadataFor(launchChannel$slambda, 'launchChannel$slambda', classMeta, CoroutineImpl, VOID, VOID, VOID, VOID, [1]);
  setMetadataFor(Companion, 'Companion', objectMeta);
  setMetadataFor(Buffer, 'Buffer', classMeta);
  setMetadataFor(InsufficientSpaceException, 'InsufficientSpaceException', classMeta, Exception, VOID, InsufficientSpaceException);
  setMetadataFor(DefaultPool, 'DefaultPool', classMeta);
  setMetadataFor(DefaultBufferPool, 'DefaultBufferPool', classMeta, DefaultPool, VOID, DefaultBufferPool);
  setMetadataFor(Output, 'Output', classMeta);
  setMetadataFor(BytePacketBuilder, 'BytePacketBuilder', classMeta, Output, VOID, BytePacketBuilder);
  setMetadataFor(Companion_0, 'Companion', objectMeta);
  setMetadataFor(Input, 'Input', classMeta);
  setMetadataFor(ByteReadPacket, 'ByteReadPacket', classMeta, Input);
  setMetadataFor(Companion_1, 'Companion', objectMeta);
  setMetadataFor(ChunkBuffer$Companion$EmptyPool$1, VOID, classMeta);
  setMetadataFor(NoPoolImpl, 'NoPoolImpl', classMeta);
  setMetadataFor(ChunkBuffer$Companion$NoPool$1, VOID, classMeta, NoPoolImpl);
  setMetadataFor(ChunkBuffer$Companion$NoPoolManuallyManaged$1, VOID, classMeta, NoPoolImpl);
  setMetadataFor(Companion_2, 'Companion', objectMeta);
  setMetadataFor(ChunkBuffer, 'ChunkBuffer', classMeta, Buffer);
  setMetadataFor(MalformedUTF8InputException, 'MalformedUTF8InputException', classMeta, Exception);
  setMetadataFor($sleepCOROUTINE$52, '$sleepCOROUTINE$52', classMeta, CoroutineImpl);
  setMetadataFor($trySuspendCOROUTINE$53, '$trySuspendCOROUTINE$53', classMeta, CoroutineImpl);
  setMetadataFor(AwaitingSlot, 'AwaitingSlot', classMeta, VOID, VOID, AwaitingSlot, VOID, VOID, [1]);
  setMetadataFor($copyToSequentialImplCOROUTINE$54, '$copyToSequentialImplCOROUTINE$54', classMeta, CoroutineImpl);
  setMetadataFor($copyToTailCOROUTINE$55, '$copyToTailCOROUTINE$55', classMeta, CoroutineImpl);
  setMetadataFor(ByteArrayPool$1, VOID, classMeta, DefaultPool);
  setMetadataFor(ByteChannelJS, 'ByteChannelJS', classMeta, ByteChannelSequentialBase, VOID, VOID, VOID, VOID, [3, 1, 0, 2, 5]);
  setMetadataFor(Companion_3, 'Companion', objectMeta);
  setMetadataFor(DefaultAllocator, 'DefaultAllocator', objectMeta);
  setMetadataFor(Companion_4, 'Companion', objectMeta);
  setMetadataFor(Memory, 'Memory', classMeta);
  setMetadataFor(Companion_5, 'Companion', objectMeta);
  setMetadataFor(Charset, 'Charset', classMeta);
  setMetadataFor(Charsets, 'Charsets', objectMeta);
  setMetadataFor(MalformedInputException, 'MalformedInputException', classMeta, Error);
  setMetadataFor(CharsetDecoder, 'CharsetDecoder', classMeta);
  setMetadataFor(CharsetEncoder, 'CharsetEncoder', classMeta);
  setMetadataFor(CharsetImpl, 'CharsetImpl', classMeta, Charset);
  setMetadataFor(CharsetEncoderImpl, 'CharsetEncoderImpl', classMeta, CharsetEncoder);
  setMetadataFor(CharsetDecoderImpl, 'CharsetDecoderImpl', classMeta, CharsetDecoder);
  setMetadataFor(DecodeBufferResult, 'DecodeBufferResult', classMeta);
  setMetadataFor(IOException, 'IOException', classMeta, Exception);
  setMetadataFor(EOFException, 'EOFException', classMeta, IOException);
  setMetadataFor(toKtor$1, VOID, classMeta);
  setMetadataFor(TextDecoderFallback, 'TextDecoderFallback', classMeta);
  //endregion
  function ByteReadChannel(content) {
    return ByteReadChannel_0(content, 0, content.length);
  }
  function _get_isCancelled__nhbn6y($this) {
    var tmp0_safe_receiver = $this.a26_1.kotlinx$atomicfu$value;
    return !((tmp0_safe_receiver == null ? null : tmp0_safe_receiver.i26_1) == null);
  }
  function flushImpl($this) {
    if ($this.b26_1.t26()) {
      $this.f26_1.k26();
      return false;
    }
    flushWrittenBytes($this);
    $this.f26_1.k26();
    return true;
  }
  function flushWrittenBytes($this) {
    // Inline function 'kotlinx.atomicfu.locks.synchronized' call
    $this.g26_1;
    // Inline function 'io.ktor.utils.io.ByteChannelSequentialBase.flushWrittenBytes.<anonymous>' call
    var size = $this.b26_1.u();
    var buffer = ensureNotNull($this.b26_1.c27());
    $this.h26_1.d27(buffer);
    $this.y25_1.atomicfu$addAndGet(size);
  }
  function ensureNotClosed($this) {
    if ($this.f27()) {
      var tmp0_elvis_lhs = $this.e27();
      throw tmp0_elvis_lhs == null ? new ClosedWriteChannelException('Channel ' + $this + ' is already closed') : tmp0_elvis_lhs;
    }
  }
  function ensureNotFailed($this) {
    var tmp0_safe_receiver = $this.e27();
    if (tmp0_safe_receiver == null)
      null;
    else {
      // Inline function 'kotlin.let' call
      // Inline function 'kotlin.contracts.contract' call
      throw tmp0_safe_receiver;
    }
  }
  function ensureNotFailed_0($this, closeable) {
    var tmp0_safe_receiver = $this.e27();
    if (tmp0_safe_receiver == null)
      null;
    else {
      // Inline function 'kotlin.let' call
      // Inline function 'kotlin.contracts.contract' call
      closeable.qy();
      throw tmp0_safe_receiver;
    }
  }
  function readRemainingSuspend($this, builder, limit, $completion) {
    var tmp = new $readRemainingSuspendCOROUTINE$27($this, builder, limit, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  }
  function addBytesRead($this, count) {
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(count >= 0)) {
      // Inline function 'io.ktor.utils.io.ByteChannelSequentialBase.addBytesRead.<anonymous>' call
      var message = "Can't read negative amount of bytes: " + count;
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    // Inline function 'kotlinx.atomicfu.AtomicInt.minusAssign' call
    $this.z25_1.atomicfu$getAndAdd(-count | 0);
    $this.w25_1.atomicfu$addAndGet$long(toLong(count));
    // Inline function 'kotlinx.atomicfu.AtomicInt.minusAssign' call
    $this.y25_1.atomicfu$getAndAdd(-count | 0);
    // Inline function 'kotlin.check' call
    // Inline function 'kotlin.contracts.contract' call
    if (!($this.z25_1.kotlinx$atomicfu$value >= 0)) {
      // Inline function 'io.ktor.utils.io.ByteChannelSequentialBase.addBytesRead.<anonymous>' call
      var message_0 = 'Readable bytes count is negative: ' + $this.s27() + ', ' + count + ' in ' + $this;
      throw IllegalStateException_init_$Create$(toString(message_0));
    }
    // Inline function 'kotlin.check' call
    // Inline function 'kotlin.contracts.contract' call
    if (!($this.s27() >= 0)) {
      // Inline function 'io.ktor.utils.io.ByteChannelSequentialBase.addBytesRead.<anonymous>' call
      var message_1 = 'Readable bytes count is negative: ' + $this.s27() + ', ' + count + ' in ' + $this;
      throw IllegalStateException_init_$Create$(toString(message_1));
    }
  }
  function addBytesWritten($this, count) {
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(count >= 0)) {
      // Inline function 'io.ktor.utils.io.ByteChannelSequentialBase.addBytesWritten.<anonymous>' call
      var message = "Can't write negative amount of bytes: " + count;
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    // Inline function 'kotlinx.atomicfu.AtomicInt.plusAssign' call
    $this.z25_1.atomicfu$getAndAdd(count);
    $this.x25_1.atomicfu$addAndGet$long(toLong(count));
    // Inline function 'kotlin.check' call
    // Inline function 'kotlin.contracts.contract' call
    if (!($this.z25_1.kotlinx$atomicfu$value >= 0)) {
      // Inline function 'io.ktor.utils.io.ByteChannelSequentialBase.addBytesWritten.<anonymous>' call
      var message_0 = 'Readable bytes count is negative: ' + $this.z25_1.kotlinx$atomicfu$value + ', ' + count + ' in ' + $this;
      throw IllegalStateException_init_$Create$(toString(message_0));
    }
  }
  function ByteChannelSequentialBase$awaitAtLeastNBytesAvailableForWrite$lambda(this$0, $count) {
    return function () {
      return this$0.t27() < $count ? !this$0.f27() : false;
    };
  }
  function ByteChannelSequentialBase$awaitAtLeastNBytesAvailableForRead$lambda(this$0, $count) {
    return function () {
      return this$0.s27() < $count ? !this$0.u27() : false;
    };
  }
  function $awaitAtLeastNBytesAvailableForWriteCOROUTINE$0(_this__u8e3s4, count, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.d28_1 = _this__u8e3s4;
    this.e28_1 = count;
  }
  protoOf($awaitAtLeastNBytesAvailableForWriteCOROUTINE$0).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 4;
            this.hd_1 = 1;
            continue $sm;
          case 1:
            if (!(this.d28_1.t27() < this.e28_1 ? !this.d28_1.f27() : false)) {
              this.hd_1 = 5;
              continue $sm;
            }

            if (!flushImpl(this.d28_1)) {
              this.hd_1 = 2;
              suspendResult = this.d28_1.f26_1.f28(ByteChannelSequentialBase$awaitAtLeastNBytesAvailableForWrite$lambda(this.d28_1, this.e28_1), this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.hd_1 = 3;
              continue $sm;
            }

          case 2:
            this.hd_1 = 3;
            continue $sm;
          case 3:
            this.hd_1 = 1;
            continue $sm;
          case 4:
            throw this.kd_1;
          case 5:
            return Unit_instance;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 4) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function $awaitAtLeastNBytesAvailableForReadCOROUTINE$1(_this__u8e3s4, count, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.o28_1 = _this__u8e3s4;
    this.p28_1 = count;
  }
  protoOf($awaitAtLeastNBytesAvailableForReadCOROUTINE$1).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 3;
            this.hd_1 = 1;
            continue $sm;
          case 1:
            if (!(this.o28_1.s27() < this.p28_1 ? !this.o28_1.u27() : false)) {
              this.hd_1 = 4;
              continue $sm;
            }

            this.hd_1 = 2;
            suspendResult = this.o28_1.f26_1.f28(ByteChannelSequentialBase$awaitAtLeastNBytesAvailableForRead$lambda(this.o28_1, this.p28_1), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 2:
            this.hd_1 = 1;
            continue $sm;
          case 3:
            throw this.kd_1;
          case 4:
            return Unit_instance;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 3) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function $writeFullyCOROUTINE$9(_this__u8e3s4, src, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.y28_1 = _this__u8e3s4;
    this.z28_1 = src;
  }
  protoOf($writeFullyCOROUTINE$9).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 2;
            this.hd_1 = 1;
            suspendResult = this.y28_1.a29(1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            var this_0 = this.z28_1;
            var count = this_0.d29_1 - this_0.c29_1 | 0;
            writeFully_2(this.y28_1.b26_1, this.z28_1);
            this.y28_1.h29(count);
            return Unit_instance;
          case 2:
            throw this.kd_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 2) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function $writeFullyCOROUTINE$10(_this__u8e3s4, src, offset, length, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.q29_1 = _this__u8e3s4;
    this.r29_1 = src;
    this.s29_1 = offset;
    this.t29_1 = length;
  }
  protoOf($writeFullyCOROUTINE$10).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 4;
            this.u29_1 = this.s29_1;
            this.v29_1 = this.s29_1 + this.t29_1 | 0;
            this.hd_1 = 1;
            continue $sm;
          case 1:
            if (!(this.u29_1 < this.v29_1)) {
              this.hd_1 = 3;
              continue $sm;
            }

            this.hd_1 = 2;
            suspendResult = this.q29_1.a29(1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 2:
            var a = this.q29_1.t27();
            var b = this.v29_1 - this.u29_1 | 0;
            var bytesCount = Math.min(a, b);
            writeFully_3(this.q29_1.b26_1, this.r29_1, this.u29_1, bytesCount);
            this.u29_1 = this.u29_1 + bytesCount | 0;
            this.q29_1.h29(bytesCount);
            this.hd_1 = 1;
            continue $sm;
          case 3:
            return Unit_instance;
          case 4:
            throw this.kd_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 4) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function $readRemainingCOROUTINE$26(_this__u8e3s4, limit, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.e2a_1 = _this__u8e3s4;
    this.f2a_1 = limit;
  }
  protoOf($readRemainingCOROUTINE$26).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 3;
            ensureNotFailed(this.e2a_1);
            this.g2a_1 = new BytePacketBuilder();
            var tmp_0 = this;
            var a = this.f2a_1;
            var b = this.e2a_1.c26_1.r2a();
            tmp_0.h2a_1 = a.c7(b) <= 0 ? a : b;
            this.g2a_1.s2a(this.e2a_1.c26_1, this.h2a_1);
            this.e2a_1.t2a(this.h2a_1.mb());
            var tmp_1 = this;
            var this_0 = this.f2a_1;
            var other = this.g2a_1.u();
            tmp_1.i2a_1 = this_0.mc(toLong(other));
            if (this.i2a_1.equals(new Long(0, 0)) ? true : this.e2a_1.u27()) {
              var tmp_2 = this;
              ensureNotFailed_0(this.e2a_1, this.g2a_1);
              tmp_2.j2a_1 = this.g2a_1.f3();
              this.hd_1 = 2;
              continue $sm;
            } else {
              this.hd_1 = 1;
              suspendResult = readRemainingSuspend(this.e2a_1, this.g2a_1, this.f2a_1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            }

          case 1:
            this.j2a_1 = suspendResult;
            this.hd_1 = 2;
            continue $sm;
          case 2:
            return this.j2a_1;
          case 3:
            throw this.kd_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 3) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function $readRemainingSuspendCOROUTINE$27(_this__u8e3s4, builder, limit, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.o27_1 = _this__u8e3s4;
    this.p27_1 = builder;
    this.q27_1 = limit;
  }
  protoOf($readRemainingSuspendCOROUTINE$27).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 5;
            this.hd_1 = 1;
            continue $sm;
          case 1:
            if (!(toLong(this.p27_1.u()).c7(this.q27_1) < 0)) {
              this.hd_1 = 4;
              continue $sm;
            }

            var tmp_0 = this;
            var this_0 = this.q27_1;
            var other = this.p27_1.u();
            var a = this_0.mc(toLong(other));
            var b = this.o27_1.c26_1.r2a();
            tmp_0.r27_1 = a.c7(b) <= 0 ? a : b;
            this.p27_1.s2a(this.o27_1.c26_1, this.r27_1);
            this.o27_1.t2a(this.r27_1.mb());
            ensureNotFailed_0(this.o27_1, this.p27_1);
            if (this.o27_1.u27() ? true : this.p27_1.u() === this.q27_1.mb()) {
              this.hd_1 = 4;
              continue $sm;
            } else {
              this.hd_1 = 2;
              continue $sm;
            }

          case 2:
            this.hd_1 = 3;
            suspendResult = this.o27_1.u2a(1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 3:
            this.hd_1 = 1;
            continue $sm;
          case 4:
            ensureNotFailed_0(this.o27_1, this.p27_1);
            return this.p27_1.f3();
          case 5:
            throw this.kd_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 5) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function $readAvailableCOROUTINE$30(_this__u8e3s4, dst, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.d2b_1 = _this__u8e3s4;
    this.e2b_1 = dst;
  }
  protoOf($readAvailableCOROUTINE$30).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 3;
            var tmp0_safe_receiver = this.d2b_1.e27();
            if (tmp0_safe_receiver == null)
              null;
            else {
              throw tmp0_safe_receiver;
            }

            if (this.d2b_1.f27() ? this.d2b_1.s27() === 0 : false)
              return -1;
            var this_0 = this.e2b_1;
            if ((this_0.f29_1 - this_0.d29_1 | 0) === 0)
              return 0;
            if (this.d2b_1.s27() === 0) {
              this.hd_1 = 1;
              suspendResult = this.d2b_1.u2a(1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.hd_1 = 2;
              continue $sm;
            }

          case 1:
            this.hd_1 = 2;
            continue $sm;
          case 2:
            if (!this.d2b_1.c26_1.g2b()) {
              this.d2b_1.f2b();
            }

            var this_1 = this.e2b_1;
            var a = toLong(this_1.f29_1 - this_1.d29_1 | 0);
            var b = this.d2b_1.c26_1.r2a();
            var size = (a.c7(b) <= 0 ? a : b).mb();
            readFully_2(this.d2b_1.c26_1, this.e2b_1, size);
            this.d2b_1.t2a(size);
            return size;
          case 3:
            throw this.kd_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 3) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function $readAvailableCOROUTINE$33(_this__u8e3s4, dst, offset, length, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.p2b_1 = _this__u8e3s4;
    this.q2b_1 = dst;
    this.r2b_1 = offset;
    this.s2b_1 = length;
  }
  protoOf($readAvailableCOROUTINE$33).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 3;
            var tmp0_safe_receiver = this.p2b_1.e27();
            if (tmp0_safe_receiver == null)
              null;
            else {
              throw tmp0_safe_receiver;
            }

            if (this.p2b_1.f27() ? this.p2b_1.s27() === 0 : false)
              return -1;
            if (this.s2b_1 === 0)
              return 0;
            if (this.p2b_1.s27() === 0) {
              this.hd_1 = 1;
              suspendResult = this.p2b_1.u2a(1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.hd_1 = 2;
              continue $sm;
            }

          case 1:
            this.hd_1 = 2;
            continue $sm;
          case 2:
            if (!this.p2b_1.c26_1.g2b()) {
              this.p2b_1.f2b();
            }

            var a = toLong(this.s2b_1);
            var b = this.p2b_1.c26_1.r2a();
            var size = (a.c7(b) <= 0 ? a : b).mb();
            readFully_1(this.p2b_1.c26_1, this.q2b_1, this.r2b_1, size);
            this.p2b_1.t2a(size);
            return size;
          case 3:
            throw this.kd_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 3) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function $awaitInternalAtLeast1COROUTINE$38(_this__u8e3s4, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.b2c_1 = _this__u8e3s4;
  }
  protoOf($awaitInternalAtLeast1COROUTINE$38).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 2;
            if (!this.b2c_1.c26_1.d2c()) {
              var tmp_0 = this;
              tmp_0.c2c_1 = true;
              this.hd_1 = 3;
              continue $sm;
            } else {
              this.hd_1 = 1;
              suspendResult = this.b2c_1.u2a(1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            }

          case 1:
            this.c2c_1 = suspendResult;
            this.hd_1 = 3;
            continue $sm;
          case 2:
            throw this.kd_1;
          case 3:
            return this.c2c_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 2) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function $awaitSuspendCOROUTINE$39(_this__u8e3s4, atLeast, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.m2c_1 = _this__u8e3s4;
    this.n2c_1 = atLeast;
  }
  protoOf($awaitSuspendCOROUTINE$39).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 2;
            if (!(this.n2c_1 >= 0)) {
              var message = 'Failed requirement.';
              throw IllegalArgumentException_init_$Create$(toString(message));
            }

            this.hd_1 = 1;
            suspendResult = this.m2c_1.o2c(this.n2c_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            this.m2c_1.f2b();
            var tmp0_safe_receiver = this.m2c_1.e27();
            if (tmp0_safe_receiver == null)
              null;
            else {
              throw tmp0_safe_receiver;
            }

            return !this.m2c_1.u27() ? this.m2c_1.s27() >= this.n2c_1 : false;
          case 2:
            throw this.kd_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 2) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function ByteChannelSequentialBase(initial, autoFlush, pool) {
    pool = pool === VOID ? Companion_getInstance_4().t2c() : pool;
    this.u25_1 = autoFlush;
    this.v25_1 = atomic$ref$1(Companion_getInstance_4().q2c_1);
    this.w25_1 = atomic$long$1(new Long(0, 0));
    this.x25_1 = atomic$long$1(new Long(0, 0));
    this.y25_1 = atomic$int$1(0);
    this.z25_1 = atomic$int$1(0);
    this.a26_1 = atomic$ref$1(null);
    this.b26_1 = new BytePacketBuilder(pool);
    this.c26_1 = ByteReadPacket_init_$Create$(initial, pool);
    this.d26_1 = atomic$int$1(0);
    this.e26_1 = atomic$ref$1(Companion_getInstance_4().q2c_1);
    this.f26_1 = new AwaitingSlot();
    this.g26_1 = new Object();
    this.h26_1 = new BytePacketBuilder();
    var count = remainingAll(initial).mb();
    this.h29(count);
    this.y25_1.atomicfu$addAndGet(count);
  }
  protoOf(ByteChannelSequentialBase).u2c = function () {
    return this.u25_1;
  };
  protoOf(ByteChannelSequentialBase).f27 = function () {
    return !(this.a26_1.kotlinx$atomicfu$value == null);
  };
  protoOf(ByteChannelSequentialBase).s27 = function () {
    return this.y25_1.kotlinx$atomicfu$value;
  };
  protoOf(ByteChannelSequentialBase).t27 = function () {
    // Inline function 'kotlin.comparisons.maxOf' call
    var b = 4088 - this.z25_1.kotlinx$atomicfu$value | 0;
    return Math.max(0, b);
  };
  protoOf(ByteChannelSequentialBase).u27 = function () {
    return _get_isCancelled__nhbn6y(this) ? true : this.f27() ? this.z25_1.kotlinx$atomicfu$value === 0 : false;
  };
  protoOf(ByteChannelSequentialBase).e27 = function () {
    var tmp0_safe_receiver = this.a26_1.kotlinx$atomicfu$value;
    return tmp0_safe_receiver == null ? null : tmp0_safe_receiver.i26_1;
  };
  protoOf(ByteChannelSequentialBase).a29 = function (count, $completion) {
    var tmp = new $awaitAtLeastNBytesAvailableForWriteCOROUTINE$0(this, count, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  };
  protoOf(ByteChannelSequentialBase).o2c = function (count, $completion) {
    var tmp = new $awaitAtLeastNBytesAvailableForReadCOROUTINE$1(this, count, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  };
  protoOf(ByteChannelSequentialBase).t6 = function () {
    flushImpl(this);
  };
  protoOf(ByteChannelSequentialBase).f2b = function () {
    // Inline function 'kotlinx.atomicfu.locks.synchronized' call
    this.g26_1;
    // Inline function 'io.ktor.utils.io.ByteChannelSequentialBase.prepareFlushedBytes.<anonymous>' call
    unsafeAppend(this.c26_1, this.h26_1);
  };
  protoOf(ByteChannelSequentialBase).v2c = function (src, $completion) {
    var tmp = new $writeFullyCOROUTINE$9(this, src, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  };
  protoOf(ByteChannelSequentialBase).w2c = function (src, offset, length, $completion) {
    var tmp = new $writeFullyCOROUTINE$10(this, src, offset, length, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  };
  protoOf(ByteChannelSequentialBase).t2a = function (count) {
    addBytesRead(this, count);
    this.f26_1.k26();
  };
  protoOf(ByteChannelSequentialBase).x2c = function (limit, $completion) {
    var tmp = new $readRemainingCOROUTINE$26(this, limit, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  };
  protoOf(ByteChannelSequentialBase).z2c = function (dst, $completion) {
    return this.a2d(dst instanceof Buffer ? dst : THROW_CCE(), $completion);
  };
  protoOf(ByteChannelSequentialBase).a2d = function (dst, $completion) {
    var tmp = new $readAvailableCOROUTINE$30(this, dst, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  };
  protoOf(ByteChannelSequentialBase).b2d = function (dst, offset, length, $completion) {
    var tmp = new $readAvailableCOROUTINE$33(this, dst, offset, length, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  };
  protoOf(ByteChannelSequentialBase).c2d = function ($completion) {
    var tmp = new $awaitInternalAtLeast1COROUTINE$38(this, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  };
  protoOf(ByteChannelSequentialBase).u2a = function (atLeast, $completion) {
    var tmp = new $awaitSuspendCOROUTINE$39(this, atLeast, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  };
  protoOf(ByteChannelSequentialBase).jx = function (cause) {
    if (!(this.e27() == null) ? true : this.f27()) {
      return false;
    }
    return this.c1a(cause == null ? CancellationException_init_$Create$('Channel cancelled') : cause);
  };
  protoOf(ByteChannelSequentialBase).c1a = function (cause) {
    var closeElement = cause == null ? get_CLOSED_SUCCESS() : new CloseElement(cause);
    if (!this.a26_1.atomicfu$compareAndSet(null, closeElement))
      return false;
    if (!(cause == null)) {
      this.c26_1.qy();
      this.b26_1.qy();
      this.h26_1.qy();
    } else {
      this.t6();
      this.b26_1.qy();
    }
    this.f26_1.d2d(cause);
    return true;
  };
  protoOf(ByteChannelSequentialBase).e2d = function (dst, limit) {
    var size = this.c26_1.r2a();
    var tmp;
    if (size.c7(limit) <= 0) {
      dst.b26_1.f2d(this.c26_1);
      dst.h29(size.mb());
      this.t2a(size.mb());
      tmp = size;
    } else {
      tmp = new Long(0, 0);
    }
    return tmp;
  };
  protoOf(ByteChannelSequentialBase).h29 = function (count) {
    addBytesWritten(this, count);
    if (this.f27()) {
      this.b26_1.qy();
      ensureNotClosed(this);
    }
    if (this.u2c() ? true : this.t27() === 0) {
      this.t6();
    }
  };
  function cancel(_this__u8e3s4) {
    return _this__u8e3s4.jx(null);
  }
  function readAvailable(_this__u8e3s4, dst, $completion) {
    return _this__u8e3s4.b2d(dst, 0, dst.length, $completion);
  }
  function close(_this__u8e3s4) {
    return _this__u8e3s4.c1a(null);
  }
  function ClosedWriteChannelException(message) {
    CancellationException_init_$Init$(message, this);
    captureStack(this, ClosedWriteChannelException);
  }
  function writeFully(_this__u8e3s4, src, $completion) {
    return _this__u8e3s4.w2c(src, 0, src.length, $completion);
  }
  function get_CLOSED_SUCCESS() {
    _init_properties_CloseElement_kt__5e72ik();
    return CLOSED_SUCCESS;
  }
  var CLOSED_SUCCESS;
  function CloseElement(cause) {
    this.i26_1 = cause;
  }
  var properties_initialized_CloseElement_kt_clkism;
  function _init_properties_CloseElement_kt__5e72ik() {
    if (!properties_initialized_CloseElement_kt_clkism) {
      properties_initialized_CloseElement_kt_clkism = true;
      CLOSED_SUCCESS = new CloseElement(null);
    }
  }
  function writer(_this__u8e3s4, coroutineContext, autoFlush, block) {
    coroutineContext = coroutineContext === VOID ? EmptyCoroutineContext_getInstance() : coroutineContext;
    autoFlush = autoFlush === VOID ? false : autoFlush;
    return launchChannel(_this__u8e3s4, coroutineContext, ByteChannel(autoFlush), true, block);
  }
  function WriterScope() {
  }
  function ChannelJob(delegate, channel) {
    this.h2d_1 = delegate;
    this.i2d_1 = channel;
  }
  protoOf(ChannelJob).p13 = function () {
    return this.i2d_1;
  };
  protoOf(ChannelJob).dq = function () {
    return this.h2d_1.dq();
  };
  protoOf(ChannelJob).s2 = function () {
    return this.h2d_1.s2();
  };
  protoOf(ChannelJob).wq = function () {
    return this.h2d_1.wq();
  };
  protoOf(ChannelJob).tr = function (child) {
    return this.h2d_1.tr(child);
  };
  protoOf(ChannelJob).lr = function (cause) {
    this.h2d_1.lr(cause);
  };
  protoOf(ChannelJob).kj = function (initial, operation) {
    return this.h2d_1.kj(initial, operation);
  };
  protoOf(ChannelJob).pd = function (key) {
    return this.h2d_1.pd(key);
  };
  protoOf(ChannelJob).cr = function () {
    return this.h2d_1.cr();
  };
  protoOf(ChannelJob).gr = function (onCancelling, invokeImmediately, handler) {
    return this.h2d_1.gr(onCancelling, invokeImmediately, handler);
  };
  protoOf(ChannelJob).fr = function (handler) {
    return this.h2d_1.fr(handler);
  };
  protoOf(ChannelJob).ir = function ($completion) {
    return this.h2d_1.ir($completion);
  };
  protoOf(ChannelJob).jj = function (key) {
    return this.h2d_1.jj(key);
  };
  protoOf(ChannelJob).lj = function (context) {
    return this.h2d_1.lj(context);
  };
  protoOf(ChannelJob).ar = function () {
    return this.h2d_1.ar();
  };
  protoOf(ChannelJob).toString = function () {
    return 'ChannelJob[' + this.h2d_1 + ']';
  };
  function launchChannel(_this__u8e3s4, context, channel, attachJob, block) {
    var dispatcher = _this__u8e3s4.cq().pd(Key_getInstance());
    var job = launch(_this__u8e3s4, context, VOID, launchChannel$slambda_0(attachJob, channel, block, dispatcher, null));
    job.fr(launchChannel$lambda(channel));
    return new ChannelJob(job, channel);
  }
  function ChannelScope(delegate, channel) {
    this.j2d_1 = channel;
    this.k2d_1 = delegate;
  }
  protoOf(ChannelScope).p13 = function () {
    return this.j2d_1;
  };
  protoOf(ChannelScope).cq = function () {
    return this.k2d_1.cq();
  };
  function launchChannel$slambda($attachJob, $channel, $block, $dispatcher, resultContinuation) {
    this.t2d_1 = $attachJob;
    this.u2d_1 = $channel;
    this.v2d_1 = $block;
    this.w2d_1 = $dispatcher;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(launchChannel$slambda).u1m = function ($this$launch, $completion) {
    var tmp = this.v1m($this$launch, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  };
  protoOf(launchChannel$slambda).he = function (p1, $completion) {
    return this.u1m((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
  };
  protoOf(launchChannel$slambda).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 3;
            if (this.t2d_1) {
              this.u2d_1.g2d(ensureNotNull(this.x2d_1.cq().pd(Key_instance)));
            }

            var tmp_0 = this;
            var tmp_1 = new ChannelScope(this.x2d_1, this.u2d_1);
            tmp_0.y2d_1 = isInterface(tmp_1, CoroutineScope) ? tmp_1 : THROW_CCE();
            this.id_1 = 2;
            this.hd_1 = 1;
            suspendResult = this.v2d_1(this.y2d_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            this.id_1 = 3;
            this.hd_1 = 4;
            continue $sm;
          case 2:
            this.id_1 = 3;
            var tmp_2 = this.kd_1;
            if (tmp_2 instanceof Error) {
              var cause = this.kd_1;
              if (!equals(this.w2d_1, Dispatchers_getInstance().q12_1) ? !(this.w2d_1 == null) : false) {
                throw cause;
              }
              this.u2d_1.jx(cause);
              this.hd_1 = 4;
              continue $sm;
            } else {
              throw this.kd_1;
            }

          case 3:
            throw this.kd_1;
          case 4:
            this.id_1 = 3;
            return Unit_instance;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 3) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  protoOf(launchChannel$slambda).v1m = function ($this$launch, completion) {
    var i = new launchChannel$slambda(this.t2d_1, this.u2d_1, this.v2d_1, this.w2d_1, completion);
    i.x2d_1 = $this$launch;
    return i;
  };
  function launchChannel$slambda_0($attachJob, $channel, $block, $dispatcher, resultContinuation) {
    var i = new launchChannel$slambda($attachJob, $channel, $block, $dispatcher, resultContinuation);
    var l = function ($this$launch, $completion) {
      return i.u1m($this$launch, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function launchChannel$lambda($channel) {
    return function (cause) {
      $channel.c1a(cause);
      return Unit_instance;
    };
  }
  function unwrapCancellationException(_this__u8e3s4) {
    var exception = _this__u8e3s4;
    $l$loop: while (exception instanceof CancellationException) {
      if (equals(exception, exception.cause)) {
        return _this__u8e3s4;
      }
      var tmp0_elvis_lhs = exception.cause;
      var tmp;
      if (tmp0_elvis_lhs == null) {
        return exception;
      } else {
        tmp = tmp0_elvis_lhs;
      }
      exception = tmp;
    }
    return exception;
  }
  function decode(_this__u8e3s4, input, max) {
    max = max === VOID ? IntCompanionObject_instance.MAX_VALUE : max;
    // Inline function 'kotlin.text.buildString' call
    // Inline function 'kotlin.comparisons.minOf' call
    var a = toLong(max);
    var b = sizeEstimate(input);
    var capacity = (a.c7(b) <= 0 ? a : b).mb();
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'kotlin.apply' call
    var this_0 = StringBuilder_init_$Create$(capacity);
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.charsets.decode.<anonymous>' call
    decode_0(_this__u8e3s4, input, this_0, max);
    return this_0.toString();
  }
  function encodeToImpl(_this__u8e3s4, destination, input, fromIndex, toIndex) {
    var start = fromIndex;
    if (start >= toIndex)
      return 0;
    var bytesWritten = 0;
    // Inline function 'io.ktor.utils.io.core.writeWhileSize' call
    var tail = prepareWriteHead(destination, 1, null);
    try {
      var size;
      $l$loop: while (true) {
        // Inline function 'io.ktor.utils.io.charsets.encodeToImpl.<anonymous>' call
        var view = tail;
        // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
        var before = view.f29_1 - view.d29_1 | 0;
        var rc = encodeImpl(_this__u8e3s4, input, start, toIndex, view);
        // Inline function 'kotlin.check' call
        // Inline function 'kotlin.contracts.contract' call
        // Inline function 'kotlin.check' call
        // Inline function 'kotlin.contracts.contract' call
        if (!(rc >= 0)) {
          // Inline function 'kotlin.check.<anonymous>' call
          var message = 'Check failed.';
          throw IllegalStateException_init_$Create$(toString(message));
        }
        start = start + rc | 0;
        var tmp = bytesWritten;
        // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
        bytesWritten = tmp + (before - (view.f29_1 - view.d29_1 | 0) | 0) | 0;
        size = start >= toIndex ? 0 : rc === 0 ? 8 : 1;
        if (size <= 0)
          break $l$loop;
        tail = prepareWriteHead(destination, size, tail);
      }
    }finally {
      destination.z2d();
    }
    bytesWritten = bytesWritten + encodeCompleteImpl(_this__u8e3s4, destination) | 0;
    return bytesWritten;
  }
  function sizeEstimate(_this__u8e3s4) {
    var tmp;
    if (_this__u8e3s4 instanceof ByteReadPacket) {
      tmp = _this__u8e3s4.r2a();
    } else {
      // Inline function 'kotlin.comparisons.maxOf' call
      var a = _this__u8e3s4.r2a();
      var b = new Long(16, 0);
      tmp = a.c7(b) >= 0 ? a : b;
    }
    return tmp;
  }
  function encodeCompleteImpl(_this__u8e3s4, dst) {
    var size = 1;
    var bytesWritten = 0;
    // Inline function 'io.ktor.utils.io.core.writeWhile' call
    var tail = prepareWriteHead(dst, 1, null);
    try {
      $l$loop: while (true) {
        // Inline function 'io.ktor.utils.io.charsets.encodeCompleteImpl.<anonymous>' call
        var view = tail;
        // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
        var before = view.f29_1 - view.d29_1 | 0;
        if (encodeComplete(_this__u8e3s4, view)) {
          size = 0;
        } else {
          size = size + 1 | 0;
        }
        var tmp = bytesWritten;
        // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
        bytesWritten = tmp + (before - (view.f29_1 - view.d29_1 | 0) | 0) | 0;
        if (!(size > 0))
          break $l$loop;
        tail = prepareWriteHead(dst, 1, tail);
      }
    }finally {
      dst.z2d();
    }
    return bytesWritten;
  }
  function encode(_this__u8e3s4, input, fromIndex, toIndex) {
    fromIndex = fromIndex === VOID ? 0 : fromIndex;
    toIndex = toIndex === VOID ? charSequenceLength(input) : toIndex;
    var tmp$ret$0;
    $l$block: {
      // Inline function 'io.ktor.utils.io.core.buildPacket' call
      // Inline function 'kotlin.contracts.contract' call
      var builder = new BytePacketBuilder();
      try {
        // Inline function 'io.ktor.utils.io.charsets.encode.<anonymous>' call
        encodeToImpl(_this__u8e3s4, builder, input, fromIndex, toIndex);
        tmp$ret$0 = builder.f3();
        break $l$block;
      } catch ($p) {
        if ($p instanceof Error) {
          var t = $p;
          builder.qy();
          throw t;
        } else {
          throw $p;
        }
      }
    }
    return tmp$ret$0;
  }
  function Companion() {
    this.a2e_1 = 8;
  }
  protoOf(Companion).b2e = function () {
    return Companion_getInstance_4().q2c_1;
  };
  var Companion_instance;
  function Companion_getInstance_1() {
    return Companion_instance;
  }
  function Buffer(memory) {
    this.b29_1 = memory;
    this.c29_1 = 0;
    this.d29_1 = 0;
    this.e29_1 = 0;
    var tmp = this;
    // Inline function 'io.ktor.utils.io.bits.Memory.size32' call
    tmp.f29_1 = this.b29_1.c2e_1.byteLength;
    var tmp_0 = this;
    // Inline function 'io.ktor.utils.io.bits.Memory.size32' call
    tmp_0.g29_1 = this.b29_1.c2e_1.byteLength;
  }
  protoOf(Buffer).d2e = function (count) {
    if (count === 0)
      return Unit_instance;
    var newReadPosition = this.c29_1 + count | 0;
    if (count < 0 ? true : newReadPosition > this.d29_1) {
      // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
      var tmp$ret$1 = this.d29_1 - this.c29_1 | 0;
      discardFailed(count, tmp$ret$1);
    }
    this.c29_1 = newReadPosition;
  };
  protoOf(Buffer).e2e = function (count) {
    var newWritePosition = this.d29_1 + count | 0;
    if (count < 0 ? true : newWritePosition > this.f29_1) {
      // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
      var tmp$ret$0 = this.f29_1 - this.d29_1 | 0;
      commitWrittenFailed(count, tmp$ret$0);
    }
    this.d29_1 = newWritePosition;
  };
  protoOf(Buffer).f2e = function (position) {
    var limit = this.f29_1;
    if (position < this.d29_1) {
      var tmp = position - this.d29_1 | 0;
      // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
      var tmp$ret$0 = this.f29_1 - this.d29_1 | 0;
      commitWrittenFailed(tmp, tmp$ret$0);
    }
    if (position >= limit) {
      if (position === limit) {
        this.d29_1 = position;
        return false;
      }
      var tmp_0 = position - this.d29_1 | 0;
      // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
      var tmp$ret$1 = this.f29_1 - this.d29_1 | 0;
      commitWrittenFailed(tmp_0, tmp$ret$1);
    }
    this.d29_1 = position;
    return true;
  };
  protoOf(Buffer).g2e = function (position) {
    if (position < 0 ? true : position > this.d29_1) {
      var tmp = position - this.c29_1 | 0;
      // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
      var tmp$ret$0 = this.d29_1 - this.c29_1 | 0;
      discardFailed(tmp, tmp$ret$0);
    }
    if (!(this.c29_1 === position)) {
      this.c29_1 = position;
    }
  };
  protoOf(Buffer).h2e = function (count) {
    var newReadPosition = this.c29_1 - count | 0;
    if (newReadPosition < this.e29_1) {
      rewindFailed(count, this.c29_1 - this.e29_1 | 0);
    }
    this.c29_1 = newReadPosition;
  };
  protoOf(Buffer).i2e = function (startGap) {
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(startGap >= 0)) {
      // Inline function 'io.ktor.utils.io.core.Buffer.reserveStartGap.<anonymous>' call
      var message = "startGap shouldn't be negative: " + startGap;
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    if (this.c29_1 >= startGap) {
      this.e29_1 = startGap;
      return Unit_instance;
    }
    if (this.c29_1 === this.d29_1) {
      if (startGap > this.f29_1) {
        startGapReservationFailedDueToLimit(this, startGap);
      }
      this.d29_1 = startGap;
      this.c29_1 = startGap;
      this.e29_1 = startGap;
      return Unit_instance;
    }
    startGapReservationFailed(this, startGap);
  };
  protoOf(Buffer).j2e = function (endGap) {
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(endGap >= 0)) {
      // Inline function 'io.ktor.utils.io.core.Buffer.reserveEndGap.<anonymous>' call
      var message = "endGap shouldn't be negative: " + endGap;
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    var newLimit = this.g29_1 - endGap | 0;
    if (newLimit >= this.d29_1) {
      this.f29_1 = newLimit;
      return Unit_instance;
    }
    if (newLimit < 0) {
      endGapReservationFailedDueToCapacity(this, endGap);
    }
    if (newLimit < this.e29_1) {
      endGapReservationFailedDueToStartGap(this, endGap);
    }
    if (this.c29_1 === this.d29_1) {
      this.f29_1 = newLimit;
      this.c29_1 = newLimit;
      this.d29_1 = newLimit;
      return Unit_instance;
    }
    endGapReservationFailedDueToContent(this, endGap);
  };
  protoOf(Buffer).k2e = function () {
    this.e29_1 = 0;
    this.c29_1 = 0;
    var capacity = this.g29_1;
    this.d29_1 = capacity;
  };
  protoOf(Buffer).l2e = function () {
    this.m2e(this.g29_1 - this.e29_1 | 0);
  };
  protoOf(Buffer).m2e = function (limit) {
    var startGap = this.e29_1;
    this.c29_1 = startGap;
    this.d29_1 = startGap;
    this.f29_1 = limit;
  };
  protoOf(Buffer).n2e = function () {
    this.o2e(0);
    this.p2e();
  };
  protoOf(Buffer).p2e = function () {
    this.f29_1 = this.g29_1;
  };
  protoOf(Buffer).o2e = function (newReadPosition) {
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(newReadPosition >= 0)) {
      // Inline function 'io.ktor.utils.io.core.Buffer.releaseStartGap.<anonymous>' call
      var message = "newReadPosition shouldn't be negative: " + newReadPosition;
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(newReadPosition <= this.c29_1)) {
      // Inline function 'io.ktor.utils.io.core.Buffer.releaseStartGap.<anonymous>' call
      var message_0 = "newReadPosition shouldn't be ahead of the read position: " + newReadPosition + ' > ' + this.c29_1;
      throw IllegalArgumentException_init_$Create$(toString(message_0));
    }
    this.c29_1 = newReadPosition;
    if (this.e29_1 > newReadPosition) {
      this.e29_1 = newReadPosition;
    }
  };
  protoOf(Buffer).q2e = function (copy) {
    copy.f29_1 = this.f29_1;
    copy.e29_1 = this.e29_1;
    copy.c29_1 = this.c29_1;
    copy.d29_1 = this.d29_1;
  };
  protoOf(Buffer).r2e = function () {
    var readPosition = this.c29_1;
    if (readPosition === this.d29_1) {
      throw new EOFException('No readable bytes available.');
    }
    this.c29_1 = readPosition + 1 | 0;
    // Inline function 'io.ktor.utils.io.bits.get' call
    // Inline function 'io.ktor.utils.io.bits.Memory.loadAt' call
    return this.b29_1.c2e_1.getInt8(readPosition);
  };
  protoOf(Buffer).s2e = function (value) {
    var writePosition = this.d29_1;
    if (writePosition === this.f29_1) {
      throw new InsufficientSpaceException('No free space in the buffer to write a byte');
    }
    // Inline function 'io.ktor.utils.io.bits.set' call
    this.b29_1.c2e_1.setInt8(writePosition, value);
    this.d29_1 = writePosition + 1 | 0;
  };
  protoOf(Buffer).t2e = function () {
    this.n2e();
    this.l2e();
  };
  protoOf(Buffer).toString = function () {
    var tmp = 'Buffer[0x' + toString_0(hashCode(this), 16) + ']';
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    var tmp_0 = this.d29_1 - this.c29_1 | 0;
    // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
    var tmp_1 = this.f29_1 - this.d29_1 | 0;
    var tmp_2 = this.e29_1;
    // Inline function 'io.ktor.utils.io.core.Buffer.endGap' call
    return tmp + ('(' + tmp_0 + ' used, ' + tmp_1 + ' free, ' + (tmp_2 + (this.g29_1 - this.f29_1 | 0) | 0) + ' reserved of ' + this.g29_1 + ')');
  };
  function discardFailed(count, readRemaining) {
    throw new EOFException('Unable to discard ' + count + ' bytes: only ' + readRemaining + ' available for reading');
  }
  function commitWrittenFailed(count, writeRemaining) {
    throw new EOFException('Unable to discard ' + count + ' bytes: only ' + writeRemaining + ' available for writing');
  }
  function rewindFailed(count, rewindRemaining) {
    throw IllegalArgumentException_init_$Create$('Unable to rewind ' + count + ' bytes: only ' + rewindRemaining + ' could be rewinded');
  }
  function startGapReservationFailedDueToLimit(_this__u8e3s4, startGap) {
    if (startGap > _this__u8e3s4.g29_1) {
      throw IllegalArgumentException_init_$Create$('Start gap ' + startGap + ' is bigger than the capacity ' + _this__u8e3s4.g29_1);
    }
    // Inline function 'io.ktor.utils.io.core.Buffer.endGap' call
    var tmp$ret$0 = _this__u8e3s4.g29_1 - _this__u8e3s4.f29_1 | 0;
    throw IllegalStateException_init_$Create$('Unable to reserve ' + startGap + ' start gap: there are already ' + tmp$ret$0 + ' bytes reserved in the end');
  }
  function startGapReservationFailed(_this__u8e3s4, startGap) {
    var tmp = 'Unable to reserve ' + startGap + ' start gap: ';
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    var tmp$ret$0 = _this__u8e3s4.d29_1 - _this__u8e3s4.c29_1 | 0;
    throw IllegalStateException_init_$Create$(tmp + ('there are already ' + tmp$ret$0 + ' content bytes starting at offset ' + _this__u8e3s4.c29_1));
  }
  function endGapReservationFailedDueToCapacity(_this__u8e3s4, endGap) {
    throw IllegalArgumentException_init_$Create$('End gap ' + endGap + ' is too big: capacity is ' + _this__u8e3s4.g29_1);
  }
  function endGapReservationFailedDueToStartGap(_this__u8e3s4, endGap) {
    throw IllegalArgumentException_init_$Create$('End gap ' + endGap + ' is too big: there are already ' + _this__u8e3s4.e29_1 + ' bytes reserved in the beginning');
  }
  function endGapReservationFailedDueToContent(_this__u8e3s4, endGap) {
    var tmp = 'Unable to reserve end gap ' + endGap + ':';
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    var tmp$ret$0 = _this__u8e3s4.d29_1 - _this__u8e3s4.c29_1 | 0;
    throw IllegalArgumentException_init_$Create$(tmp + (' there are already ' + tmp$ret$0 + ' content bytes at offset ' + _this__u8e3s4.c29_1));
  }
  function InsufficientSpaceException_init_$Init$(name, size, availableSpace, $this) {
    InsufficientSpaceException.call($this, 'Not enough free space to write ' + name + ' of ' + size + ' bytes, available ' + availableSpace + ' bytes.');
    return $this;
  }
  function InsufficientSpaceException_init_$Create$(name, size, availableSpace) {
    var tmp = InsufficientSpaceException_init_$Init$(name, size, availableSpace, objectCreate(protoOf(InsufficientSpaceException)));
    captureStack(tmp, InsufficientSpaceException_init_$Create$);
    return tmp;
  }
  function InsufficientSpaceException(message) {
    message = message === VOID ? 'Not enough free space' : message;
    Exception_init_$Init$(message, this);
    captureStack(this, InsufficientSpaceException);
  }
  function restoreStartGap(_this__u8e3s4, size) {
    _this__u8e3s4.o2e(_this__u8e3s4.c29_1 - size | 0);
  }
  function writeBufferAppend(_this__u8e3s4, other, maxSize) {
    // Inline function 'kotlin.comparisons.minOf' call
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    var a = other.d29_1 - other.c29_1 | 0;
    var size = Math.min(a, maxSize);
    // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
    if ((_this__u8e3s4.f29_1 - _this__u8e3s4.d29_1 | 0) <= size) {
      writeBufferAppendUnreserve(_this__u8e3s4, size);
    }
    // Inline function 'io.ktor.utils.io.core.write' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.writeBufferAppend.<anonymous>' call
    var dst = _this__u8e3s4.b29_1;
    var dstOffset = _this__u8e3s4.d29_1;
    _this__u8e3s4.f29_1;
    // Inline function 'io.ktor.utils.io.core.read' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.writeBufferAppend.<anonymous>.<anonymous>' call
    var src = other.b29_1;
    var srcOffset = other.c29_1;
    other.d29_1;
    src.u2e(dst, srcOffset, size, dstOffset);
    var rc = size;
    other.d2e(rc);
    var rc_0 = rc;
    _this__u8e3s4.e2e(rc_0);
    return rc_0;
  }
  function writeBufferAppendUnreserve(_this__u8e3s4, writeSize) {
    // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
    var tmp = _this__u8e3s4.f29_1 - _this__u8e3s4.d29_1 | 0;
    // Inline function 'io.ktor.utils.io.core.Buffer.endGap' call
    if ((tmp + (_this__u8e3s4.g29_1 - _this__u8e3s4.f29_1 | 0) | 0) < writeSize) {
      throw IllegalArgumentException_init_$Create$("Can't append buffer: not enough free space at the end");
    }
    var newWritePosition = _this__u8e3s4.d29_1 + writeSize | 0;
    var overrunSize = newWritePosition - _this__u8e3s4.f29_1 | 0;
    if (overrunSize > 0) {
      _this__u8e3s4.p2e();
    }
  }
  function writeBufferPrepend(_this__u8e3s4, other) {
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    var size = other.d29_1 - other.c29_1 | 0;
    var readPosition = _this__u8e3s4.c29_1;
    if (readPosition < size) {
      throw IllegalArgumentException_init_$Create$('Not enough space in the beginning to prepend bytes');
    }
    var newReadPosition = readPosition - size | 0;
    other.b29_1.u2e(_this__u8e3s4.b29_1, other.c29_1, size, newReadPosition);
    other.d2e(size);
    _this__u8e3s4.o2e(newReadPosition);
    return size;
  }
  function get_DefaultChunkedBufferPool() {
    _init_properties_BufferFactory_kt__uj6b48();
    return DefaultChunkedBufferPool;
  }
  var DefaultChunkedBufferPool;
  function DefaultBufferPool(bufferSize, capacity, allocator) {
    bufferSize = bufferSize === VOID ? 4096 : bufferSize;
    capacity = capacity === VOID ? 1000 : capacity;
    allocator = allocator === VOID ? DefaultAllocator_instance : allocator;
    DefaultPool.call(this, capacity);
    this.y2e_1 = bufferSize;
    this.z2e_1 = allocator;
  }
  protoOf(DefaultBufferPool).a2f = function () {
    return new ChunkBuffer(this.z2e_1.b2f(this.y2e_1), null, this);
  };
  protoOf(DefaultBufferPool).c2f = function (instance) {
    this.z2e_1.d2f(instance.b29_1);
    protoOf(DefaultPool).h2f.call(this, instance);
    instance.s2f();
  };
  protoOf(DefaultBufferPool).h2f = function (instance) {
    return this.c2f(instance instanceof ChunkBuffer ? instance : THROW_CCE());
  };
  protoOf(DefaultBufferPool).t2f = function (instance) {
    protoOf(DefaultPool).u2f.call(this, instance);
    // Inline function 'kotlin.check' call
    // Inline function 'io.ktor.utils.io.bits.Memory.size' call
    var this_0 = instance.b29_1;
    // Inline function 'kotlin.contracts.contract' call
    if (!toLong(this_0.c2e_1.byteLength).equals(toLong(this.y2e_1))) {
      // Inline function 'io.ktor.utils.io.core.DefaultBufferPool.validateInstance.<anonymous>' call
      // Inline function 'io.ktor.utils.io.bits.Memory.size' call
      var this_1 = instance.b29_1;
      var tmp$ret$1 = toLong(this_1.c2e_1.byteLength);
      var message = 'Buffer size mismatch. Expected: ' + this.y2e_1 + ', actual: ' + tmp$ret$1.toString();
      throw IllegalStateException_init_$Create$(toString(message));
    }
    // Inline function 'kotlin.check' call
    // Inline function 'kotlin.contracts.contract' call
    if (!!(instance === Companion_getInstance_4().q2c_1)) {
      // Inline function 'io.ktor.utils.io.core.DefaultBufferPool.validateInstance.<anonymous>' call
      var message_0 = "ChunkBuffer.Empty couldn't be recycled";
      throw IllegalStateException_init_$Create$(toString(message_0));
    }
    // Inline function 'kotlin.check' call
    // Inline function 'kotlin.contracts.contract' call
    if (!!(instance === Companion_instance.b2e())) {
      // Inline function 'io.ktor.utils.io.core.DefaultBufferPool.validateInstance.<anonymous>' call
      var message_1 = "Empty instance couldn't be recycled";
      throw IllegalStateException_init_$Create$(toString(message_1));
    }
    // Inline function 'kotlin.check' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(instance.v2f() === 0)) {
      // Inline function 'io.ktor.utils.io.core.DefaultBufferPool.validateInstance.<anonymous>' call
      var message_2 = 'Unable to clear buffer: it is still in use.';
      throw IllegalStateException_init_$Create$(toString(message_2));
    }
    // Inline function 'kotlin.check' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(instance.t14() == null)) {
      // Inline function 'io.ktor.utils.io.core.DefaultBufferPool.validateInstance.<anonymous>' call
      var message_3 = "Recycled instance shouldn't be a part of a chain.";
      throw IllegalStateException_init_$Create$(toString(message_3));
    }
    // Inline function 'kotlin.check' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(instance.r2f_1 == null)) {
      // Inline function 'io.ktor.utils.io.core.DefaultBufferPool.validateInstance.<anonymous>' call
      var message_4 = "Recycled instance shouldn't be a view or another buffer.";
      throw IllegalStateException_init_$Create$(toString(message_4));
    }
  };
  protoOf(DefaultBufferPool).u2f = function (instance) {
    return this.t2f(instance instanceof ChunkBuffer ? instance : THROW_CCE());
  };
  protoOf(DefaultBufferPool).w2f = function (instance) {
    // Inline function 'kotlin.apply' call
    var this_0 = protoOf(DefaultPool).x2f.call(this, instance);
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.DefaultBufferPool.clearInstance.<anonymous>' call
    this_0.y2f();
    this_0.t2e();
    return this_0;
  };
  protoOf(DefaultBufferPool).x2f = function (instance) {
    return this.w2f(instance instanceof ChunkBuffer ? instance : THROW_CCE());
  };
  function get_DEFAULT_BUFFER_SIZE() {
    return DEFAULT_BUFFER_SIZE;
  }
  var DEFAULT_BUFFER_SIZE;
  var properties_initialized_BufferFactory_kt_q9tgbq;
  function _init_properties_BufferFactory_kt__uj6b48() {
    if (!properties_initialized_BufferFactory_kt_q9tgbq) {
      properties_initialized_BufferFactory_kt_q9tgbq = true;
      DefaultChunkedBufferPool = new DefaultBufferPool();
    }
  }
  function writeFully_0(_this__u8e3s4, source, offset, length) {
    offset = offset === VOID ? 0 : offset;
    length = length === VOID ? source.length - offset | 0 : length;
    // Inline function 'io.ktor.utils.io.core.writeExact' call
    var name = 'byte array';
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.write' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.writeExact.<anonymous>' call
    var memory = _this__u8e3s4.b29_1;
    var start = _this__u8e3s4.d29_1;
    var writeRemaining = _this__u8e3s4.f29_1 - start | 0;
    if (writeRemaining < length) {
      throw InsufficientSpaceException_init_$Create$(name, length, writeRemaining);
    }
    // Inline function 'io.ktor.utils.io.core.writeFully.<anonymous>' call
    // Inline function 'io.ktor.utils.io.bits.storeByteArray' call
    // Inline function 'io.ktor.utils.io.bits.useMemory' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'kotlin.let' call
    // Inline function 'kotlin.contracts.contract' call
    of(Companion_getInstance_6(), source, offset, length).u2e(memory, 0, length, start);
    var rc = length;
    _this__u8e3s4.e2e(rc);
  }
  function writeFully_1(_this__u8e3s4, src, length) {
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(length >= 0)) {
      // Inline function 'io.ktor.utils.io.core.writeFully.<anonymous>' call
      var message = "length shouldn't be negative: " + length;
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    // Inline function 'kotlin.require' call
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(length <= (src.d29_1 - src.c29_1 | 0))) {
      // Inline function 'io.ktor.utils.io.core.writeFully.<anonymous>' call
      // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
      var message_0 = "length shouldn't be greater than the source read remaining: " + length + ' > ' + (src.d29_1 - src.c29_1 | 0);
      throw IllegalArgumentException_init_$Create$(toString(message_0));
    }
    // Inline function 'kotlin.require' call
    // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(length <= (_this__u8e3s4.f29_1 - _this__u8e3s4.d29_1 | 0))) {
      // Inline function 'io.ktor.utils.io.core.writeFully.<anonymous>' call
      // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
      var message_1 = "length shouldn't be greater than the destination write remaining space: " + length + ' > ' + (_this__u8e3s4.f29_1 - _this__u8e3s4.d29_1 | 0);
      throw IllegalArgumentException_init_$Create$(toString(message_1));
    }
    // Inline function 'io.ktor.utils.io.core.writeExact' call
    var name = 'buffer readable content';
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.write' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.writeExact.<anonymous>' call
    var memory = _this__u8e3s4.b29_1;
    var start = _this__u8e3s4.d29_1;
    var writeRemaining = _this__u8e3s4.f29_1 - start | 0;
    if (writeRemaining < length) {
      throw InsufficientSpaceException_init_$Create$(name, length, writeRemaining);
    }
    // Inline function 'io.ktor.utils.io.core.writeFully.<anonymous>' call
    src.b29_1.u2e(memory, src.c29_1, length, start);
    src.d2e(length);
    var rc = length;
    _this__u8e3s4.e2e(rc);
  }
  function readFully(_this__u8e3s4, destination, offset, length) {
    offset = offset === VOID ? 0 : offset;
    length = length === VOID ? destination.length - offset | 0 : length;
    // Inline function 'io.ktor.utils.io.core.readExact' call
    var name = 'byte array';
    // Inline function 'kotlin.contracts.contract' call
    var value;
    // Inline function 'io.ktor.utils.io.core.read' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.readExact.<anonymous>' call
    var memory = _this__u8e3s4.b29_1;
    var start = _this__u8e3s4.c29_1;
    if ((_this__u8e3s4.d29_1 - start | 0) < length) {
      throw new EOFException('Not enough bytes to read a ' + name + ' of size ' + length + '.');
    }
    copyTo_1(memory, destination, start, length, offset);
    value = Unit_instance;
    var rc = length;
    _this__u8e3s4.d2e(rc);
  }
  function readFully_0(_this__u8e3s4, dst, length) {
    var tmp;
    if (length === VOID) {
      // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
      tmp = dst.f29_1 - dst.d29_1 | 0;
    } else {
      tmp = length;
    }
    length = tmp;
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(length >= 0)) {
      // Inline function 'kotlin.require.<anonymous>' call
      var message = 'Failed requirement.';
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    // Inline function 'kotlin.require' call
    // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(length <= (dst.f29_1 - dst.d29_1 | 0))) {
      // Inline function 'kotlin.require.<anonymous>' call
      var message_0 = 'Failed requirement.';
      throw IllegalArgumentException_init_$Create$(toString(message_0));
    }
    // Inline function 'io.ktor.utils.io.core.readExact' call
    var name = 'buffer content';
    // Inline function 'kotlin.contracts.contract' call
    var value;
    // Inline function 'io.ktor.utils.io.core.read' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.readExact.<anonymous>' call
    var memory = _this__u8e3s4.b29_1;
    var start = _this__u8e3s4.c29_1;
    if ((_this__u8e3s4.d29_1 - start | 0) < length) {
      throw new EOFException('Not enough bytes to read a ' + name + ' of size ' + length + '.');
    }
    memory.u2e(dst.b29_1, start, length, dst.d29_1);
    dst.e2e(length);
    value = Unit_instance;
    var rc = length;
    _this__u8e3s4.d2e(rc);
    return length;
  }
  function writeShort(_this__u8e3s4, value) {
    var name = 'short integer';
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.write' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.writeExact.<anonymous>' call
    var memory = _this__u8e3s4.b29_1;
    var start = _this__u8e3s4.d29_1;
    var writeRemaining = _this__u8e3s4.f29_1 - start | 0;
    if (writeRemaining < 2) {
      throw InsufficientSpaceException_init_$Create$(name, 2, writeRemaining);
    }
    // Inline function 'io.ktor.utils.io.core.writeShort.<anonymous>' call
    // Inline function 'io.ktor.utils.io.bits.storeShortAt' call
    memory.c2e_1.setInt16(start, value, false);
    var rc = 2;
    _this__u8e3s4.e2e(rc);
    return Unit_instance;
  }
  function readShort(_this__u8e3s4) {
    // Inline function 'io.ktor.utils.io.core.readExact' call
    var name = 'short integer';
    // Inline function 'kotlin.contracts.contract' call
    var value;
    // Inline function 'io.ktor.utils.io.core.read' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.readExact.<anonymous>' call
    var memory = _this__u8e3s4.b29_1;
    var start = _this__u8e3s4.c29_1;
    if ((_this__u8e3s4.d29_1 - start | 0) < 2) {
      throw new EOFException('Not enough bytes to read a ' + name + ' of size ' + 2 + '.');
    }
    // Inline function 'io.ktor.utils.io.core.readShort.<anonymous>' call
    // Inline function 'io.ktor.utils.io.bits.loadShortAt' call
    value = memory.c2e_1.getInt16(start, false);
    var rc = 2;
    _this__u8e3s4.d2e(rc);
    return value;
  }
  function remainingAll(_this__u8e3s4) {
    return remainingAll_0(_this__u8e3s4, new Long(0, 0));
  }
  function findTail(_this__u8e3s4) {
    var $this = _this__u8e3s4;
    $l$1: do {
      $l$0: do {
        var tmp0_elvis_lhs = $this.t14();
        var tmp;
        if (tmp0_elvis_lhs == null) {
          return $this;
        } else {
          tmp = tmp0_elvis_lhs;
        }
        var next = tmp;
        $this = next;
        continue $l$0;
      }
       while (false);
    }
     while (true);
  }
  function releaseAll(_this__u8e3s4, pool) {
    var current = _this__u8e3s4;
    while (!(current == null)) {
      var next = current.b2g();
      current.c2g(pool);
      current = next;
    }
  }
  function remainingAll_0(_this__u8e3s4, n) {
    var $this = _this__u8e3s4;
    var n_0 = n;
    $l$1: do {
      $l$0: do {
        // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
        var this_0 = $this;
        var tmp$ret$0 = this_0.d29_1 - this_0.c29_1 | 0;
        var rem = toLong(tmp$ret$0).lc(n_0);
        var tmp0_elvis_lhs = $this.t14();
        var tmp;
        if (tmp0_elvis_lhs == null) {
          return rem;
        } else {
          tmp = tmp0_elvis_lhs;
        }
        var next = tmp;
        $this = next;
        n_0 = rem;
        continue $l$0;
      }
       while (false);
    }
     while (true);
  }
  function BytePacketBuilder(pool) {
    pool = pool === VOID ? Companion_getInstance_4().t2c() : pool;
    Output.call(this, pool);
  }
  protoOf(BytePacketBuilder).u = function () {
    return this.d2g();
  };
  protoOf(BytePacketBuilder).t26 = function () {
    return this.d2g() === 0;
  };
  protoOf(BytePacketBuilder).e2g = function () {
  };
  protoOf(BytePacketBuilder).f2g = function (source, offset, length) {
  };
  protoOf(BytePacketBuilder).z5 = function (value) {
    var tmp = protoOf(Output).z5.call(this, value);
    return tmp instanceof BytePacketBuilder ? tmp : THROW_CCE();
  };
  protoOf(BytePacketBuilder).r8 = function (value) {
    var tmp = protoOf(Output).r8.call(this, value);
    return tmp instanceof BytePacketBuilder ? tmp : THROW_CCE();
  };
  protoOf(BytePacketBuilder).s8 = function (value, startIndex, endIndex) {
    var tmp = protoOf(Output).s8.call(this, value, startIndex, endIndex);
    return tmp instanceof BytePacketBuilder ? tmp : THROW_CCE();
  };
  protoOf(BytePacketBuilder).f3 = function () {
    var size = this.u();
    var head = this.c27();
    return head == null ? Companion_getInstance_2().g2g_1 : new ByteReadPacket(head, toLong(size), this.u26_1);
  };
  protoOf(BytePacketBuilder).toString = function () {
    return 'BytePacketBuilder[0x' + hashCode(this) + ']';
  };
  function ByteReadPacket_init_$Init$(head, pool, $this) {
    ByteReadPacket.call($this, head, remainingAll(head), pool);
    return $this;
  }
  function ByteReadPacket_init_$Create$(head, pool) {
    return ByteReadPacket_init_$Init$(head, pool, objectCreate(protoOf(ByteReadPacket)));
  }
  function Companion_0() {
    Companion_instance_0 = this;
    this.g2g_1 = new ByteReadPacket(Companion_getInstance_4().q2c_1, new Long(0, 0), Companion_getInstance_4().p2c_1);
  }
  var Companion_instance_0;
  function Companion_getInstance_2() {
    if (Companion_instance_0 == null)
      new Companion_0();
    return Companion_instance_0;
  }
  function ByteReadPacket(head, remaining, pool) {
    Companion_getInstance_2();
    Input.call(this, head, remaining, pool);
    this.m2g();
  }
  protoOf(ByteReadPacket).u2g = function () {
    return null;
  };
  protoOf(ByteReadPacket).v2g = function (destination, offset, length) {
    return 0;
  };
  protoOf(ByteReadPacket).toString = function () {
    return 'ByteReadPacket[' + hashCode(this) + ']';
  };
  function _set__head__b4pap2($this, newHead) {
    $this.l2a_1 = newHead;
    $this.m2a_1 = newHead.b29_1;
    $this.n2a_1 = newHead.c29_1;
    $this.o2a_1 = newHead.d29_1;
  }
  function readASCII($this, out, min, max) {
    if (max === 0 ? min === 0 : false)
      return 0;
    else if ($this.d2c())
      if (min === 0)
        return 0;
      else {
        atLeastMinCharactersRequire($this, min);
      }
     else if (max < min) {
      minShouldBeLess($this, min, max);
    }
    var copied = 0;
    var utf8 = false;
    $l$block: {
      // Inline function 'io.ktor.utils.io.core.takeWhile' call
      var release = true;
      var tmp0_elvis_lhs = prepareReadFirstHead($this, 1);
      var tmp;
      if (tmp0_elvis_lhs == null) {
        break $l$block;
      } else {
        tmp = tmp0_elvis_lhs;
      }
      var current = tmp;
      try {
        $l$loop_0: do {
          // Inline function 'io.ktor.utils.io.core.Input.readASCII.<anonymous>' call
          var buffer = current;
          var tmp$ret$4;
          $l$block_0: {
            // Inline function 'io.ktor.utils.io.core.internal.decodeASCII' call
            // Inline function 'io.ktor.utils.io.core.read' call
            // Inline function 'kotlin.contracts.contract' call
            // Inline function 'io.ktor.utils.io.core.internal.decodeASCII.<anonymous>' call
            var memory = buffer.b29_1;
            var start = buffer.c29_1;
            var endExclusive = buffer.d29_1;
            var inductionVariable = start;
            if (inductionVariable < endExclusive)
              do {
                var index = inductionVariable;
                inductionVariable = inductionVariable + 1 | 0;
                // Inline function 'io.ktor.utils.io.bits.get' call
                // Inline function 'io.ktor.utils.io.bits.Memory.loadAt' call
                var codepoint = memory.c2e_1.getInt8(index) & 255;
                var tmp_0;
                if ((codepoint & 128) === 128) {
                  tmp_0 = true;
                } else {
                  // Inline function 'io.ktor.utils.io.core.Input.readASCII.<anonymous>.<anonymous>' call
                  var it = numberToChar(codepoint);
                  var tmp_1;
                  if (copied === max) {
                    tmp_1 = false;
                  } else {
                    out.z5(it);
                    copied = copied + 1 | 0;
                    tmp_1 = true;
                  }
                  tmp_0 = !tmp_1;
                }
                if (tmp_0) {
                  buffer.d2e(index - start | 0);
                  tmp$ret$4 = false;
                  break $l$block_0;
                }
              }
               while (inductionVariable < endExclusive);
            var rc = endExclusive - start | 0;
            buffer.d2e(rc);
            tmp$ret$4 = true;
          }
          var rc_0 = tmp$ret$4;
          var tmp_2;
          if (rc_0) {
            tmp_2 = true;
          } else if (copied === max) {
            tmp_2 = false;
          } else {
            utf8 = true;
            tmp_2 = false;
          }
          if (!tmp_2) {
            break $l$loop_0;
          }
          release = false;
          var tmp1_elvis_lhs = prepareReadNextHead($this, current);
          var tmp_3;
          if (tmp1_elvis_lhs == null) {
            break $l$loop_0;
          } else {
            tmp_3 = tmp1_elvis_lhs;
          }
          var next = tmp_3;
          current = next;
          release = true;
        }
         while (true);
      }finally {
        if (release) {
          completeReadHead($this, current);
        }
      }
    }
    if (utf8) {
      return copied + readUtf8($this, out, min - copied | 0, max - copied | 0) | 0;
    }
    if (copied < min) {
      prematureEndOfStreamChars($this, min, copied);
    }
    return copied;
  }
  function atLeastMinCharactersRequire($this, min) {
    throw new EOFException('at least ' + min + ' characters required but no bytes available');
  }
  function minShouldBeLess($this, min, max) {
    throw IllegalArgumentException_init_$Create$('min should be less or equal to max but min = ' + min + ', max = ' + max);
  }
  function prematureEndOfStreamChars($this, min, copied) {
    throw new MalformedUTF8InputException('Premature end of stream: expected at least ' + min + ' chars but had only ' + copied);
  }
  function readUtf8($this, out, min, max) {
    var copied = 0;
    $l$block: {
      // Inline function 'io.ktor.utils.io.core.takeWhileSize' call
      var release = true;
      var tmp0_elvis_lhs = prepareReadFirstHead($this, 1);
      var tmp;
      if (tmp0_elvis_lhs == null) {
        break $l$block;
      } else {
        tmp = tmp0_elvis_lhs;
      }
      var current = tmp;
      var size = 1;
      try {
        $l$loop_0: do {
          // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
          var this_0 = current;
          var before = this_0.d29_1 - this_0.c29_1 | 0;
          var after;
          if (before >= size) {
            try {
              // Inline function 'io.ktor.utils.io.core.Input.readUtf8.<anonymous>' call
              var buffer = current;
              var tmp$ret$5;
              $l$block_3: {
                // Inline function 'io.ktor.utils.io.core.internal.decodeUTF8' call
                var byteCount = 0;
                var value = 0;
                var lastByteCount = 0;
                // Inline function 'io.ktor.utils.io.core.read' call
                // Inline function 'kotlin.contracts.contract' call
                // Inline function 'io.ktor.utils.io.core.internal.decodeUTF8.<anonymous>' call
                var memory = buffer.b29_1;
                var start = buffer.c29_1;
                var endExclusive = buffer.d29_1;
                var inductionVariable = start;
                if (inductionVariable < endExclusive)
                  do {
                    var index = inductionVariable;
                    inductionVariable = inductionVariable + 1 | 0;
                    // Inline function 'io.ktor.utils.io.bits.get' call
                    // Inline function 'io.ktor.utils.io.bits.Memory.loadAt' call
                    var v = memory.c2e_1.getInt8(index) & 255;
                    if ((v & 128) === 0) {
                      if (!(byteCount === 0)) {
                        malformedByteCount(byteCount);
                      }
                      // Inline function 'io.ktor.utils.io.core.Input.readUtf8.<anonymous>.<anonymous>' call
                      var it = numberToChar(v);
                      var tmp_0;
                      if (copied === max) {
                        tmp_0 = false;
                      } else {
                        out.z5(it);
                        copied = copied + 1 | 0;
                        tmp_0 = true;
                      }
                      if (!tmp_0) {
                        buffer.d2e(index - start | 0);
                        tmp$ret$5 = -1;
                        break $l$block_3;
                      }
                    } else if (byteCount === 0) {
                      var mask = 128;
                      value = v;
                      var inductionVariable_0 = 1;
                      if (inductionVariable_0 <= 6)
                        $l$loop: do {
                          var i = inductionVariable_0;
                          inductionVariable_0 = inductionVariable_0 + 1 | 0;
                          if (!((value & mask) === 0)) {
                            value = value & ~mask;
                            mask = mask >> 1;
                            byteCount = byteCount + 1 | 0;
                          } else {
                            break $l$loop;
                          }
                        }
                         while (inductionVariable_0 <= 6);
                      lastByteCount = byteCount;
                      byteCount = byteCount - 1 | 0;
                      if (lastByteCount > (endExclusive - index | 0)) {
                        buffer.d2e(index - start | 0);
                        tmp$ret$5 = lastByteCount;
                        break $l$block_3;
                      }
                    } else {
                      value = value << 6 | v & 127;
                      byteCount = byteCount - 1 | 0;
                      if (byteCount === 0) {
                        if (isBmpCodePoint(value)) {
                          // Inline function 'io.ktor.utils.io.core.Input.readUtf8.<anonymous>.<anonymous>' call
                          var it_0 = numberToChar(value);
                          var tmp_1;
                          if (copied === max) {
                            tmp_1 = false;
                          } else {
                            out.z5(it_0);
                            copied = copied + 1 | 0;
                            tmp_1 = true;
                          }
                          if (!tmp_1) {
                            buffer.d2e(((index - start | 0) - lastByteCount | 0) + 1 | 0);
                            tmp$ret$5 = -1;
                            break $l$block_3;
                          }
                        } else if (!isValidCodePoint(value)) {
                          malformedCodePoint(value);
                        } else {
                          var tmp_2;
                          // Inline function 'io.ktor.utils.io.core.Input.readUtf8.<anonymous>.<anonymous>' call
                          var it_1 = numberToChar(highSurrogate(value));
                          var tmp_3;
                          if (copied === max) {
                            tmp_3 = false;
                          } else {
                            out.z5(it_1);
                            copied = copied + 1 | 0;
                            tmp_3 = true;
                          }
                          if (!tmp_3) {
                            tmp_2 = true;
                          } else {
                            // Inline function 'io.ktor.utils.io.core.Input.readUtf8.<anonymous>.<anonymous>' call
                            var it_2 = numberToChar(lowSurrogate(value));
                            var tmp_4;
                            if (copied === max) {
                              tmp_4 = false;
                            } else {
                              out.z5(it_2);
                              copied = copied + 1 | 0;
                              tmp_4 = true;
                            }
                            tmp_2 = !tmp_4;
                          }
                          if (tmp_2) {
                            buffer.d2e(((index - start | 0) - lastByteCount | 0) + 1 | 0);
                            tmp$ret$5 = -1;
                            break $l$block_3;
                          }
                        }
                        value = 0;
                      }
                    }
                  }
                   while (inductionVariable < endExclusive);
                var rc = endExclusive - start | 0;
                buffer.d2e(rc);
                tmp$ret$5 = 0;
              }
              var size_0 = tmp$ret$5;
              size = size_0 === 0 ? 1 : size_0 > 0 ? size_0 : 0;
            }finally {
              // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
              var this_1 = current;
              after = this_1.d29_1 - this_1.c29_1 | 0;
            }
          } else {
            after = before;
          }
          release = false;
          var tmp_5;
          if (after === 0) {
            tmp_5 = prepareReadNextHead($this, current);
          } else {
            var tmp_6;
            if (after < size) {
              tmp_6 = true;
            } else {
              // Inline function 'io.ktor.utils.io.core.Buffer.endGap' call
              var this_2 = current;
              var tmp_7 = this_2.g29_1 - this_2.f29_1 | 0;
              tmp_6 = tmp_7 < 8;
            }
            if (tmp_6) {
              completeReadHead($this, current);
              tmp_5 = prepareReadFirstHead($this, size);
            } else {
              tmp_5 = current;
            }
          }
          var tmp1_elvis_lhs = tmp_5;
          var tmp_8;
          if (tmp1_elvis_lhs == null) {
            break $l$loop_0;
          } else {
            tmp_8 = tmp1_elvis_lhs;
          }
          var next = tmp_8;
          current = next;
          release = true;
        }
         while (size > 0);
      }finally {
        if (release) {
          completeReadHead($this, current);
        }
      }
    }
    if (copied < min) {
      prematureEndOfStreamChars($this, min, copied);
    }
    return copied;
  }
  function discardAsMuchAsPossible($this, n, skipped) {
    var $this_0 = $this;
    var n_0 = n;
    var skipped_0 = skipped;
    $l$1: do {
      $l$0: do {
        if (n_0.equals(new Long(0, 0)))
          return skipped_0;
        var tmp0_elvis_lhs = $this_0.i2h(1);
        var tmp;
        if (tmp0_elvis_lhs == null) {
          return skipped_0;
        } else {
          tmp = tmp0_elvis_lhs;
        }
        var current = tmp;
        // Inline function 'kotlin.comparisons.minOf' call
        // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
        var tmp$ret$0 = current.d29_1 - current.c29_1 | 0;
        var a = toLong(tmp$ret$0);
        var b = n_0;
        var size = (a.c7(b) <= 0 ? a : b).mb();
        current.d2e(size);
        var tmp1_this = $this_0;
        tmp1_this.n2a_1 = tmp1_this.n2a_1 + size | 0;
        afterRead($this_0, current);
        // Inline function 'kotlin.Long.minus' call
        // Inline function 'kotlin.Long.plus' call
        $this_0 = $this_0;
        n_0 = n_0.mc(toLong(size));
        skipped_0 = skipped_0.lc(toLong(size));
        continue $l$0;
      }
       while (false);
    }
     while (true);
  }
  function discardAsMuchAsPossible_0($this, n, skipped) {
    var currentCount = n;
    var currentSkipped = skipped;
    while (true) {
      if (currentCount === 0) {
        return currentSkipped;
      }
      var tmp0_elvis_lhs = $this.i2h(1);
      var tmp;
      if (tmp0_elvis_lhs == null) {
        return currentSkipped;
      } else {
        tmp = tmp0_elvis_lhs;
      }
      var current = tmp;
      // Inline function 'kotlin.comparisons.minOf' call
      // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
      var a = current.d29_1 - current.c29_1 | 0;
      var b = currentCount;
      var size = Math.min(a, b);
      current.d2e(size);
      $this.n2a_1 = $this.n2a_1 + size | 0;
      afterRead($this, current);
      currentCount = currentCount - size | 0;
      currentSkipped = currentSkipped + size | 0;
    }
  }
  function fixGapAfterReadFallback($this, current) {
    if ($this.q2a_1 ? current.t14() == null : false) {
      $this.n2a_1 = current.c29_1;
      $this.o2a_1 = current.d29_1;
      $this.w2g(new Long(0, 0));
      return Unit_instance;
    }
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    var size = current.d29_1 - current.c29_1 | 0;
    // Inline function 'kotlin.comparisons.minOf' call
    // Inline function 'io.ktor.utils.io.core.Buffer.endGap' call
    var b = 8 - (current.g29_1 - current.f29_1 | 0) | 0;
    var overrun = Math.min(size, b);
    if (size > overrun) {
      fixGapAfterReadFallbackUnreserved($this, current, size, overrun);
    } else {
      var new_0 = $this.k2a_1.z2f();
      new_0.j2e(8);
      new_0.k2h(current.b2g());
      writeBufferAppend(new_0, current, size);
      _set__head__b4pap2($this, new_0);
    }
    current.c2g($this.k2a_1);
  }
  function fixGapAfterReadFallbackUnreserved($this, current, size, overrun) {
    var chunk1 = $this.k2a_1.z2f();
    var chunk2 = $this.k2a_1.z2f();
    chunk1.j2e(8);
    chunk2.j2e(8);
    chunk1.k2h(chunk2);
    chunk2.k2h(current.b2g());
    writeBufferAppend(chunk1, current, size - overrun | 0);
    writeBufferAppend(chunk2, current, overrun);
    _set__head__b4pap2($this, chunk1);
    $this.w2g(remainingAll(chunk2));
  }
  function ensureNext($this, current, empty) {
    var $this_0 = $this;
    var current_0 = current;
    var empty_0 = empty;
    $l$1: do {
      $l$0: do {
        if (current_0 === empty_0) {
          return doFill($this_0);
        }
        var next = current_0.b2g();
        current_0.c2g($this_0.k2a_1);
        var tmp;
        if (next == null) {
          _set__head__b4pap2($this_0, empty_0);
          $this_0.w2g(new Long(0, 0));
          $this_0 = $this_0;
          current_0 = empty_0;
          empty_0 = empty_0;
          continue $l$0;
        } else {
          // Inline function 'io.ktor.utils.io.core.canRead' call
          if (next.d29_1 > next.c29_1) {
            _set__head__b4pap2($this_0, next);
            var tmp0_this = $this_0;
            // Inline function 'kotlin.Long.minus' call
            var this_0 = tmp0_this.p2a_1;
            // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
            var other = next.d29_1 - next.c29_1 | 0;
            var tmp$ret$2 = this_0.mc(toLong(other));
            tmp0_this.w2g(tmp$ret$2);
            tmp = next;
          } else {
            $this_0 = $this_0;
            current_0 = next;
            empty_0 = empty_0;
            continue $l$0;
          }
        }
        return tmp;
      }
       while (false);
    }
     while (true);
  }
  function doFill($this) {
    if ($this.q2a_1)
      return null;
    var chunk = $this.u2g();
    if (chunk == null) {
      $this.q2a_1 = true;
      return null;
    }
    appendView($this, chunk);
    return chunk;
  }
  function appendView($this, chunk) {
    var tail = findTail($this.l2a_1);
    if (tail === Companion_getInstance_4().q2c_1) {
      _set__head__b4pap2($this, chunk);
      // Inline function 'kotlin.require' call
      // Inline function 'kotlin.contracts.contract' call
      if (!$this.p2a_1.equals(new Long(0, 0))) {
        throw IllegalStateException_init_$Create$('It should be no tail remaining bytes if current tail is EmptyBuffer');
      }
      var tmp0_safe_receiver = chunk.t14();
      var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : remainingAll(tmp0_safe_receiver);
      $this.w2g(tmp1_elvis_lhs == null ? new Long(0, 0) : tmp1_elvis_lhs);
    } else {
      tail.k2h(chunk);
      $this.w2g($this.p2a_1.lc(remainingAll(chunk)));
    }
  }
  function prepareReadLoop($this, minSize, head) {
    var $this_0 = $this;
    var minSize_0 = minSize;
    var head_0 = head;
    $l$1: do {
      $l$0: do {
        // Inline function 'io.ktor.utils.io.core.Input.headRemaining' call
        var this_0 = $this_0;
        var headSize = this_0.o2a_1 - this_0.n2a_1 | 0;
        if (headSize >= minSize_0)
          return head_0;
        var tmp0_elvis_lhs = head_0.t14();
        var tmp1_elvis_lhs = tmp0_elvis_lhs == null ? doFill($this_0) : tmp0_elvis_lhs;
        var tmp;
        if (tmp1_elvis_lhs == null) {
          return null;
        } else {
          tmp = tmp1_elvis_lhs;
        }
        var next = tmp;
        if (headSize === 0) {
          if (!(head_0 === Companion_getInstance_4().q2c_1)) {
            $this_0.j2h(head_0);
          }
          $this_0 = $this_0;
          minSize_0 = minSize_0;
          head_0 = next;
          continue $l$0;
        } else {
          var desiredExtraBytes = minSize_0 - headSize | 0;
          var copied = writeBufferAppend(head_0, next, desiredExtraBytes);
          $this_0.o2a_1 = head_0.d29_1;
          var tmp2_this = $this_0;
          // Inline function 'kotlin.Long.minus' call
          var tmp$ret$1 = tmp2_this.p2a_1.mc(toLong(copied));
          tmp2_this.w2g(tmp$ret$1);
          // Inline function 'io.ktor.utils.io.core.canRead' call
          if (!(next.d29_1 > next.c29_1)) {
            head_0.k2h(null);
            head_0.k2h(next.b2g());
            next.c2g($this_0.k2a_1);
          } else {
            next.i2e(copied);
          }
        }
        // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
        var this_1 = head_0;
        if ((this_1.d29_1 - this_1.c29_1 | 0) >= minSize_0)
          return head_0;
        var tmp_0 = minSize_0;
        if (tmp_0 > 8) {
          minSizeIsTooBig($this_0, minSize_0);
        }
        $this_0 = $this_0;
        minSize_0 = minSize_0;
        head_0 = head_0;
        continue $l$0;
      }
       while (false);
    }
     while (true);
  }
  function minSizeIsTooBig($this, minSize) {
    throw IllegalStateException_init_$Create$('minSize of ' + minSize + ' is too big (should be less than ' + 8 + ')');
  }
  function afterRead($this, head) {
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    if ((head.d29_1 - head.c29_1 | 0) === 0) {
      $this.j2h(head);
    }
  }
  function Companion_1() {
  }
  var Companion_instance_1;
  function Companion_getInstance_3() {
    return Companion_instance_1;
  }
  function Input(head, remaining, pool) {
    head = head === VOID ? Companion_getInstance_4().q2c_1 : head;
    remaining = remaining === VOID ? remainingAll(head) : remaining;
    pool = pool === VOID ? Companion_getInstance_4().t2c() : pool;
    this.k2a_1 = pool;
    this.l2a_1 = head;
    this.m2a_1 = head.b29_1;
    this.n2a_1 = head.c29_1;
    this.o2a_1 = head.d29_1;
    var tmp = this;
    // Inline function 'kotlin.Long.minus' call
    var other = this.o2a_1 - this.n2a_1 | 0;
    tmp.p2a_1 = remaining.mc(toLong(other));
    this.q2a_1 = false;
  }
  protoOf(Input).d2c = function () {
    var tmp;
    var tmp_0;
    // Inline function 'io.ktor.utils.io.core.Input.headRemaining' call
    if ((this.o2a_1 - this.n2a_1 | 0) === 0) {
      tmp_0 = this.p2a_1.equals(new Long(0, 0));
    } else {
      tmp_0 = false;
    }
    if (tmp_0) {
      tmp = this.q2a_1 ? true : doFill(this) == null;
    } else {
      tmp = false;
    }
    return tmp;
  };
  protoOf(Input).h2g = function () {
    // Inline function 'kotlin.also' call
    var this_0 = this.l2a_1;
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.Input.<get-head>.<anonymous>' call
    this_0.g2e(this.n2a_1);
    return this_0;
  };
  protoOf(Input).w2g = function (newValue) {
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(newValue.c7(new Long(0, 0)) >= 0)) {
      // Inline function 'io.ktor.utils.io.core.Input.<set-tailRemaining>.<anonymous>' call
      var message = "tailRemaining shouldn't be negative: " + newValue.toString();
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    this.p2a_1 = newValue;
  };
  protoOf(Input).r2a = function () {
    // Inline function 'io.ktor.utils.io.core.Input.headRemaining' call
    var tmp$ret$0 = this.o2a_1 - this.n2a_1 | 0;
    return toLong(tmp$ret$0).lc(this.p2a_1);
  };
  protoOf(Input).g2b = function () {
    return !(this.n2a_1 === this.o2a_1) ? true : !this.p2a_1.equals(new Long(0, 0));
  };
  protoOf(Input).qy = function () {
    var head = this.h2g();
    var empty = Companion_getInstance_4().q2c_1;
    if (!(head === empty)) {
      _set__head__b4pap2(this, empty);
      this.w2g(new Long(0, 0));
      releaseAll(head, this.k2a_1);
    }
  };
  protoOf(Input).c27 = function () {
    var head = this.h2g();
    var empty = Companion_getInstance_4().q2c_1;
    if (head === empty)
      return null;
    _set__head__b4pap2(this, empty);
    this.w2g(new Long(0, 0));
    return head;
  };
  protoOf(Input).x2g = function () {
    var head = this.h2g();
    var next = head.t14();
    var empty = Companion_getInstance_4().q2c_1;
    if (head === empty)
      return null;
    if (next == null) {
      _set__head__b4pap2(this, empty);
      this.w2g(new Long(0, 0));
    } else {
      _set__head__b4pap2(this, next);
      // Inline function 'kotlin.Long.minus' call
      var this_0 = this.p2a_1;
      // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
      var other = next.d29_1 - next.c29_1 | 0;
      var tmp$ret$1 = this_0.mc(toLong(other));
      this.w2g(tmp$ret$1);
    }
    head.k2h(null);
    return head;
  };
  protoOf(Input).y2g = function (chain) {
    if (chain === Companion_getInstance_4().q2c_1)
      return Unit_instance;
    var size = remainingAll(chain);
    if (this.l2a_1 === Companion_getInstance_4().q2c_1) {
      _set__head__b4pap2(this, chain);
      // Inline function 'kotlin.Long.minus' call
      // Inline function 'io.ktor.utils.io.core.Input.headRemaining' call
      var other = this.o2a_1 - this.n2a_1 | 0;
      var tmp$ret$1 = size.mc(toLong(other));
      this.w2g(tmp$ret$1);
    } else {
      findTail(this.l2a_1).k2h(chain);
      this.w2g(this.p2a_1.lc(size));
    }
  };
  protoOf(Input).z2g = function (chain) {
    var tail = findTail(this.h2g());
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    var size = chain.d29_1 - chain.c29_1 | 0;
    var tmp;
    if (size === 0) {
      tmp = true;
    } else {
      // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
      tmp = (tail.f29_1 - tail.d29_1 | 0) < size;
    }
    if (tmp)
      return false;
    writeBufferAppend(tail, chain, size);
    if (this.h2g() === tail) {
      this.o2a_1 = tail.d29_1;
    } else {
      // Inline function 'kotlin.Long.plus' call
      var tmp$ret$2 = this.p2a_1.lc(toLong(size));
      this.w2g(tmp$ret$2);
    }
    return true;
  };
  protoOf(Input).a2h = function (n) {
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(n >= 0)) {
      // Inline function 'io.ktor.utils.io.core.Input.discard.<anonymous>' call
      var message = 'Negative discard is not allowed: ' + n;
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    return discardAsMuchAsPossible_0(this, n, 0);
  };
  protoOf(Input).d2e = function (n) {
    if (!(this.a2h(n) === n))
      throw new EOFException('Unable to discard ' + n + ' bytes due to end of packet');
  };
  protoOf(Input).b2h = function (n) {
    if (n.c7(new Long(0, 0)) <= 0)
      return new Long(0, 0);
    return discardAsMuchAsPossible(this, n, new Long(0, 0));
  };
  protoOf(Input).c2h = function (min, max) {
    if (min === 0 ? max === 0 ? true : this.d2c() : false)
      return '';
    var remaining = this.r2a();
    if (remaining.c7(new Long(0, 0)) > 0 ? toLong(max).c7(remaining) >= 0 : false)
      return readTextExactBytes(this, remaining.mb());
    // Inline function 'kotlin.text.buildString' call
    var capacity = coerceAtMost(coerceAtLeast(min, 16), max);
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'kotlin.apply' call
    var this_0 = StringBuilder_init_$Create$(capacity);
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.Input.readText.<anonymous>' call
    readASCII(this, this_0, min, max);
    return this_0.toString();
  };
  protoOf(Input).d2h = function (min, max, $super) {
    min = min === VOID ? 0 : min;
    max = max === VOID ? IntCompanionObject_instance.MAX_VALUE : max;
    return $super === VOID ? this.c2h(min, max) : $super.c2h.call(this, min, max);
  };
  protoOf(Input).e2h = function (minSize) {
    return prepareReadLoop(this, minSize, this.h2g());
  };
  protoOf(Input).f2h = function (current) {
    return this.g2h(current);
  };
  protoOf(Input).g2h = function (current) {
    return ensureNext(this, current, Companion_getInstance_4().q2c_1);
  };
  protoOf(Input).h2h = function (current) {
    var tmp0_elvis_lhs = current.t14();
    var tmp;
    if (tmp0_elvis_lhs == null) {
      return fixGapAfterReadFallback(this, current);
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var next = tmp;
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    var remaining = current.d29_1 - current.c29_1 | 0;
    // Inline function 'kotlin.comparisons.minOf' call
    // Inline function 'io.ktor.utils.io.core.Buffer.endGap' call
    var b = 8 - (current.g29_1 - current.f29_1 | 0) | 0;
    var overrunSize = Math.min(remaining, b);
    if (next.e29_1 < overrunSize) {
      return fixGapAfterReadFallback(this, current);
    }
    restoreStartGap(next, overrunSize);
    if (remaining > overrunSize) {
      current.p2e();
      this.o2a_1 = current.d29_1;
      // Inline function 'kotlin.Long.plus' call
      var tmp$ret$3 = this.p2a_1.lc(toLong(overrunSize));
      this.w2g(tmp$ret$3);
    } else {
      _set__head__b4pap2(this, next);
      // Inline function 'kotlin.Long.minus' call
      var this_0 = this.p2a_1;
      // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
      var other = (next.d29_1 - next.c29_1 | 0) - overrunSize | 0;
      var tmp$ret$5 = this_0.mc(toLong(other));
      this.w2g(tmp$ret$5);
      current.b2g();
      current.c2g(this.k2a_1);
    }
  };
  protoOf(Input).u2g = function () {
    var buffer = this.k2a_1.z2f();
    try {
      buffer.j2e(8);
      var tmp = buffer.d29_1;
      // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
      var tmp$ret$0 = buffer.f29_1 - buffer.d29_1 | 0;
      var copied = this.v2g(buffer.b29_1, tmp, tmp$ret$0);
      if (copied === 0) {
        this.q2a_1 = true;
        // Inline function 'io.ktor.utils.io.core.canRead' call
        if (!(buffer.d29_1 > buffer.c29_1)) {
          buffer.c2g(this.k2a_1);
          return null;
        }
      }
      buffer.e2e(copied);
      return buffer;
    } catch ($p) {
      if ($p instanceof Error) {
        var t = $p;
        buffer.c2g(this.k2a_1);
        throw t;
      } else {
        throw $p;
      }
    }
  };
  protoOf(Input).m2g = function () {
    if (!this.q2a_1) {
      this.q2a_1 = true;
    }
  };
  protoOf(Input).i2h = function (minSize) {
    var head = this.h2g();
    if ((this.o2a_1 - this.n2a_1 | 0) >= minSize)
      return head;
    return prepareReadLoop(this, minSize, head);
  };
  protoOf(Input).j2h = function (head) {
    var tmp0_elvis_lhs = head.b2g();
    var next = tmp0_elvis_lhs == null ? Companion_getInstance_4().q2c_1 : tmp0_elvis_lhs;
    _set__head__b4pap2(this, next);
    // Inline function 'kotlin.Long.minus' call
    var this_0 = this.p2a_1;
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    var other = next.d29_1 - next.c29_1 | 0;
    var tmp$ret$1 = this_0.mc(toLong(other));
    this.w2g(tmp$ret$1);
    head.c2g(this.k2a_1);
    return next;
  };
  function discard(_this__u8e3s4) {
    Companion_getInstance();
    return _this__u8e3s4.b2h(new Long(-1, 2147483647));
  }
  function readFully_1(_this__u8e3s4, dst, offset, length) {
    offset = offset === VOID ? 0 : offset;
    length = length === VOID ? dst.length - offset | 0 : length;
    // Inline function 'io.ktor.utils.io.core.requireNoRemaining' call
    // Inline function 'io.ktor.utils.io.core.readFullyBytesTemplate' call
    var remaining = length;
    var dstOffset = offset;
    $l$block: {
      // Inline function 'io.ktor.utils.io.core.takeWhile' call
      var release = true;
      var tmp0_elvis_lhs = prepareReadFirstHead(_this__u8e3s4, 1);
      var tmp;
      if (tmp0_elvis_lhs == null) {
        break $l$block;
      } else {
        tmp = tmp0_elvis_lhs;
      }
      var current = tmp;
      try {
        $l$loop_0: do {
          // Inline function 'io.ktor.utils.io.core.readFullyBytesTemplate.<anonymous>' call
          var buffer = current;
          // Inline function 'kotlin.comparisons.minOf' call
          var a = remaining;
          // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
          var b = buffer.d29_1 - buffer.c29_1 | 0;
          var count = Math.min(a, b);
          // Inline function 'io.ktor.utils.io.core.readFully.<anonymous>' call
          var dstOffset_0 = dstOffset;
          readFully(buffer, dst, dstOffset_0, count);
          remaining = remaining - count | 0;
          dstOffset = dstOffset + count | 0;
          if (!(remaining > 0)) {
            break $l$loop_0;
          }
          release = false;
          var tmp1_elvis_lhs = prepareReadNextHead(_this__u8e3s4, current);
          var tmp_0;
          if (tmp1_elvis_lhs == null) {
            break $l$loop_0;
          } else {
            tmp_0 = tmp1_elvis_lhs;
          }
          var next = tmp_0;
          current = next;
          release = true;
        }
         while (true);
      }finally {
        if (release) {
          completeReadHead(_this__u8e3s4, current);
        }
      }
    }
    var this_0 = remaining;
    if (this_0 > 0) {
      prematureEndOfStream(this_0);
    }
  }
  function readFully_2(_this__u8e3s4, dst, length) {
    var tmp;
    if (length === VOID) {
      // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
      tmp = dst.f29_1 - dst.d29_1 | 0;
    } else {
      tmp = length;
    }
    length = tmp;
    // Inline function 'io.ktor.utils.io.core.requireNoRemaining' call
    // Inline function 'io.ktor.utils.io.core.readFullyBytesTemplate' call
    var remaining = length;
    var dstOffset = 0;
    $l$block: {
      // Inline function 'io.ktor.utils.io.core.takeWhile' call
      var release = true;
      var tmp0_elvis_lhs = prepareReadFirstHead(_this__u8e3s4, 1);
      var tmp_0;
      if (tmp0_elvis_lhs == null) {
        break $l$block;
      } else {
        tmp_0 = tmp0_elvis_lhs;
      }
      var current = tmp_0;
      try {
        $l$loop_0: do {
          // Inline function 'io.ktor.utils.io.core.readFullyBytesTemplate.<anonymous>' call
          var buffer = current;
          // Inline function 'kotlin.comparisons.minOf' call
          var a = remaining;
          // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
          var b = buffer.d29_1 - buffer.c29_1 | 0;
          var count = Math.min(a, b);
          // Inline function 'io.ktor.utils.io.core.readFully.<anonymous>' call
          readFully_0(buffer, dst, count);
          remaining = remaining - count | 0;
          dstOffset = dstOffset + count | 0;
          if (!(remaining > 0)) {
            break $l$loop_0;
          }
          release = false;
          var tmp1_elvis_lhs = prepareReadNextHead(_this__u8e3s4, current);
          var tmp_1;
          if (tmp1_elvis_lhs == null) {
            break $l$loop_0;
          } else {
            tmp_1 = tmp1_elvis_lhs;
          }
          var next = tmp_1;
          current = next;
          release = true;
        }
         while (true);
      }finally {
        if (release) {
          completeReadHead(_this__u8e3s4, current);
        }
      }
    }
    var this_0 = remaining;
    if (this_0 > 0) {
      prematureEndOfStream(this_0);
    }
  }
  function readAvailable_0(_this__u8e3s4, dst, offset, length) {
    offset = offset === VOID ? 0 : offset;
    length = length === VOID ? dst.length - offset | 0 : length;
    // Inline function 'io.ktor.utils.io.core.readFullyBytesTemplate' call
    var remaining = length;
    var dstOffset = offset;
    $l$block: {
      // Inline function 'io.ktor.utils.io.core.takeWhile' call
      var release = true;
      var tmp0_elvis_lhs = prepareReadFirstHead(_this__u8e3s4, 1);
      var tmp;
      if (tmp0_elvis_lhs == null) {
        break $l$block;
      } else {
        tmp = tmp0_elvis_lhs;
      }
      var current = tmp;
      try {
        $l$loop_0: do {
          // Inline function 'io.ktor.utils.io.core.readFullyBytesTemplate.<anonymous>' call
          var buffer = current;
          // Inline function 'kotlin.comparisons.minOf' call
          var a = remaining;
          // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
          var b = buffer.d29_1 - buffer.c29_1 | 0;
          var count = Math.min(a, b);
          // Inline function 'io.ktor.utils.io.core.readAvailable.<anonymous>' call
          var dstOffset_0 = dstOffset;
          readFully(buffer, dst, dstOffset_0, count);
          remaining = remaining - count | 0;
          dstOffset = dstOffset + count | 0;
          if (!(remaining > 0)) {
            break $l$loop_0;
          }
          release = false;
          var tmp1_elvis_lhs = prepareReadNextHead(_this__u8e3s4, current);
          var tmp_0;
          if (tmp1_elvis_lhs == null) {
            break $l$loop_0;
          } else {
            tmp_0 = tmp1_elvis_lhs;
          }
          var next = tmp_0;
          current = next;
          release = true;
        }
         while (true);
      }finally {
        if (release) {
          completeReadHead(_this__u8e3s4, current);
        }
      }
    }
    return length - remaining | 0;
  }
  function readShort_0(_this__u8e3s4) {
    var tmp$ret$3;
    $l$block: {
      // Inline function 'io.ktor.utils.io.core.readPrimitive' call
      // Inline function 'io.ktor.utils.io.core.Input.headRemaining' call
      if ((_this__u8e3s4.o2a_1 - _this__u8e3s4.n2a_1 | 0) > 2) {
        var index = _this__u8e3s4.n2a_1;
        _this__u8e3s4.n2a_1 = index + 2 | 0;
        // Inline function 'io.ktor.utils.io.core.readShort.<anonymous>' call
        // Inline function 'io.ktor.utils.io.bits.loadShortAt' call
        tmp$ret$3 = _this__u8e3s4.m2a_1.c2e_1.getInt16(index, false);
        break $l$block;
      }
      // Inline function 'io.ktor.utils.io.core.readShort.<anonymous>' call
      tmp$ret$3 = readShortFallback(_this__u8e3s4);
    }
    return tmp$ret$3;
  }
  function readShortFallback(_this__u8e3s4) {
    // Inline function 'io.ktor.utils.io.core.readPrimitiveFallback' call
    var tmp0_elvis_lhs = prepareReadFirstHead(_this__u8e3s4, 2);
    var tmp;
    if (tmp0_elvis_lhs == null) {
      prematureEndOfStream(2);
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var head = tmp;
    // Inline function 'io.ktor.utils.io.core.readShortFallback.<anonymous>' call
    var value = readShort(head);
    completeReadHead(_this__u8e3s4, head);
    return value;
  }
  function flushChain($this) {
    var tmp0_elvis_lhs = $this.c27();
    var tmp;
    if (tmp0_elvis_lhs == null) {
      return Unit_instance;
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var oldTail = tmp;
    try {
      // Inline function 'io.ktor.utils.io.core.forEachChunk' call
      // Inline function 'kotlin.contracts.contract' call
      var current = oldTail;
      $l$loop: do {
        // Inline function 'io.ktor.utils.io.core.Output.flushChain.<anonymous>' call
        var chunk = current;
        var tmp_0 = chunk.c29_1;
        // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
        var tmp$ret$0 = chunk.d29_1 - chunk.c29_1 | 0;
        $this.f2g(chunk.b29_1, tmp_0, tmp$ret$0);
        var tmp0_elvis_lhs_0 = current.t14();
        var tmp_1;
        if (tmp0_elvis_lhs_0 == null) {
          break $l$loop;
        } else {
          tmp_1 = tmp0_elvis_lhs_0;
        }
        current = tmp_1;
      }
       while (true);
    }finally {
      releaseAll(oldTail, $this.u26_1);
    }
  }
  function appendNewChunk($this) {
    var new_0 = $this.u26_1.z2f();
    new_0.j2e(8);
    $this.i2g(new_0);
    return new_0;
  }
  function appendChainImpl($this, head, newTail, chainedSizeDelta) {
    var _tail = $this.w26_1;
    if (_tail == null) {
      $this.v26_1 = head;
      $this.b27_1 = 0;
    } else {
      _tail.k2h(head);
      var tailPosition = $this.y26_1;
      _tail.f2e(tailPosition);
      $this.b27_1 = $this.b27_1 + (tailPosition - $this.a27_1 | 0) | 0;
    }
    $this.w26_1 = newTail;
    $this.b27_1 = $this.b27_1 + chainedSizeDelta | 0;
    $this.x26_1 = newTail.b29_1;
    $this.y26_1 = newTail.d29_1;
    $this.a27_1 = newTail.c29_1;
    $this.z26_1 = newTail.f29_1;
  }
  function writeByteFallback($this, v) {
    appendNewChunk($this).s2e(v);
    $this.y26_1 = $this.y26_1 + 1 | 0;
  }
  function appendCharFallback($this, c) {
    $l$block: {
      // Inline function 'io.ktor.utils.io.core.Output.write' call
      var buffer = $this.k2g(3);
      try {
        // Inline function 'io.ktor.utils.io.core.Output.appendCharFallback.<anonymous>' call
        // Inline function 'io.ktor.utils.io.core.internal.putUtf8Char' call
        var this_0 = buffer.b29_1;
        var offset = buffer.d29_1;
        // Inline function 'kotlin.code' call
        var v = Char__toInt_impl_vasixd(c);
        var tmp;
        if (0 <= v ? v <= 127 : false) {
          // Inline function 'io.ktor.utils.io.bits.Memory.storeAt' call
          var value = toByte(v);
          this_0.c2e_1.setInt8(offset, value);
          tmp = 1;
        } else if (128 <= v ? v <= 2047 : false) {
          // Inline function 'io.ktor.utils.io.bits.set' call
          var value_0 = toByte(192 | v >> 6 & 31);
          this_0.c2e_1.setInt8(offset, value_0);
          // Inline function 'io.ktor.utils.io.bits.set' call
          var index = offset + 1 | 0;
          var value_1 = toByte(128 | v & 63);
          this_0.c2e_1.setInt8(index, value_1);
          tmp = 2;
        } else if (2048 <= v ? v <= 65535 : false) {
          // Inline function 'io.ktor.utils.io.bits.set' call
          var value_2 = toByte(224 | v >> 12 & 15);
          this_0.c2e_1.setInt8(offset, value_2);
          // Inline function 'io.ktor.utils.io.bits.set' call
          var index_0 = offset + 1 | 0;
          var value_3 = toByte(128 | v >> 6 & 63);
          this_0.c2e_1.setInt8(index_0, value_3);
          // Inline function 'io.ktor.utils.io.bits.set' call
          var index_1 = offset + 2 | 0;
          var value_4 = toByte(128 | v & 63);
          this_0.c2e_1.setInt8(index_1, value_4);
          tmp = 3;
        } else if (65536 <= v ? v <= 1114111 : false) {
          // Inline function 'io.ktor.utils.io.bits.set' call
          var value_5 = toByte(240 | v >> 18 & 7);
          this_0.c2e_1.setInt8(offset, value_5);
          // Inline function 'io.ktor.utils.io.bits.set' call
          var index_2 = offset + 1 | 0;
          var value_6 = toByte(128 | v >> 12 & 63);
          this_0.c2e_1.setInt8(index_2, value_6);
          // Inline function 'io.ktor.utils.io.bits.set' call
          var index_3 = offset + 2 | 0;
          var value_7 = toByte(128 | v >> 6 & 63);
          this_0.c2e_1.setInt8(index_3, value_7);
          // Inline function 'io.ktor.utils.io.bits.set' call
          var index_4 = offset + 3 | 0;
          var value_8 = toByte(128 | v & 63);
          this_0.c2e_1.setInt8(index_4, value_8);
          tmp = 4;
        } else {
          malformedCodePoint(v);
        }
        var size = tmp;
        buffer.e2e(size);
        var result = size;
        // Inline function 'kotlin.check' call
        // Inline function 'kotlin.contracts.contract' call
        if (!(result >= 0)) {
          // Inline function 'io.ktor.utils.io.core.Output.write.<anonymous>' call
          var message = "The returned value shouldn't be negative";
          throw IllegalStateException_init_$Create$(toString(message));
        }
        break $l$block;
      }finally {
        $this.z2d();
      }
    }
  }
  function writePacketMerging($this, tail, foreignStolen, pool) {
    tail.f2e($this.y26_1);
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    var lastSize = tail.d29_1 - tail.c29_1 | 0;
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    var nextSize = foreignStolen.d29_1 - foreignStolen.c29_1 | 0;
    var maxCopySize = get_PACKET_MAX_COPY_SIZE();
    var tmp;
    var tmp_0;
    if (nextSize < maxCopySize) {
      // Inline function 'io.ktor.utils.io.core.Buffer.endGap' call
      var tmp_1 = tail.g29_1 - tail.f29_1 | 0;
      // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
      tmp_0 = nextSize <= (tmp_1 + (tail.f29_1 - tail.d29_1 | 0) | 0);
    } else {
      tmp_0 = false;
    }
    if (tmp_0) {
      tmp = nextSize;
    } else {
      tmp = -1;
    }
    var appendSize = tmp;
    var tmp_2;
    if ((lastSize < maxCopySize ? lastSize <= foreignStolen.e29_1 : false) ? isExclusivelyOwned(foreignStolen) : false) {
      tmp_2 = lastSize;
    } else {
      tmp_2 = -1;
    }
    var prependSize = tmp_2;
    if (appendSize === -1 ? prependSize === -1 : false) {
      $this.j2g(foreignStolen);
    } else if (prependSize === -1 ? true : appendSize <= prependSize) {
      // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
      var tmp_3 = tail.f29_1 - tail.d29_1 | 0;
      // Inline function 'io.ktor.utils.io.core.Buffer.endGap' call
      var tmp$ret$5 = tail.g29_1 - tail.f29_1 | 0;
      writeBufferAppend(tail, foreignStolen, tmp_3 + tmp$ret$5 | 0);
      $this.z2d();
      var tmp0_safe_receiver = foreignStolen.b2g();
      if (tmp0_safe_receiver == null)
        null;
      else {
        // Inline function 'kotlin.let' call
        // Inline function 'kotlin.contracts.contract' call
        $this.j2g(tmp0_safe_receiver);
      }
      foreignStolen.c2g(pool);
    } else if (appendSize === -1 ? true : prependSize < appendSize) {
      writePacketSlowPrepend($this, foreignStolen, tail);
    } else {
      throw IllegalStateException_init_$Create$('prep = ' + prependSize + ', app = ' + appendSize);
    }
  }
  function writePacketSlowPrepend($this, foreignStolen, tail) {
    writeBufferPrepend(foreignStolen, tail);
    var tmp0_elvis_lhs = $this.v26_1;
    var tmp;
    if (tmp0_elvis_lhs == null) {
      var message = "head should't be null since it is already handled in the fast-path";
      throw IllegalStateException_init_$Create$(toString(message));
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var _head = tmp;
    if (_head === tail) {
      $this.v26_1 = foreignStolen;
    } else {
      var pre = _head;
      $l$loop: while (true) {
        var next = ensureNotNull(pre.t14());
        if (next === tail)
          break $l$loop;
        pre = next;
      }
      pre.k2h(foreignStolen);
    }
    tail.c2g($this.u26_1);
    $this.w26_1 = findTail(foreignStolen);
  }
  function Output(pool) {
    this.u26_1 = pool;
    this.v26_1 = null;
    this.w26_1 = null;
    this.x26_1 = Companion_getInstance_6().l2h_1;
    this.y26_1 = 0;
    this.z26_1 = 0;
    this.a27_1 = 0;
    this.b27_1 = 0;
  }
  protoOf(Output).d2g = function () {
    return this.b27_1 + (this.y26_1 - this.a27_1 | 0) | 0;
  };
  protoOf(Output).h2g = function () {
    var tmp0_elvis_lhs = this.v26_1;
    return tmp0_elvis_lhs == null ? Companion_getInstance_4().q2c_1 : tmp0_elvis_lhs;
  };
  protoOf(Output).t6 = function () {
    flushChain(this);
  };
  protoOf(Output).c27 = function () {
    var tmp0_elvis_lhs = this.v26_1;
    var tmp;
    if (tmp0_elvis_lhs == null) {
      return null;
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var head = tmp;
    var tmp1_safe_receiver = this.w26_1;
    if (tmp1_safe_receiver == null)
      null;
    else
      tmp1_safe_receiver.f2e(this.y26_1);
    this.v26_1 = null;
    this.w26_1 = null;
    this.y26_1 = 0;
    this.z26_1 = 0;
    this.a27_1 = 0;
    this.b27_1 = 0;
    this.x26_1 = Companion_getInstance_6().l2h_1;
    return head;
  };
  protoOf(Output).i2g = function (buffer) {
    // Inline function 'kotlin.check' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(buffer.t14() == null)) {
      // Inline function 'io.ktor.utils.io.core.Output.appendSingleChunk.<anonymous>' call
      var message = 'It should be a single buffer chunk.';
      throw IllegalStateException_init_$Create$(toString(message));
    }
    appendChainImpl(this, buffer, buffer, 0);
  };
  protoOf(Output).j2g = function (head) {
    var tail = findTail(head);
    // Inline function 'io.ktor.utils.io.core.internal.toIntOrFail' call
    // Inline function 'kotlin.Long.minus' call
    var this_0 = remainingAll(head);
    // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
    var other = tail.d29_1 - tail.c29_1 | 0;
    var this_1 = this_0.mc(toLong(other));
    var name = 'total size increase';
    if (this_1.c7(toLong(IntCompanionObject_instance.MAX_VALUE)) >= 0) {
      failLongToIntConversion(this_1, name);
    }
    var chainedSizeDelta = this_1.mb();
    appendChainImpl(this, head, tail, chainedSizeDelta);
  };
  protoOf(Output).s2e = function (v) {
    var index = this.y26_1;
    if (index < this.z26_1) {
      this.y26_1 = index + 1 | 0;
      // Inline function 'io.ktor.utils.io.bits.set' call
      this.x26_1.c2e_1.setInt8(index, v);
      return Unit_instance;
    }
    return writeByteFallback(this, v);
  };
  protoOf(Output).n = function () {
    try {
      this.t6();
    }finally {
      this.e2g();
    }
  };
  protoOf(Output).z5 = function (value) {
    var tailPosition = this.y26_1;
    if ((this.z26_1 - tailPosition | 0) >= 3) {
      // Inline function 'io.ktor.utils.io.core.internal.putUtf8Char' call
      var this_0 = this.x26_1;
      // Inline function 'kotlin.code' call
      var v = Char__toInt_impl_vasixd(value);
      var tmp;
      if (0 <= v ? v <= 127 : false) {
        // Inline function 'io.ktor.utils.io.bits.Memory.storeAt' call
        var value_0 = toByte(v);
        this_0.c2e_1.setInt8(tailPosition, value_0);
        tmp = 1;
      } else if (128 <= v ? v <= 2047 : false) {
        // Inline function 'io.ktor.utils.io.bits.set' call
        var value_1 = toByte(192 | v >> 6 & 31);
        this_0.c2e_1.setInt8(tailPosition, value_1);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index = tailPosition + 1 | 0;
        var value_2 = toByte(128 | v & 63);
        this_0.c2e_1.setInt8(index, value_2);
        tmp = 2;
      } else if (2048 <= v ? v <= 65535 : false) {
        // Inline function 'io.ktor.utils.io.bits.set' call
        var value_3 = toByte(224 | v >> 12 & 15);
        this_0.c2e_1.setInt8(tailPosition, value_3);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_0 = tailPosition + 1 | 0;
        var value_4 = toByte(128 | v >> 6 & 63);
        this_0.c2e_1.setInt8(index_0, value_4);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_1 = tailPosition + 2 | 0;
        var value_5 = toByte(128 | v & 63);
        this_0.c2e_1.setInt8(index_1, value_5);
        tmp = 3;
      } else if (65536 <= v ? v <= 1114111 : false) {
        // Inline function 'io.ktor.utils.io.bits.set' call
        var value_6 = toByte(240 | v >> 18 & 7);
        this_0.c2e_1.setInt8(tailPosition, value_6);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_2 = tailPosition + 1 | 0;
        var value_7 = toByte(128 | v >> 12 & 63);
        this_0.c2e_1.setInt8(index_2, value_7);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_3 = tailPosition + 2 | 0;
        var value_8 = toByte(128 | v >> 6 & 63);
        this_0.c2e_1.setInt8(index_3, value_8);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_4 = tailPosition + 3 | 0;
        var value_9 = toByte(128 | v & 63);
        this_0.c2e_1.setInt8(index_4, value_9);
        tmp = 4;
      } else {
        malformedCodePoint(v);
      }
      var size = tmp;
      this.y26_1 = tailPosition + size | 0;
      return this;
    }
    appendCharFallback(this, value);
    return this;
  };
  protoOf(Output).r8 = function (value) {
    if (value == null) {
      this.s8('null', 0, 4);
    } else {
      this.s8(value, 0, charSequenceLength(value));
    }
    return this;
  };
  protoOf(Output).s8 = function (value, startIndex, endIndex) {
    if (value == null) {
      return this.s8('null', startIndex, endIndex);
    }
    writeText(this, value, startIndex, endIndex, Charsets_getInstance().m2h_1);
    return this;
  };
  protoOf(Output).f2d = function (packet) {
    var foreignStolen = packet.c27();
    if (foreignStolen == null) {
      packet.qy();
      return Unit_instance;
    }
    var tail = this.w26_1;
    if (tail == null) {
      this.j2g(foreignStolen);
      return Unit_instance;
    }
    writePacketMerging(this, tail, foreignStolen, packet.k2a_1);
  };
  protoOf(Output).d27 = function (chunkBuffer) {
    var _tail = this.w26_1;
    if (_tail == null) {
      this.j2g(chunkBuffer);
      return Unit_instance;
    }
    writePacketMerging(this, _tail, chunkBuffer, this.u26_1);
  };
  protoOf(Output).s2a = function (p, n) {
    var remaining = n;
    $l$loop: while (remaining.c7(new Long(0, 0)) > 0) {
      // Inline function 'io.ktor.utils.io.core.Input.headRemaining' call
      var tmp$ret$0 = p.o2a_1 - p.n2a_1 | 0;
      var headRemaining = toLong(tmp$ret$0);
      if (headRemaining.c7(remaining) <= 0) {
        remaining = remaining.mc(headRemaining);
        var tmp0_elvis_lhs = p.x2g();
        var tmp;
        if (tmp0_elvis_lhs == null) {
          throw new EOFException('Unexpected end of packet');
        } else {
          tmp = tmp0_elvis_lhs;
        }
        this.i2g(tmp);
      } else {
        // Inline function 'io.ktor.utils.io.core.read' call
        // Inline function 'kotlin.contracts.contract' call
        var tmp0_elvis_lhs_0 = p.i2h(1);
        var tmp_0;
        if (tmp0_elvis_lhs_0 == null) {
          prematureEndOfStream(1);
        } else {
          tmp_0 = tmp0_elvis_lhs_0;
        }
        var buffer = tmp_0;
        var positionBefore = buffer.c29_1;
        try {
          // Inline function 'io.ktor.utils.io.core.Output.writePacket.<anonymous>' call
          writeFully_2(this, buffer, remaining.mb());
        }finally {
          var positionAfter = buffer.c29_1;
          if (positionAfter < positionBefore) {
            throw IllegalStateException_init_$Create$("Buffer's position shouldn't be rewinded");
          }
          if (positionAfter === buffer.d29_1) {
            p.g2h(buffer);
          } else {
            p.n2a_1 = positionAfter;
          }
        }
        break $l$loop;
      }
    }
  };
  protoOf(Output).qy = function () {
    this.n();
  };
  protoOf(Output).k2g = function (n) {
    // Inline function 'io.ktor.utils.io.core.Output.tailRemaining' call
    if ((this.z26_1 - this.y26_1 | 0) >= n) {
      var tmp0_safe_receiver = this.w26_1;
      if (tmp0_safe_receiver == null)
        null;
      else {
        // Inline function 'kotlin.let' call
        // Inline function 'kotlin.contracts.contract' call
        tmp0_safe_receiver.f2e(this.y26_1);
        return tmp0_safe_receiver;
      }
    }
    return appendNewChunk(this);
  };
  protoOf(Output).z2d = function () {
    var tmp0_safe_receiver = this.w26_1;
    if (tmp0_safe_receiver == null)
      null;
    else {
      // Inline function 'kotlin.let' call
      // Inline function 'kotlin.contracts.contract' call
      this.y26_1 = tmp0_safe_receiver.d29_1;
    }
  };
  protoOf(Output).l2g = function () {
    var head = this.h2g();
    if (!(head === Companion_getInstance_4().q2c_1)) {
      // Inline function 'kotlin.check' call
      // Inline function 'kotlin.contracts.contract' call
      // Inline function 'kotlin.check' call
      // Inline function 'kotlin.contracts.contract' call
      if (!(head.t14() == null)) {
        // Inline function 'kotlin.check.<anonymous>' call
        var message = 'Check failed.';
        throw IllegalStateException_init_$Create$(toString(message));
      }
      head.l2e();
      head.j2e(8);
      this.y26_1 = head.d29_1;
      this.a27_1 = this.y26_1;
      this.z26_1 = head.f29_1;
    }
  };
  function writeFully_2(_this__u8e3s4, src, length) {
    var tmp;
    if (length === VOID) {
      // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
      tmp = src.d29_1 - src.c29_1 | 0;
    } else {
      tmp = length;
    }
    length = tmp;
    // Inline function 'io.ktor.utils.io.core.writeFullyBytesTemplate' call
    var currentOffset = 0;
    var remaining = length;
    // Inline function 'io.ktor.utils.io.core.writeWhile' call
    var tail = prepareWriteHead(_this__u8e3s4, 1, null);
    try {
      $l$loop: while (true) {
        // Inline function 'io.ktor.utils.io.core.writeFullyBytesTemplate.<anonymous>' call
        var buffer = tail;
        // Inline function 'kotlin.comparisons.minOf' call
        var a = remaining;
        // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
        var b = buffer.f29_1 - buffer.d29_1 | 0;
        var size = Math.min(a, b);
        // Inline function 'io.ktor.utils.io.core.writeFully.<anonymous>' call
        writeFully_1(buffer, src, size);
        currentOffset = currentOffset + size | 0;
        remaining = remaining - size | 0;
        if (!(remaining > 0))
          break $l$loop;
        tail = prepareWriteHead(_this__u8e3s4, 1, tail);
      }
    }finally {
      _this__u8e3s4.z2d();
    }
  }
  function writeFully_3(_this__u8e3s4, src, offset, length) {
    offset = offset === VOID ? 0 : offset;
    length = length === VOID ? src.length - offset | 0 : length;
    // Inline function 'io.ktor.utils.io.core.writeFullyBytesTemplate' call
    var currentOffset = offset;
    var remaining = length;
    // Inline function 'io.ktor.utils.io.core.writeWhile' call
    var tail = prepareWriteHead(_this__u8e3s4, 1, null);
    try {
      $l$loop: while (true) {
        // Inline function 'io.ktor.utils.io.core.writeFullyBytesTemplate.<anonymous>' call
        var buffer = tail;
        // Inline function 'kotlin.comparisons.minOf' call
        var a = remaining;
        // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
        var b = buffer.f29_1 - buffer.d29_1 | 0;
        var size = Math.min(a, b);
        // Inline function 'io.ktor.utils.io.core.writeFully.<anonymous>' call
        var currentOffset_0 = currentOffset;
        writeFully_0(buffer, src, currentOffset_0, size);
        currentOffset = currentOffset + size | 0;
        remaining = remaining - size | 0;
        if (!(remaining > 0))
          break $l$loop;
        tail = prepareWriteHead(_this__u8e3s4, 1, tail);
      }
    }finally {
      _this__u8e3s4.z2d();
    }
  }
  function writeShort_0(_this__u8e3s4, value) {
    var tmp$ret$0;
    $l$block: {
      // Inline function 'io.ktor.utils.io.core.writePrimitiveTemplate' call
      var index = _this__u8e3s4.y26_1;
      if ((_this__u8e3s4.z26_1 - index | 0) > 2) {
        _this__u8e3s4.y26_1 = index + 2 | 0;
        // Inline function 'io.ktor.utils.io.core.writeShort.<anonymous>' call
        // Inline function 'io.ktor.utils.io.bits.storeShortAt' call
        _this__u8e3s4.x26_1.c2e_1.setInt16(index, value, false);
        tmp$ret$0 = true;
        break $l$block;
      }
      tmp$ret$0 = false;
    }
    if (!tmp$ret$0) {
      writeShortFallback(_this__u8e3s4, value);
    }
  }
  function writeShortFallback(_this__u8e3s4, value) {
    // Inline function 'io.ktor.utils.io.core.writePrimitiveFallbackTemplate' call
    var tail = _this__u8e3s4.k2g(2);
    // Inline function 'io.ktor.utils.io.core.writeShortFallback.<anonymous>' call
    writeShort(tail, value);
    _this__u8e3s4.z2d();
    if (!true) {
      // Inline function 'io.ktor.utils.io.bits.highByte' call
      var tmp$ret$1 = toByte(value >>> 8 | 0);
      _this__u8e3s4.s2e(tmp$ret$1);
      // Inline function 'io.ktor.utils.io.bits.lowByte' call
      var tmp$ret$2 = toByte(value & 255);
      _this__u8e3s4.s2e(tmp$ret$2);
    }
  }
  function readText(_this__u8e3s4, charset, max) {
    charset = charset === VOID ? Charsets_getInstance().m2h_1 : charset;
    max = max === VOID ? IntCompanionObject_instance.MAX_VALUE : max;
    return decode(charset.p2h(), _this__u8e3s4, max);
  }
  function readBytes(_this__u8e3s4, n) {
    var tmp;
    if (n === VOID) {
      // Inline function 'io.ktor.utils.io.core.coerceAtMostMaxIntOrFail' call
      var this_0 = _this__u8e3s4.r2a();
      var message = 'Unable to convert to a ByteArray: packet is too big';
      if (this_0.c7(toLong(IntCompanionObject_instance.MAX_VALUE)) > 0)
        throw IllegalArgumentException_init_$Create$(message);
      tmp = this_0.mb();
    } else {
      tmp = n;
    }
    n = tmp;
    var tmp_0;
    if (!(n === 0)) {
      // Inline function 'kotlin.also' call
      var this_1 = new Int8Array(n);
      // Inline function 'kotlin.contracts.contract' call
      // Inline function 'io.ktor.utils.io.core.readBytes.<anonymous>' call
      readFully_1(_this__u8e3s4, this_1, 0, n);
      tmp_0 = this_1;
    } else {
      tmp_0 = get_EmptyByteArray();
    }
    return tmp_0;
  }
  function prematureEndOfStream(size) {
    throw new EOFException('Premature end of stream: expected ' + size + ' bytes');
  }
  function readTextExactBytes(_this__u8e3s4, bytesCount, charset) {
    charset = charset === VOID ? Charsets_getInstance().m2h_1 : charset;
    return decodeExactBytes(charset.p2h(), _this__u8e3s4, bytesCount);
  }
  function writeText(_this__u8e3s4, text, fromIndex, toIndex, charset) {
    fromIndex = fromIndex === VOID ? 0 : fromIndex;
    toIndex = toIndex === VOID ? charSequenceLength(text) : toIndex;
    charset = charset === VOID ? Charsets_getInstance().m2h_1 : charset;
    if (charset === Charsets_getInstance().m2h_1) {
      return writeTextUtf8(_this__u8e3s4, text, fromIndex, toIndex);
    }
    encodeToImpl(charset.q2h(), _this__u8e3s4, text, fromIndex, toIndex);
  }
  function writeTextUtf8(_this__u8e3s4, text, fromIndex, toIndex) {
    var index = fromIndex;
    // Inline function 'io.ktor.utils.io.core.writeWhileSize' call
    var tail = prepareWriteHead(_this__u8e3s4, 1, null);
    try {
      var size;
      $l$loop: while (true) {
        // Inline function 'io.ktor.utils.io.core.writeTextUtf8.<anonymous>' call
        var buffer = tail;
        var memory = buffer.b29_1;
        var dstOffset = buffer.d29_1;
        var dstLimit = buffer.f29_1;
        var tmp0_container = encodeUTF8(memory, text, index, toIndex, dstOffset, dstLimit);
        var characters = EncodeResult__component1_impl_36tlhi(tmp0_container);
        var bytes = EncodeResult__component2_impl_3nv7vp(tmp0_container);
        var tmp = index;
        // Inline function 'kotlin.UShort.toInt' call
        index = tmp + (_UShort___get_data__impl__g0245(characters) & 65535) | 0;
        // Inline function 'kotlin.UShort.toInt' call
        var tmp$ret$1 = _UShort___get_data__impl__g0245(bytes) & 65535;
        buffer.e2e(tmp$ret$1);
        var tmp_0;
        var tmp_1;
        // Inline function 'kotlin.UShort.toInt' call
        if ((_UShort___get_data__impl__g0245(characters) & 65535) === 0) {
          tmp_1 = index < toIndex;
        } else {
          tmp_1 = false;
        }
        if (tmp_1) {
          tmp_0 = 8;
        } else {
          if (index < toIndex) {
            tmp_0 = 1;
          } else {
            tmp_0 = 0;
          }
        }
        size = tmp_0;
        if (size <= 0)
          break $l$loop;
        tail = prepareWriteHead(_this__u8e3s4, size, tail);
      }
    }finally {
      _this__u8e3s4.z2d();
    }
  }
  function readBytes_0(_this__u8e3s4) {
    return readBytesOf(_this__u8e3s4);
  }
  function readBytesOf(_this__u8e3s4, min, max) {
    min = min === VOID ? 0 : min;
    max = max === VOID ? IntCompanionObject_instance.MAX_VALUE : max;
    var tmp;
    if (min === max ? min === 0 : false) {
      tmp = get_EmptyByteArray();
    } else if (min === max) {
      // Inline function 'kotlin.also' call
      var this_0 = new Int8Array(min);
      // Inline function 'kotlin.contracts.contract' call
      // Inline function 'io.ktor.utils.io.core.readBytesOf.<anonymous>' call
      readFully_1(_this__u8e3s4, this_0, 0, min);
      tmp = this_0;
    } else {
      var array = new Int8Array(coerceAtLeast_0(coerceAtMost_0(toLong(max), sizeEstimate(_this__u8e3s4)), toLong(min)).mb());
      var size = 0;
      $l$loop: while (size < max) {
        // Inline function 'kotlin.comparisons.minOf' call
        var b = array.length;
        var partSize = Math.min(max, b) - size | 0;
        var rc = readAvailable_0(_this__u8e3s4, array, size, partSize);
        if (rc <= 0)
          break $l$loop;
        size = size + rc | 0;
        if (array.length === size) {
          array = copyOf(array, imul(size, 2));
        }
      }
      if (size < min) {
        throw new EOFException('Not enough bytes available to read ' + min + ' bytes: ' + (min - size | 0) + ' more required');
      }
      tmp = size === array.length ? array : copyOf(array, size);
    }
    return tmp;
  }
  function ChunkBuffer$Companion$EmptyPool$1() {
  }
  protoOf(ChunkBuffer$Companion$EmptyPool$1).z2f = function () {
    return Companion_getInstance_4().q2c_1;
  };
  protoOf(ChunkBuffer$Companion$EmptyPool$1).r2h = function (instance) {
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(instance === Companion_getInstance_4().q2c_1)) {
      // Inline function 'io.ktor.utils.io.core.internal.<no name provided>.recycle.<anonymous>' call
      var message = 'Only ChunkBuffer.Empty instance could be recycled.';
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
  };
  protoOf(ChunkBuffer$Companion$EmptyPool$1).a2g = function (instance) {
    return this.r2h(instance instanceof ChunkBuffer ? instance : THROW_CCE());
  };
  function ChunkBuffer$Companion$NoPool$1() {
    NoPoolImpl.call(this);
  }
  protoOf(ChunkBuffer$Companion$NoPool$1).z2f = function () {
    return new ChunkBuffer(DefaultAllocator_instance.b2f(get_DEFAULT_BUFFER_SIZE()), null, this);
  };
  protoOf(ChunkBuffer$Companion$NoPool$1).r2h = function (instance) {
    DefaultAllocator_instance.d2f(instance.b29_1);
  };
  protoOf(ChunkBuffer$Companion$NoPool$1).a2g = function (instance) {
    return this.r2h(instance instanceof ChunkBuffer ? instance : THROW_CCE());
  };
  function ChunkBuffer$Companion$NoPoolManuallyManaged$1() {
    NoPoolImpl.call(this);
  }
  protoOf(ChunkBuffer$Companion$NoPoolManuallyManaged$1).z2f = function () {
    throw UnsupportedOperationException_init_$Create$("This pool doesn't support borrow");
  };
  protoOf(ChunkBuffer$Companion$NoPoolManuallyManaged$1).r2h = function (instance) {
  };
  protoOf(ChunkBuffer$Companion$NoPoolManuallyManaged$1).a2g = function (instance) {
    return this.r2h(instance instanceof ChunkBuffer ? instance : THROW_CCE());
  };
  function appendNext($this, chunk) {
    if (!$this.p2f_1.atomicfu$compareAndSet(null, chunk)) {
      throw IllegalStateException_init_$Create$('This chunk has already a next chunk.');
    }
  }
  function Companion_2() {
    Companion_instance_2 = this;
    var tmp = this;
    tmp.p2c_1 = new ChunkBuffer$Companion$EmptyPool$1();
    this.q2c_1 = new ChunkBuffer(Companion_getInstance_6().l2h_1, null, this.p2c_1);
    var tmp_0 = this;
    tmp_0.r2c_1 = new ChunkBuffer$Companion$NoPool$1();
    var tmp_1 = this;
    tmp_1.s2c_1 = new ChunkBuffer$Companion$NoPoolManuallyManaged$1();
  }
  protoOf(Companion_2).t2c = function () {
    return get_DefaultChunkedBufferPool();
  };
  var Companion_instance_2;
  function Companion_getInstance_4() {
    if (Companion_instance_2 == null)
      new Companion_2();
    return Companion_instance_2;
  }
  function ChunkBuffer(memory, origin, parentPool) {
    Companion_getInstance_4();
    Buffer.call(this, memory);
    this.o2f_1 = parentPool;
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!!(origin === this)) {
      // Inline function 'io.ktor.utils.io.core.internal.ChunkBuffer.<anonymous>' call
      var message = "A chunk couldn't be a view of itself.";
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    this.p2f_1 = atomic$ref$1(null);
    this.q2f_1 = atomic$int$1(1);
    this.r2f_1 = origin;
  }
  protoOf(ChunkBuffer).k2h = function (newValue) {
    if (newValue == null) {
      this.b2g();
    } else {
      appendNext(this, newValue);
    }
  };
  protoOf(ChunkBuffer).t14 = function () {
    return this.p2f_1.kotlinx$atomicfu$value;
  };
  protoOf(ChunkBuffer).v2f = function () {
    return this.q2f_1.kotlinx$atomicfu$value;
  };
  protoOf(ChunkBuffer).b2g = function () {
    return this.p2f_1.atomicfu$getAndSet(null);
  };
  protoOf(ChunkBuffer).s2h = function () {
    // Inline function 'kotlin.let' call
    var tmp0_elvis_lhs = this.r2f_1;
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.internal.ChunkBuffer.duplicate.<anonymous>' call
    var newOrigin = tmp0_elvis_lhs == null ? this : tmp0_elvis_lhs;
    newOrigin.t2h();
    // Inline function 'kotlin.also' call
    var this_0 = new ChunkBuffer(this.b29_1, newOrigin, this.o2f_1);
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.internal.ChunkBuffer.duplicate.<anonymous>.<anonymous>' call
    this.q2e(this_0);
    return this_0;
  };
  protoOf(ChunkBuffer).c2g = function (pool) {
    if (this.u2h()) {
      var origin = this.r2f_1;
      if (!(origin == null)) {
        this.s2f();
        origin.c2g(pool);
      } else {
        var tmp0_elvis_lhs = this.o2f_1;
        var poolToUse = tmp0_elvis_lhs == null ? pool : tmp0_elvis_lhs;
        poolToUse.a2g(this);
      }
    }
  };
  protoOf(ChunkBuffer).s2f = function () {
    if (!this.q2f_1.atomicfu$compareAndSet(0, -1)) {
      throw IllegalStateException_init_$Create$('Unable to unlink: buffer is in use.');
    }
    this.b2g();
    this.r2f_1 = null;
  };
  protoOf(ChunkBuffer).t2h = function () {
    $l$block: {
      // Inline function 'kotlinx.atomicfu.update' call
      var this_0 = this.q2f_1;
      while (true) {
        var cur = this_0.kotlinx$atomicfu$value;
        // Inline function 'io.ktor.utils.io.core.internal.ChunkBuffer.acquire.<anonymous>' call
        if (cur <= 0)
          throw IllegalStateException_init_$Create$('Unable to acquire chunk: it is already released.');
        var upd = cur + 1 | 0;
        if (this_0.atomicfu$compareAndSet(cur, upd)) {
          break $l$block;
        }
      }
    }
  };
  protoOf(ChunkBuffer).y2f = function () {
    $l$block: {
      // Inline function 'kotlinx.atomicfu.update' call
      var this_0 = this.q2f_1;
      while (true) {
        var cur = this_0.kotlinx$atomicfu$value;
        // Inline function 'io.ktor.utils.io.core.internal.ChunkBuffer.unpark.<anonymous>' call
        if (cur < 0) {
          throw IllegalStateException_init_$Create$("This instance is already disposed and couldn't be borrowed.");
        }
        if (cur > 0) {
          throw IllegalStateException_init_$Create$('This instance is already in use but somehow appeared in the pool.');
        }
        var upd = 1;
        if (this_0.atomicfu$compareAndSet(cur, upd)) {
          break $l$block;
        }
      }
    }
  };
  protoOf(ChunkBuffer).u2h = function () {
    var tmp$ret$1;
    $l$block: {
      // Inline function 'kotlinx.atomicfu.updateAndGet' call
      var this_0 = this.q2f_1;
      while (true) {
        var cur = this_0.kotlinx$atomicfu$value;
        // Inline function 'io.ktor.utils.io.core.internal.ChunkBuffer.release.<anonymous>' call
        if (cur <= 0)
          throw IllegalStateException_init_$Create$('Unable to release: it is already released.');
        var upd = cur - 1 | 0;
        if (this_0.atomicfu$compareAndSet(cur, upd)) {
          tmp$ret$1 = upd;
          break $l$block;
        }
      }
    }
    return tmp$ret$1 === 0;
  };
  protoOf(ChunkBuffer).t2e = function () {
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(this.r2f_1 == null)) {
      // Inline function 'io.ktor.utils.io.core.internal.ChunkBuffer.reset.<anonymous>' call
      var message = 'Unable to reset buffer with origin';
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    protoOf(Buffer).t2e.call(this);
    this.p2f_1.kotlinx$atomicfu$value = null;
  };
  function isExclusivelyOwned(_this__u8e3s4) {
    return _this__u8e3s4.v2f() === 1;
  }
  function _EncodeResult___init__impl__vkc0cy(value) {
    return value;
  }
  function _EncodeResult___get_value__impl__h0r466($this) {
    return $this;
  }
  function _EncodeResult___init__impl__vkc0cy_0(characters, bytes) {
    // Inline function 'kotlin.UShort.toInt' call
    var tmp = (_UShort___get_data__impl__g0245(characters) & 65535) << 16;
    // Inline function 'kotlin.UShort.toInt' call
    var tmp$ret$1 = _UShort___get_data__impl__g0245(bytes) & 65535;
    return _EncodeResult___init__impl__vkc0cy(tmp | tmp$ret$1);
  }
  function _EncodeResult___get_characters__impl__rrxzcv($this) {
    // Inline function 'kotlin.toUShort' call
    // Inline function 'io.ktor.utils.io.bits.highShort' call
    var this_0 = _EncodeResult___get_value__impl__h0r466($this);
    var this_1 = toShort(this_0 >>> 16 | 0);
    return _UShort___init__impl__jigrne(this_1);
  }
  function _EncodeResult___get_bytes__impl__bt0kq0($this) {
    // Inline function 'kotlin.toUShort' call
    // Inline function 'io.ktor.utils.io.bits.lowShort' call
    var this_0 = _EncodeResult___get_value__impl__h0r466($this);
    var this_1 = toShort(this_0 & 65535);
    return _UShort___init__impl__jigrne(this_1);
  }
  function EncodeResult__component1_impl_36tlhi($this) {
    return _EncodeResult___get_characters__impl__rrxzcv($this);
  }
  function EncodeResult__component2_impl_3nv7vp($this) {
    return _EncodeResult___get_bytes__impl__bt0kq0($this);
  }
  function failLongToIntConversion(value, name) {
    throw IllegalArgumentException_init_$Create$('Long value ' + value.toString() + ' of ' + name + " doesn't fit into 32-bit integer");
  }
  function MalformedUTF8InputException(message) {
    Exception_init_$Init$(message, this);
    captureStack(this, MalformedUTF8InputException);
  }
  function malformedByteCount(byteCount) {
    throw new MalformedUTF8InputException('Expected ' + byteCount + ' more character bytes');
  }
  function isBmpCodePoint(cp) {
    return (cp >>> 16 | 0) === 0;
  }
  function isValidCodePoint(codePoint) {
    return codePoint <= 1114111;
  }
  function malformedCodePoint(value) {
    throw IllegalArgumentException_init_$Create$('Malformed code-point ' + value + ' found');
  }
  function highSurrogate(cp) {
    return (cp >>> 10 | 0) + 55232 | 0;
  }
  function lowSurrogate(cp) {
    return (cp & 1023) + 56320 | 0;
  }
  function encodeUTF8(_this__u8e3s4, text, from, to, dstOffset, dstLimit) {
    // Inline function 'kotlin.comparisons.minOf' call
    // Inline function 'kotlin.UShort.toInt' call
    Companion_getInstance_0();
    var this_0 = _UShort___init__impl__jigrne(-1);
    var b = from + (_UShort___get_data__impl__g0245(this_0) & 65535) | 0;
    var lastCharIndex = Math.min(to, b);
    // Inline function 'kotlin.UShort.toInt' call
    Companion_getInstance_0();
    var this_1 = _UShort___init__impl__jigrne(-1);
    var tmp$ret$2 = _UShort___get_data__impl__g0245(this_1) & 65535;
    var resultLimit = coerceAtMost(dstLimit, tmp$ret$2);
    var resultPosition = dstOffset;
    var index = from;
    $l$loop: do {
      if (resultPosition >= resultLimit ? true : index >= lastCharIndex) {
        // Inline function 'kotlin.toUShort' call
        var this_2 = index - from | 0;
        var tmp = _UShort___init__impl__jigrne(toShort(this_2));
        // Inline function 'kotlin.toUShort' call
        var this_3 = resultPosition - dstOffset | 0;
        var tmp$ret$4 = _UShort___init__impl__jigrne(toShort(this_3));
        return _EncodeResult___init__impl__vkc0cy_0(tmp, tmp$ret$4);
      }
      // Inline function 'kotlin.code' call
      var tmp0 = index;
      index = tmp0 + 1 | 0;
      var this_4 = charSequenceGet(text, tmp0);
      var character = Char__toInt_impl_vasixd(this_4) & 65535;
      if ((character & 65408) === 0) {
        // Inline function 'io.ktor.utils.io.bits.Memory.storeAt' call
        var tmp1 = resultPosition;
        resultPosition = tmp1 + 1 | 0;
        var value = toByte(character);
        _this__u8e3s4.c2e_1.setInt8(tmp1, value);
      } else {
        break $l$loop;
      }
    }
     while (true);
    index = index - 1 | 0;
    return encodeUTF8Stage1(_this__u8e3s4, text, index, lastCharIndex, from, resultPosition, resultLimit, dstOffset);
  }
  function encodeUTF8Stage1(_this__u8e3s4, text, index1, lastCharIndex, from, resultPosition1, resultLimit, dstOffset) {
    var index = index1;
    var resultPosition = resultPosition1;
    var stage1Limit = resultLimit - 3 | 0;
    $l$loop: do {
      var freeSpace = stage1Limit - resultPosition | 0;
      if (freeSpace <= 0 ? true : index >= lastCharIndex) {
        break $l$loop;
      }
      var tmp0 = index;
      index = tmp0 + 1 | 0;
      var character = charSequenceGet(text, tmp0);
      var tmp;
      if (isHighSurrogate(character)) {
        var tmp_0;
        if (index === lastCharIndex ? true : !isLowSurrogate(charSequenceGet(text, index))) {
          tmp_0 = 63;
        } else {
          var tmp1 = index;
          index = tmp1 + 1 | 0;
          tmp_0 = codePoint(character, charSequenceGet(text, tmp1));
        }
        tmp = tmp_0;
      } else {
        // Inline function 'kotlin.code' call
        tmp = Char__toInt_impl_vasixd(character);
      }
      var codepoint = tmp;
      // Inline function 'io.ktor.utils.io.core.internal.putUtf8Char' call
      var offset = resultPosition;
      var tmp_1;
      if (0 <= codepoint ? codepoint <= 127 : false) {
        // Inline function 'io.ktor.utils.io.bits.Memory.storeAt' call
        var value = toByte(codepoint);
        _this__u8e3s4.c2e_1.setInt8(offset, value);
        tmp_1 = 1;
      } else if (128 <= codepoint ? codepoint <= 2047 : false) {
        // Inline function 'io.ktor.utils.io.bits.set' call
        var value_0 = toByte(192 | codepoint >> 6 & 31);
        _this__u8e3s4.c2e_1.setInt8(offset, value_0);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_0 = offset + 1 | 0;
        var value_1 = toByte(128 | codepoint & 63);
        _this__u8e3s4.c2e_1.setInt8(index_0, value_1);
        tmp_1 = 2;
      } else if (2048 <= codepoint ? codepoint <= 65535 : false) {
        // Inline function 'io.ktor.utils.io.bits.set' call
        var value_2 = toByte(224 | codepoint >> 12 & 15);
        _this__u8e3s4.c2e_1.setInt8(offset, value_2);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_1 = offset + 1 | 0;
        var value_3 = toByte(128 | codepoint >> 6 & 63);
        _this__u8e3s4.c2e_1.setInt8(index_1, value_3);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_2 = offset + 2 | 0;
        var value_4 = toByte(128 | codepoint & 63);
        _this__u8e3s4.c2e_1.setInt8(index_2, value_4);
        tmp_1 = 3;
      } else if (65536 <= codepoint ? codepoint <= 1114111 : false) {
        // Inline function 'io.ktor.utils.io.bits.set' call
        var value_5 = toByte(240 | codepoint >> 18 & 7);
        _this__u8e3s4.c2e_1.setInt8(offset, value_5);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_3 = offset + 1 | 0;
        var value_6 = toByte(128 | codepoint >> 12 & 63);
        _this__u8e3s4.c2e_1.setInt8(index_3, value_6);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_4 = offset + 2 | 0;
        var value_7 = toByte(128 | codepoint >> 6 & 63);
        _this__u8e3s4.c2e_1.setInt8(index_4, value_7);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_5 = offset + 3 | 0;
        var value_8 = toByte(128 | codepoint & 63);
        _this__u8e3s4.c2e_1.setInt8(index_5, value_8);
        tmp_1 = 4;
      } else {
        malformedCodePoint(codepoint);
      }
      var size = tmp_1;
      resultPosition = resultPosition + size | 0;
    }
     while (true);
    if (resultPosition === stage1Limit) {
      return encodeUTF8Stage2(_this__u8e3s4, text, index, lastCharIndex, from, resultPosition, resultLimit, dstOffset);
    }
    // Inline function 'kotlin.toUShort' call
    var this_0 = index - from | 0;
    var tmp_2 = _UShort___init__impl__jigrne(toShort(this_0));
    // Inline function 'kotlin.toUShort' call
    var this_1 = resultPosition - dstOffset | 0;
    var tmp$ret$12 = _UShort___init__impl__jigrne(toShort(this_1));
    return _EncodeResult___init__impl__vkc0cy_0(tmp_2, tmp$ret$12);
  }
  function codePoint(high, low) {
    // Inline function 'kotlin.code' call
    var highValue = Char__toInt_impl_vasixd(high) - 55232 | 0;
    // Inline function 'kotlin.code' call
    var lowValue = Char__toInt_impl_vasixd(low) - 56320 | 0;
    return highValue << 10 | lowValue;
  }
  function encodeUTF8Stage2(_this__u8e3s4, text, index1, lastCharIndex, from, resultPosition1, resultLimit, dstOffset) {
    var index = index1;
    var resultPosition = resultPosition1;
    $l$loop_0: do {
      var freeSpace = resultLimit - resultPosition | 0;
      if (freeSpace <= 0 ? true : index >= lastCharIndex) {
        break $l$loop_0;
      }
      var tmp0 = index;
      index = tmp0 + 1 | 0;
      var character = charSequenceGet(text, tmp0);
      var tmp;
      if (!isHighSurrogate(character)) {
        // Inline function 'kotlin.code' call
        tmp = Char__toInt_impl_vasixd(character);
      } else {
        var tmp_0;
        if (index === lastCharIndex ? true : !isLowSurrogate(charSequenceGet(text, index))) {
          tmp_0 = 63;
        } else {
          var tmp1 = index;
          index = tmp1 + 1 | 0;
          tmp_0 = codePoint(character, charSequenceGet(text, tmp1));
        }
        tmp = tmp_0;
      }
      var codepoint = tmp;
      // Inline function 'io.ktor.utils.io.core.internal.charactersSize' call
      var tmp_1;
      if (1 <= codepoint ? codepoint <= 127 : false) {
        tmp_1 = 1;
      } else if (128 <= codepoint ? codepoint <= 2047 : false) {
        tmp_1 = 2;
      } else if (2048 <= codepoint ? codepoint <= 65535 : false) {
        tmp_1 = 3;
      } else if (65536 <= codepoint ? codepoint <= 1114111 : false) {
        tmp_1 = 4;
      } else {
        malformedCodePoint(codepoint);
      }
      if (tmp_1 > freeSpace) {
        index = index - 1 | 0;
        break $l$loop_0;
      }
      // Inline function 'io.ktor.utils.io.core.internal.putUtf8Char' call
      var offset = resultPosition;
      var tmp_2;
      if (0 <= codepoint ? codepoint <= 127 : false) {
        // Inline function 'io.ktor.utils.io.bits.Memory.storeAt' call
        var value = toByte(codepoint);
        _this__u8e3s4.c2e_1.setInt8(offset, value);
        tmp_2 = 1;
      } else if (128 <= codepoint ? codepoint <= 2047 : false) {
        // Inline function 'io.ktor.utils.io.bits.set' call
        var value_0 = toByte(192 | codepoint >> 6 & 31);
        _this__u8e3s4.c2e_1.setInt8(offset, value_0);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_0 = offset + 1 | 0;
        var value_1 = toByte(128 | codepoint & 63);
        _this__u8e3s4.c2e_1.setInt8(index_0, value_1);
        tmp_2 = 2;
      } else if (2048 <= codepoint ? codepoint <= 65535 : false) {
        // Inline function 'io.ktor.utils.io.bits.set' call
        var value_2 = toByte(224 | codepoint >> 12 & 15);
        _this__u8e3s4.c2e_1.setInt8(offset, value_2);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_1 = offset + 1 | 0;
        var value_3 = toByte(128 | codepoint >> 6 & 63);
        _this__u8e3s4.c2e_1.setInt8(index_1, value_3);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_2 = offset + 2 | 0;
        var value_4 = toByte(128 | codepoint & 63);
        _this__u8e3s4.c2e_1.setInt8(index_2, value_4);
        tmp_2 = 3;
      } else if (65536 <= codepoint ? codepoint <= 1114111 : false) {
        // Inline function 'io.ktor.utils.io.bits.set' call
        var value_5 = toByte(240 | codepoint >> 18 & 7);
        _this__u8e3s4.c2e_1.setInt8(offset, value_5);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_3 = offset + 1 | 0;
        var value_6 = toByte(128 | codepoint >> 12 & 63);
        _this__u8e3s4.c2e_1.setInt8(index_3, value_6);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_4 = offset + 2 | 0;
        var value_7 = toByte(128 | codepoint >> 6 & 63);
        _this__u8e3s4.c2e_1.setInt8(index_4, value_7);
        // Inline function 'io.ktor.utils.io.bits.set' call
        var index_5 = offset + 3 | 0;
        var value_8 = toByte(128 | codepoint & 63);
        _this__u8e3s4.c2e_1.setInt8(index_5, value_8);
        tmp_2 = 4;
      } else {
        malformedCodePoint(codepoint);
      }
      var size = tmp_2;
      resultPosition = resultPosition + size | 0;
    }
     while (true);
    // Inline function 'kotlin.toUShort' call
    var this_0 = index - from | 0;
    var tmp_3 = _UShort___init__impl__jigrne(toShort(this_0));
    // Inline function 'kotlin.toUShort' call
    var this_1 = resultPosition - dstOffset | 0;
    var tmp$ret$13 = _UShort___init__impl__jigrne(toShort(this_1));
    return _EncodeResult___init__impl__vkc0cy_0(tmp_3, tmp$ret$13);
  }
  function get_EmptyByteArray() {
    _init_properties_Unsafe_kt__orlvcq();
    return EmptyByteArray;
  }
  var EmptyByteArray;
  function completeReadHead(_this__u8e3s4, current) {
    _init_properties_Unsafe_kt__orlvcq();
    if (current === _this__u8e3s4)
      return Unit_instance;
    else {
      // Inline function 'io.ktor.utils.io.core.canRead' call
      if (!(current.d29_1 > current.c29_1)) {
        _this__u8e3s4.g2h(current);
      } else {
        // Inline function 'io.ktor.utils.io.core.Buffer.endGap' call
        var tmp = current.g29_1 - current.f29_1 | 0;
        if (tmp < 8) {
          _this__u8e3s4.h2h(current);
        } else {
          _this__u8e3s4.n2a_1 = current.c29_1;
        }
      }
    }
  }
  function prepareReadFirstHead(_this__u8e3s4, minSize) {
    _init_properties_Unsafe_kt__orlvcq();
    return _this__u8e3s4.e2h(minSize);
  }
  function prepareReadNextHead(_this__u8e3s4, current) {
    _init_properties_Unsafe_kt__orlvcq();
    if (current === _this__u8e3s4) {
      return _this__u8e3s4.g2b() ? _this__u8e3s4 : null;
    }
    return _this__u8e3s4.f2h(current);
  }
  function unsafeAppend(_this__u8e3s4, builder) {
    _init_properties_Unsafe_kt__orlvcq();
    var builderSize = builder.u();
    var tmp0_elvis_lhs = builder.c27();
    var tmp;
    if (tmp0_elvis_lhs == null) {
      return 0;
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var builderHead = tmp;
    if ((builderSize <= get_PACKET_MAX_COPY_SIZE() ? builderHead.t14() == null : false) ? _this__u8e3s4.z2g(builderHead) : false) {
      builder.l2g();
      return builderSize;
    }
    _this__u8e3s4.y2g(builderHead);
    return builderSize;
  }
  function prepareWriteHead(_this__u8e3s4, capacity, current) {
    _init_properties_Unsafe_kt__orlvcq();
    if (!(current == null)) {
      _this__u8e3s4.z2d();
    }
    return _this__u8e3s4.k2g(capacity);
  }
  var properties_initialized_Unsafe_kt_o5mw48;
  function _init_properties_Unsafe_kt__orlvcq() {
    if (!properties_initialized_Unsafe_kt_o5mw48) {
      properties_initialized_Unsafe_kt_o5mw48 = true;
      EmptyByteArray = new Int8Array(0);
    }
  }
  function trySuspend($this, sleepCondition, $completion) {
    var tmp = new $trySuspendCOROUTINE$53($this, sleepCondition, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  }
  function $sleepCOROUTINE$52(_this__u8e3s4, sleepCondition, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.p2i_1 = _this__u8e3s4;
    this.q2i_1 = sleepCondition;
  }
  protoOf($sleepCOROUTINE$52).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 3;
            this.hd_1 = 1;
            suspendResult = trySuspend(this.p2i_1, this.q2i_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            if (suspendResult) {
              return Unit_instance;
            } else {
              this.hd_1 = 2;
              continue $sm;
            }

          case 2:
            this.p2i_1.k26();
            return Unit_instance;
          case 3:
            throw this.kd_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 3) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function $trySuspendCOROUTINE$53(_this__u8e3s4, sleepCondition, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.d2i_1 = _this__u8e3s4;
    this.e2i_1 = sleepCondition;
  }
  protoOf($trySuspendCOROUTINE$53).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 3;
            this.f2i_1 = false;
            this.g2i_1 = Job_0();
            if (this.d2i_1.j26_1.atomicfu$compareAndSet(null, this.g2i_1) ? this.e2i_1() : false) {
              this.f2i_1 = true;
              this.hd_1 = 1;
              suspendResult = this.g2i_1.ir(this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.hd_1 = 2;
              continue $sm;
            }

          case 1:
            this.hd_1 = 2;
            continue $sm;
          case 2:
            return this.f2i_1;
          case 3:
            throw this.kd_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 3) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function AwaitingSlot() {
    this.j26_1 = atomic$ref$1(null);
  }
  protoOf(AwaitingSlot).f28 = function (sleepCondition, $completion) {
    var tmp = new $sleepCOROUTINE$52(this, sleepCondition, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  };
  protoOf(AwaitingSlot).k26 = function () {
    var tmp0_safe_receiver = this.j26_1.atomicfu$getAndSet(null);
    if (tmp0_safe_receiver == null)
      null;
    else
      tmp0_safe_receiver.jy();
  };
  protoOf(AwaitingSlot).d2d = function (cause) {
    var tmp0_elvis_lhs = this.j26_1.atomicfu$getAndSet(null);
    var tmp;
    if (tmp0_elvis_lhs == null) {
      return Unit_instance;
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var continuation = tmp;
    if (!(cause == null)) {
      continuation.iy(cause);
    } else {
      continuation.jy();
    }
  };
  function copyToSequentialImpl(_this__u8e3s4, dst, limit, $completion) {
    var tmp = new $copyToSequentialImplCOROUTINE$54(_this__u8e3s4, dst, limit, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  }
  function copyToTail(_this__u8e3s4, dst, limit, $completion) {
    var tmp = new $copyToTailCOROUTINE$55(_this__u8e3s4, dst, limit, $completion);
    tmp.jd_1 = Unit_instance;
    tmp.kd_1 = null;
    return tmp.ud();
  }
  function $copyToSequentialImplCOROUTINE$54(_this__u8e3s4, dst, limit, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.z2i_1 = _this__u8e3s4;
    this.a2j_1 = dst;
    this.b2j_1 = limit;
  }
  protoOf($copyToSequentialImplCOROUTINE$54).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 10;
            if (!!(this.z2i_1 === this.a2j_1)) {
              var message = 'Failed requirement.';
              throw IllegalArgumentException_init_$Create$(toString(message));
            }

            if (!(this.z2i_1.e27() == null)) {
              this.a2j_1.c1a(this.z2i_1.e27());
              return new Long(0, 0);
            }

            this.c2j_1 = this.b2j_1;
            this.hd_1 = 1;
            continue $sm;
          case 1:
            if (!(this.c2j_1.c7(new Long(0, 0)) > 0)) {
              this.hd_1 = 9;
              continue $sm;
            }

            this.hd_1 = 2;
            suspendResult = this.z2i_1.c2d(this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 2:
            this.d2j_1 = suspendResult;
            if (!this.d2j_1) {
              this.hd_1 = 9;
              continue $sm;
            } else {
              this.hd_1 = 3;
              continue $sm;
            }

          case 3:
            this.e2j_1 = this.z2i_1.e2d(this.a2j_1, this.c2j_1);
            if (this.e2j_1.equals(new Long(0, 0))) {
              this.hd_1 = 6;
              suspendResult = copyToTail(this.z2i_1, this.a2j_1, this.c2j_1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              if (this.a2j_1.t27() === 0) {
                this.hd_1 = 4;
                suspendResult = this.a2j_1.a29(1, this);
                if (suspendResult === get_COROUTINE_SUSPENDED()) {
                  return suspendResult;
                }
                continue $sm;
              } else {
                this.hd_1 = 5;
                continue $sm;
              }
            }

          case 4:
            this.hd_1 = 5;
            continue $sm;
          case 5:
            this.f2j_1 = this.e2j_1;
            this.hd_1 = 8;
            continue $sm;
          case 6:
            var tail = suspendResult;
            if (tail.equals(new Long(0, 0))) {
              this.hd_1 = 9;
              continue $sm;
            } else {
              this.hd_1 = 7;
              continue $sm;
            }

          case 7:
            this.f2j_1 = tail;
            this.hd_1 = 8;
            continue $sm;
          case 8:
            var copied = this.f2j_1;
            this.c2j_1 = this.c2j_1.mc(copied);
            if (copied.c7(new Long(0, 0)) > 0) {
              this.a2j_1.t6();
            }

            this.hd_1 = 1;
            continue $sm;
          case 9:
            return this.b2j_1.mc(this.c2j_1);
          case 10:
            throw this.kd_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 10) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function $copyToTailCOROUTINE$55(_this__u8e3s4, dst, limit, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.o2j_1 = _this__u8e3s4;
    this.p2j_1 = dst;
    this.q2j_1 = limit;
  }
  protoOf($copyToTailCOROUTINE$55).ud = function () {
    var suspendResult = this.jd_1;
    $sm: do
      try {
        var tmp = this.hd_1;
        switch (tmp) {
          case 0:
            this.id_1 = 9;
            this.r2j_1 = Companion_getInstance_4().t2c().z2f();
            this.hd_1 = 1;
            continue $sm;
          case 1:
            this.hd_1 = 2;
            continue $sm;
          case 2:
            this.id_1 = 8;
            this.r2j_1.m2e(coerceAtMost_0(this.q2j_1, toLong(this.r2j_1.g29_1)).mb());
            this.hd_1 = 3;
            suspendResult = this.o2j_1.z2c(this.r2j_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 3:
            this.t2j_1 = suspendResult;
            if (this.t2j_1 === -1) {
              this.r2j_1.c2g(Companion_getInstance_4().t2c());
              this.s2j_1 = new Long(0, 0);
              this.id_1 = 9;
              this.hd_1 = 6;
              continue $sm;
            } else {
              this.hd_1 = 4;
              continue $sm;
            }

          case 4:
            this.hd_1 = 5;
            suspendResult = this.p2j_1.v2c(this.r2j_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 5:
            this.s2j_1 = toLong(this.t2j_1);
            this.id_1 = 9;
            this.hd_1 = 6;
            var tmp_0 = this;
            continue $sm;
          case 6:
            var tmp_1 = this.s2j_1;
            this.id_1 = 9;
            this.r2j_1.c2g(Companion_getInstance_4().t2c());
            return tmp_1;
          case 7:
            this.id_1 = 9;
            this.r2j_1.c2g(Companion_getInstance_4().t2c());
            return Unit_instance;
          case 8:
            this.id_1 = 9;
            var t = this.kd_1;
            this.r2j_1.c2g(Companion_getInstance_4().t2c());
            throw t;
          case 9:
            throw this.kd_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.id_1 === 9) {
          throw e;
        } else {
          this.hd_1 = this.id_1;
          this.kd_1 = e;
        }
      }
     while (true);
  };
  function get_ByteArrayPool() {
    _init_properties_ByteArrayPool_kt__kfi3uj();
    return ByteArrayPool;
  }
  var ByteArrayPool;
  function ByteArrayPool$1() {
    DefaultPool.call(this, 128);
  }
  protoOf(ByteArrayPool$1).a2f = function () {
    return new Int8Array(4096);
  };
  var properties_initialized_ByteArrayPool_kt_td6pfh;
  function _init_properties_ByteArrayPool_kt__kfi3uj() {
    if (!properties_initialized_ByteArrayPool_kt_td6pfh) {
      properties_initialized_ByteArrayPool_kt_td6pfh = true;
      ByteArrayPool = new ByteArrayPool$1();
    }
  }
  function NoPoolImpl() {
  }
  protoOf(NoPoolImpl).a2g = function (instance) {
  };
  function ByteChannel(autoFlush) {
    autoFlush = autoFlush === VOID ? false : autoFlush;
    return new ByteChannelJS(Companion_getInstance_4().q2c_1, autoFlush);
  }
  function copyTo(_this__u8e3s4, dst, limit, $completion) {
    var tmp = _this__u8e3s4 instanceof ByteChannelSequentialBase ? _this__u8e3s4 : THROW_CCE();
    return copyToSequentialImpl(tmp, dst instanceof ByteChannelSequentialBase ? dst : THROW_CCE(), limit, $completion);
  }
  function ByteReadChannel_0(content, offset, length) {
    // Inline function 'kotlin.collections.isEmpty' call
    if (content.length === 0)
      return Companion_getInstance_5().b2e();
    var head = Companion_getInstance_4().t2c().z2f();
    var tail = head;
    var start = offset;
    var end = start + length | 0;
    $l$loop: while (true) {
      tail.j2e(8);
      // Inline function 'kotlin.comparisons.minOf' call
      var a = end - start | 0;
      // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
      var this_0 = tail;
      var b = this_0.f29_1 - this_0.d29_1 | 0;
      var size = Math.min(a, b);
      writeFully_0(tail instanceof Buffer ? tail : THROW_CCE(), content, start, size);
      start = start + size | 0;
      if (start === end)
        break $l$loop;
      var current = tail;
      tail = Companion_getInstance_4().t2c().z2f();
      current.k2h(tail);
    }
    // Inline function 'kotlin.apply' call
    var this_1 = new ByteChannelJS(head, false);
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.ByteReadChannel.<anonymous>' call
    close(this_1);
    return this_1;
  }
  function ByteChannelJS$attachJob$lambda(this$0) {
    return function (cause) {
      this$0.m2k_1 = null;
      var tmp;
      if (!(cause == null)) {
        this$0.jx(unwrapCancellationException(cause));
        tmp = Unit_instance;
      }
      return Unit_instance;
    };
  }
  function ByteChannelJS(initial, autoFlush) {
    ByteChannelSequentialBase.call(this, initial, autoFlush);
    this.m2k_1 = null;
  }
  protoOf(ByteChannelJS).g2d = function (job) {
    var tmp0_safe_receiver = this.m2k_1;
    if (tmp0_safe_receiver == null)
      null;
    else {
      tmp0_safe_receiver.mr();
    }
    this.m2k_1 = job;
    job.hr(true, VOID, ByteChannelJS$attachJob$lambda(this));
  };
  protoOf(ByteChannelJS).toString = function () {
    return 'ByteChannel[' + this.m2k_1 + ', ' + hashCode(this) + ']';
  };
  function ByteReadChannel$Companion$Empty$delegate$lambda() {
    // Inline function 'kotlin.apply' call
    var this_0 = new ByteChannelJS(Companion_getInstance_4().q2c_1, false);
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.Companion.Empty$delegate.<anonymous>.<anonymous>' call
    this_0.c1a(null);
    return this_0;
  }
  function Companion_3() {
    Companion_instance_3 = this;
    var tmp = this;
    tmp.x2j_1 = lazy(ByteReadChannel$Companion$Empty$delegate$lambda);
  }
  protoOf(Companion_3).b2e = function () {
    // Inline function 'kotlin.getValue' call
    var this_0 = this.x2j_1;
    Empty$factory();
    return this_0.t2();
  };
  var Companion_instance_3;
  function Companion_getInstance_5() {
    if (Companion_instance_3 == null)
      new Companion_3();
    return Companion_instance_3;
  }
  function ByteReadChannel_1() {
  }
  function Empty$factory() {
    return getPropertyCallableRef('Empty', 1, KProperty1, function (receiver) {
      return receiver.b2e();
    }, null);
  }
  function DefaultAllocator() {
  }
  protoOf(DefaultAllocator).b2f = function (size) {
    return new Memory(new DataView(new ArrayBuffer(size)));
  };
  protoOf(DefaultAllocator).d2f = function (instance) {
  };
  var DefaultAllocator_instance;
  function DefaultAllocator_getInstance() {
    return DefaultAllocator_instance;
  }
  function of(_this__u8e3s4, array, offset, length) {
    offset = offset === VOID ? 0 : offset;
    length = length === VOID ? array.length - offset | 0 : length;
    // Inline function 'kotlin.js.asDynamic' call
    var typedArray = array;
    return of_0(Companion_getInstance_6(), typedArray, offset, length);
  }
  function of_0(_this__u8e3s4, view, offset, length) {
    offset = offset === VOID ? 0 : offset;
    length = length === VOID ? view.byteLength : length;
    return of_1(Companion_getInstance_6(), view.buffer, view.byteOffset + offset | 0, length);
  }
  function of_1(_this__u8e3s4, buffer, offset, length) {
    offset = offset === VOID ? 0 : offset;
    length = length === VOID ? buffer.byteLength - offset | 0 : length;
    return new Memory(new DataView(buffer, offset, length));
  }
  function Companion_4() {
    Companion_instance_4 = this;
    this.l2h_1 = new Memory(new DataView(new ArrayBuffer(0)));
  }
  var Companion_instance_4;
  function Companion_getInstance_6() {
    if (Companion_instance_4 == null)
      new Companion_4();
    return Companion_instance_4;
  }
  function Memory(view) {
    Companion_getInstance_6();
    this.c2e_1 = view;
  }
  protoOf(Memory).n2k = function (offset, length) {
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(offset >= 0)) {
      // Inline function 'io.ktor.utils.io.bits.Memory.slice.<anonymous>' call
      var message = "offset shouldn't be negative: " + offset;
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(length >= 0)) {
      // Inline function 'io.ktor.utils.io.bits.Memory.slice.<anonymous>' call
      var message_0 = "length shouldn't be negative: " + length;
      throw IllegalArgumentException_init_$Create$(toString(message_0));
    }
    var tmp = toLong(offset + length | 0);
    // Inline function 'io.ktor.utils.io.bits.Memory.size' call
    var tmp$ret$2 = toLong(this.c2e_1.byteLength);
    if (tmp.c7(tmp$ret$2) > 0) {
      // Inline function 'io.ktor.utils.io.bits.Memory.size' call
      var tmp$ret$3 = toLong(this.c2e_1.byteLength);
      throw IndexOutOfBoundsException_init_$Create$('offset + length > size: ' + offset + ' + ' + length + ' > ' + tmp$ret$3.toString());
    }
    return new Memory(new DataView(this.c2e_1.buffer, this.c2e_1.byteOffset + offset | 0, length));
  };
  protoOf(Memory).u2e = function (destination, offset, length, destinationOffset) {
    var src = new Int8Array(this.c2e_1.buffer, this.c2e_1.byteOffset + offset | 0, length);
    var dst = new Int8Array(destination.c2e_1.buffer, destination.c2e_1.byteOffset + destinationOffset | 0, length);
    dst.set(src);
  };
  function copyTo_0(_this__u8e3s4, destination, offset, length, destinationOffset) {
    copyTo_2(_this__u8e3s4.buffer, destination, offset + _this__u8e3s4.byteOffset | 0, length, destinationOffset);
  }
  function copyTo_1(_this__u8e3s4, destination, offset, length, destinationOffset) {
    // Inline function 'kotlin.js.asDynamic' call
    var to = destination;
    var from = new Int8Array(_this__u8e3s4.c2e_1.buffer, _this__u8e3s4.c2e_1.byteOffset + offset | 0, length);
    to.set(from, destinationOffset);
  }
  function copyTo_2(_this__u8e3s4, destination, offset, length, destinationOffset) {
    var from = new Int8Array(_this__u8e3s4, offset, length);
    var to = new Int8Array(destination.c2e_1.buffer, destination.c2e_1.byteOffset + destinationOffset | 0, length);
    to.set(from, 0);
  }
  function Companion_5() {
  }
  protoOf(Companion_5).o2k = function (name) {
    switch (name) {
      case 'UTF-8':
      case 'utf-8':
      case 'UTF8':
      case 'utf8':
        return Charsets_getInstance().m2h_1;
    }
    var tmp;
    var tmp_0;
    var tmp_1;
    switch (name) {
      case 'ISO-8859-1':
      case 'iso-8859-1':
        tmp_1 = true;
        break;
      default:
        // Inline function 'kotlin.let' call

        // Inline function 'kotlin.contracts.contract' call

        // Inline function 'io.ktor.utils.io.charsets.Companion.forName.<anonymous>' call

        var it = replace(name, _Char___init__impl__6a9atx(95), _Char___init__impl__6a9atx(45));
        var tmp_2;
        if (it === 'iso-8859-1') {
          tmp_2 = true;
        } else {
          // Inline function 'kotlin.text.lowercase' call
          // Inline function 'kotlin.js.asDynamic' call
          tmp_2 = it.toLowerCase() === 'iso-8859-1';
        }

        tmp_1 = tmp_2;
        break;
    }
    if (tmp_1) {
      tmp_0 = true;
    } else {
      tmp_0 = name === 'latin1';
    }
    if (tmp_0) {
      tmp = true;
    } else {
      tmp = name === 'Latin1';
    }
    if (tmp) {
      return Charsets_getInstance().n2h_1;
    }
    throw IllegalArgumentException_init_$Create$('Charset ' + name + ' is not supported');
  };
  protoOf(Companion_5).p2k = function (charset) {
    var tmp;
    switch (charset) {
      case 'UTF-8':
      case 'utf-8':
      case 'UTF8':
      case 'utf8':
        tmp = true;
        break;
      default:
        var tmp_0;
        var tmp_1;
        switch (charset) {
          case 'ISO-8859-1':
          case 'iso-8859-1':
            tmp_1 = true;
            break;
          default:
            // Inline function 'kotlin.let' call

            // Inline function 'kotlin.contracts.contract' call

            // Inline function 'io.ktor.utils.io.charsets.Companion.isSupported.<anonymous>' call

            var it = replace(charset, _Char___init__impl__6a9atx(95), _Char___init__impl__6a9atx(45));
            var tmp_2;
            if (it === 'iso-8859-1') {
              tmp_2 = true;
            } else {
              // Inline function 'kotlin.text.lowercase' call
              // Inline function 'kotlin.js.asDynamic' call
              tmp_2 = it.toLowerCase() === 'iso-8859-1';
            }

            tmp_1 = tmp_2;
            break;
        }

        if (tmp_1) {
          tmp_0 = true;
        } else {
          tmp_0 = charset === 'latin1';
        }

        if (tmp_0) {
          tmp = true;
        } else {
          tmp = false;
        }

        break;
    }
    return tmp;
  };
  var Companion_instance_5;
  function Companion_getInstance_7() {
    return Companion_instance_5;
  }
  function Charset(_name) {
    this.o2h_1 = _name;
  }
  protoOf(Charset).equals = function (other) {
    if (this === other)
      return true;
    if (other == null ? true : !(this.constructor == other.constructor))
      return false;
    if (!(other instanceof Charset))
      THROW_CCE();
    if (!(this.o2h_1 === other.o2h_1))
      return false;
    return true;
  };
  protoOf(Charset).hashCode = function () {
    return getStringHashCode(this.o2h_1);
  };
  protoOf(Charset).toString = function () {
    return this.o2h_1;
  };
  function get_name(_this__u8e3s4) {
    return _this__u8e3s4.o2h_1;
  }
  function Charsets() {
    Charsets_instance = this;
    this.m2h_1 = new CharsetImpl('UTF-8');
    this.n2h_1 = new CharsetImpl('ISO-8859-1');
  }
  var Charsets_instance;
  function Charsets_getInstance() {
    if (Charsets_instance == null)
      new Charsets();
    return Charsets_instance;
  }
  function MalformedInputException(message) {
    extendThrowable(this, message);
    captureStack(this, MalformedInputException);
  }
  function CharsetDecoder(_charset) {
    this.q2k_1 = _charset;
  }
  function encodeToByteArray(_this__u8e3s4, input, fromIndex, toIndex) {
    fromIndex = fromIndex === VOID ? 0 : fromIndex;
    toIndex = toIndex === VOID ? charSequenceLength(input) : toIndex;
    return encodeToByteArrayImpl1(_this__u8e3s4, input, fromIndex, toIndex);
  }
  function CharsetEncoder(_charset) {
    this.r2k_1 = _charset;
  }
  function CharsetImpl(name) {
    Charset.call(this, name);
    this.t2k_1 = name;
  }
  protoOf(CharsetImpl).q2h = function () {
    return new CharsetEncoderImpl(this);
  };
  protoOf(CharsetImpl).p2h = function () {
    return new CharsetDecoderImpl(this);
  };
  protoOf(CharsetImpl).toString = function () {
    return 'CharsetImpl(name=' + this.t2k_1 + ')';
  };
  protoOf(CharsetImpl).hashCode = function () {
    return getStringHashCode(this.t2k_1);
  };
  protoOf(CharsetImpl).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof CharsetImpl))
      return false;
    var tmp0_other_with_cast = other instanceof CharsetImpl ? other : THROW_CCE();
    if (!(this.t2k_1 === tmp0_other_with_cast.t2k_1))
      return false;
    return true;
  };
  function encodeToByteArrayImpl1(_this__u8e3s4, input, fromIndex, toIndex) {
    fromIndex = fromIndex === VOID ? 0 : fromIndex;
    toIndex = toIndex === VOID ? charSequenceLength(input) : toIndex;
    var start = fromIndex;
    if (start >= toIndex)
      return get_EmptyByteArray();
    var single = Companion_getInstance_4().t2c().z2f();
    try {
      var rc = encodeImpl(_this__u8e3s4, input, start, toIndex, single);
      start = start + rc | 0;
      if (start === toIndex) {
        // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
        var tmp$ret$0 = single.d29_1 - single.c29_1 | 0;
        var result = new Int8Array(tmp$ret$0);
        // Inline function 'io.ktor.utils.io.core.readFully' call
        var length = result.length - 0 | 0;
        readFully(single instanceof Buffer ? single : THROW_CCE(), result, 0, length);
        return result;
      }
      var tmp$ret$1;
      $l$block: {
        // Inline function 'io.ktor.utils.io.core.buildPacket' call
        // Inline function 'kotlin.contracts.contract' call
        var builder = new BytePacketBuilder();
        try {
          // Inline function 'io.ktor.utils.io.charsets.encodeToByteArrayImpl1.<anonymous>' call
          builder.i2g(single.s2h());
          encodeToImpl(_this__u8e3s4, builder, input, start, toIndex);
          tmp$ret$1 = builder.f3();
          break $l$block;
        } catch ($p) {
          if ($p instanceof Error) {
            var t = $p;
            builder.qy();
            throw t;
          } else {
            throw $p;
          }
        }
      }
      return readBytes(tmp$ret$1);
    }finally {
      single.c2g(Companion_getInstance_4().t2c());
    }
  }
  function CharsetEncoderImpl(charset) {
    CharsetEncoder.call(this, charset);
    this.v2k_1 = charset;
  }
  protoOf(CharsetEncoderImpl).toString = function () {
    return 'CharsetEncoderImpl(charset=' + this.v2k_1 + ')';
  };
  protoOf(CharsetEncoderImpl).hashCode = function () {
    return this.v2k_1.hashCode();
  };
  protoOf(CharsetEncoderImpl).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof CharsetEncoderImpl))
      return false;
    var tmp0_other_with_cast = other instanceof CharsetEncoderImpl ? other : THROW_CCE();
    if (!this.v2k_1.equals(tmp0_other_with_cast.v2k_1))
      return false;
    return true;
  };
  function CharsetDecoderImpl(charset) {
    CharsetDecoder.call(this, charset);
    this.x2k_1 = charset;
  }
  protoOf(CharsetDecoderImpl).toString = function () {
    return 'CharsetDecoderImpl(charset=' + this.x2k_1 + ')';
  };
  protoOf(CharsetDecoderImpl).hashCode = function () {
    return this.x2k_1.hashCode();
  };
  protoOf(CharsetDecoderImpl).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof CharsetDecoderImpl))
      return false;
    var tmp0_other_with_cast = other instanceof CharsetDecoderImpl ? other : THROW_CCE();
    if (!this.x2k_1.equals(tmp0_other_with_cast.x2k_1))
      return false;
    return true;
  };
  function encodeImpl(_this__u8e3s4, input, fromIndex, toIndex, dst) {
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(fromIndex <= toIndex)) {
      // Inline function 'kotlin.require.<anonymous>' call
      var message = 'Failed requirement.';
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    if (get_charset(_this__u8e3s4).equals(Charsets_getInstance().n2h_1)) {
      return encodeISO88591(input, fromIndex, toIndex, dst);
    }
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(get_charset(_this__u8e3s4) === Charsets_getInstance().m2h_1)) {
      // Inline function 'io.ktor.utils.io.charsets.encodeImpl.<anonymous>' call
      var message_0 = 'Only UTF-8 encoding is supported in JS';
      throw IllegalArgumentException_init_$Create$(toString(message_0));
    }
    var encoder = new TextEncoder();
    var start = fromIndex;
    // Inline function 'io.ktor.utils.io.core.Buffer.writeRemaining' call
    var dstRemaining = dst.f29_1 - dst.d29_1 | 0;
    $l$loop: while (start < toIndex ? dstRemaining > 0 : false) {
      // Inline function 'kotlin.comparisons.minOf' call
      var a = toIndex - start | 0;
      var b = dstRemaining / 6 | 0;
      var tmp$ret$3 = Math.min(a, b);
      var numChars = coerceAtLeast(tmp$ret$3, 1);
      var dropLastChar = isHighSurrogate(charSequenceGet(input, (start + numChars | 0) - 1 | 0));
      var endIndexExclusive = (dropLastChar ? numChars === 1 : false) ? start + 2 | 0 : dropLastChar ? (start + numChars | 0) - 1 | 0 : start + numChars | 0;
      // Inline function 'kotlin.text.substring' call
      var startIndex = start;
      var tmp$ret$4 = toString(charSequenceSubSequence(input, startIndex, endIndexExclusive));
      var array1 = encoder.encode(tmp$ret$4);
      if (array1.length > dstRemaining)
        break $l$loop;
      writeFully_4(dst, array1);
      start = endIndexExclusive;
      dstRemaining = dstRemaining - array1.length | 0;
    }
    return start - fromIndex | 0;
  }
  function get_charset(_this__u8e3s4) {
    return _this__u8e3s4.r2k_1;
  }
  function decode_0(_this__u8e3s4, input, dst, max) {
    var decoder = Decoder(get_name(get_charset_0(_this__u8e3s4)), true);
    var charactersCopied = 0;
    $l$block: {
      // Inline function 'io.ktor.utils.io.core.takeWhileSize' call
      var release = true;
      var tmp0_elvis_lhs = prepareReadFirstHead(input, 1);
      var tmp;
      if (tmp0_elvis_lhs == null) {
        break $l$block;
      } else {
        tmp = tmp0_elvis_lhs;
      }
      var current = tmp;
      var size = 1;
      try {
        $l$loop: do {
          // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
          var this_0 = current;
          var before = this_0.d29_1 - this_0.c29_1 | 0;
          var after;
          if (before >= size) {
            try {
              var tmp$ret$3;
              $l$block_0: {
                // Inline function 'io.ktor.utils.io.charsets.decode.<anonymous>' call
                var buffer = current;
                var rem = max - charactersCopied | 0;
                // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
                var bufferSize = buffer.d29_1 - buffer.c29_1 | 0;
                if (rem < bufferSize) {
                  tmp$ret$3 = 0;
                  break $l$block_0;
                }
                // Inline function 'io.ktor.utils.io.core.readDirectInt8Array' call
                // Inline function 'kotlin.contracts.contract' call
                // Inline function 'io.ktor.utils.io.core.read' call
                // Inline function 'kotlin.contracts.contract' call
                // Inline function 'io.ktor.utils.io.core.readDirectInt8Array.<anonymous>' call
                var memory = buffer.b29_1;
                var start = buffer.c29_1;
                var endExclusive = buffer.d29_1;
                // Inline function 'io.ktor.utils.io.charsets.decode.<anonymous>.<anonymous>' call
                var view = new Int8Array(memory.c2e_1.buffer, memory.c2e_1.byteOffset + start | 0, endExclusive - start | 0);
                $l$block_2: {
                  // Inline function 'io.ktor.utils.io.js.decodeWrap' call
                  try {
                    // Inline function 'io.ktor.utils.io.charsets.decode.<anonymous>.<anonymous>.<anonymous>' call
                    var tmp$ret$4;
                    $l$block_1: {
                      // Inline function 'io.ktor.utils.io.js.decodeStream' call
                      // Inline function 'io.ktor.utils.io.js.decodeWrap' call
                      try {
                        tmp$ret$4 = decoder.y2k(view, decodeOptions(true));
                        break $l$block_1;
                      } catch ($p) {
                        if ($p instanceof Error) {
                          var t = $p;
                          var tmp0_elvis_lhs_0 = t.message;
                          throw new MalformedInputException('Failed to decode bytes: ' + (tmp0_elvis_lhs_0 == null ? 'no cause provided' : tmp0_elvis_lhs_0));
                        } else {
                          throw $p;
                        }
                      }
                    }
                    break $l$block_2;
                  } catch ($p) {
                    if ($p instanceof Error) {
                      var t_0 = $p;
                      var tmp0_elvis_lhs_1 = t_0.message;
                      throw new MalformedInputException('Failed to decode bytes: ' + (tmp0_elvis_lhs_1 == null ? 'no cause provided' : tmp0_elvis_lhs_1));
                    } else {
                      throw $p;
                    }
                  }
                }
                var decodedText = tmp$ret$4;
                dst.r8(decodedText);
                charactersCopied = charactersCopied + decodedText.length | 0;
                var rc = view.byteLength;
                buffer.d2e(rc);
                var tmp_0;
                if (charactersCopied === max) {
                  var tmp_1;
                  try {
                    tmp_1 = decoder.z2k();
                  } catch ($p) {
                    var tmp_2;
                    var _ = $p;
                    tmp_2 = '';
                    tmp_1 = tmp_2;
                  }
                  var tail = tmp_1;
                  // Inline function 'kotlin.text.isNotEmpty' call
                  if (charSequenceLength(tail) > 0) {
                    buffer.h2e(bufferSize);
                  }
                  tmp_0 = 0;
                } else if (charactersCopied < max) {
                  tmp_0 = get_MAX_CHARACTERS_SIZE_IN_BYTES();
                } else {
                  tmp_0 = 0;
                }
                tmp$ret$3 = tmp_0;
              }
              size = tmp$ret$3;
            }finally {
              // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
              var this_1 = current;
              after = this_1.d29_1 - this_1.c29_1 | 0;
            }
          } else {
            after = before;
          }
          release = false;
          var tmp_3;
          if (after === 0) {
            tmp_3 = prepareReadNextHead(input, current);
          } else {
            var tmp_4;
            if (after < size) {
              tmp_4 = true;
            } else {
              // Inline function 'io.ktor.utils.io.core.Buffer.endGap' call
              var this_2 = current;
              var tmp_5 = this_2.g29_1 - this_2.f29_1 | 0;
              tmp_4 = tmp_5 < 8;
            }
            if (tmp_4) {
              completeReadHead(input, current);
              tmp_3 = prepareReadFirstHead(input, size);
            } else {
              tmp_3 = current;
            }
          }
          var tmp1_elvis_lhs = tmp_3;
          var tmp_6;
          if (tmp1_elvis_lhs == null) {
            break $l$loop;
          } else {
            tmp_6 = tmp1_elvis_lhs;
          }
          var next = tmp_6;
          current = next;
          release = true;
        }
         while (size > 0);
      }finally {
        if (release) {
          completeReadHead(input, current);
        }
      }
    }
    if (charactersCopied < max) {
      var size_0 = 1;
      $l$block_3: {
        // Inline function 'io.ktor.utils.io.core.takeWhileSize' call
        var release_0 = true;
        var tmp0_elvis_lhs_2 = prepareReadFirstHead(input, 1);
        var tmp_7;
        if (tmp0_elvis_lhs_2 == null) {
          break $l$block_3;
        } else {
          tmp_7 = tmp0_elvis_lhs_2;
        }
        var current_0 = tmp_7;
        var size_1 = 1;
        try {
          $l$loop_0: do {
            // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
            var this_3 = current_0;
            var before_0 = this_3.d29_1 - this_3.c29_1 | 0;
            var after_0;
            if (before_0 >= size_1) {
              try {
                // Inline function 'io.ktor.utils.io.charsets.decode.<anonymous>' call
                // Inline function 'io.ktor.utils.io.core.readDirectInt8Array' call
                // Inline function 'kotlin.contracts.contract' call
                // Inline function 'io.ktor.utils.io.core.read' call
                var this_4 = current_0;
                // Inline function 'kotlin.contracts.contract' call
                // Inline function 'io.ktor.utils.io.core.readDirectInt8Array.<anonymous>' call
                var memory_0 = this_4.b29_1;
                var start_0 = this_4.c29_1;
                var endExclusive_0 = this_4.d29_1;
                // Inline function 'io.ktor.utils.io.charsets.decode.<anonymous>.<anonymous>' call
                var view_0 = new Int8Array(memory_0.c2e_1.buffer, memory_0.c2e_1.byteOffset + start_0 | 0, endExclusive_0 - start_0 | 0);
                var result = decodeBufferImpl(view_0, decoder, max - charactersCopied | 0);
                dst.r8(result.a2l_1);
                charactersCopied = charactersCopied + result.a2l_1.length | 0;
                var rc_0 = result.b2l_1;
                this_4.d2e(rc_0);
                var rc_1 = rc_0;
                if (rc_1 > 0)
                  size_0 = 1;
                else if (size_0 === get_MAX_CHARACTERS_SIZE_IN_BYTES())
                  size_0 = 0;
                else {
                  size_0 = size_0 + 1 | 0;
                }
                size_1 = size_0;
              }finally {
                // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
                var this_5 = current_0;
                after_0 = this_5.d29_1 - this_5.c29_1 | 0;
              }
            } else {
              after_0 = before_0;
            }
            release_0 = false;
            var tmp_8;
            if (after_0 === 0) {
              tmp_8 = prepareReadNextHead(input, current_0);
            } else {
              var tmp_9;
              if (after_0 < size_1) {
                tmp_9 = true;
              } else {
                // Inline function 'io.ktor.utils.io.core.Buffer.endGap' call
                var this_6 = current_0;
                var tmp_10 = this_6.g29_1 - this_6.f29_1 | 0;
                tmp_9 = tmp_10 < 8;
              }
              if (tmp_9) {
                completeReadHead(input, current_0);
                tmp_8 = prepareReadFirstHead(input, size_1);
              } else {
                tmp_8 = current_0;
              }
            }
            var tmp1_elvis_lhs_0 = tmp_8;
            var tmp_11;
            if (tmp1_elvis_lhs_0 == null) {
              break $l$loop_0;
            } else {
              tmp_11 = tmp1_elvis_lhs_0;
            }
            var next_0 = tmp_11;
            current_0 = next_0;
            release_0 = true;
          }
           while (size_1 > 0);
        }finally {
          if (release_0) {
            completeReadHead(input, current_0);
          }
        }
      }
    }
    return charactersCopied;
  }
  function encodeComplete(_this__u8e3s4, dst) {
    return true;
  }
  function decodeExactBytes(_this__u8e3s4, input, inputLength) {
    if (inputLength === 0)
      return '';
    // Inline function 'io.ktor.utils.io.core.Input.headRemaining' call
    if ((input.o2a_1 - input.n2a_1 | 0) >= inputLength) {
      var decoder = Decoder(get_charset_0(_this__u8e3s4).o2h_1, true);
      var head = input.h2g();
      var view = input.m2a_1.c2e_1;
      var tmp$ret$2;
      $l$block: {
        // Inline function 'io.ktor.utils.io.js.decodeWrap' call
        try {
          // Inline function 'io.ktor.utils.io.charsets.decodeExactBytes.<anonymous>' call
          var subView = (head.c29_1 === 0 ? inputLength === view.byteLength : false) ? view : new DataView(view.buffer, view.byteOffset + head.c29_1 | 0, inputLength);
          tmp$ret$2 = decoder.c2l(subView);
          break $l$block;
        } catch ($p) {
          if ($p instanceof Error) {
            var t = $p;
            var tmp0_elvis_lhs = t.message;
            throw new MalformedInputException('Failed to decode bytes: ' + (tmp0_elvis_lhs == null ? 'no cause provided' : tmp0_elvis_lhs));
          } else {
            throw $p;
          }
        }
      }
      var text = tmp$ret$2;
      input.d2e(inputLength);
      return text;
    }
    return decodeExactBytesSlow(_this__u8e3s4, input, inputLength);
  }
  function get_charset_0(_this__u8e3s4) {
    return _this__u8e3s4.q2k_1;
  }
  function decodeExactBytesSlow(_this__u8e3s4, input, inputLength) {
    var decoder = Decoder(get_name(get_charset_0(_this__u8e3s4)), true);
    var inputRemaining = inputLength;
    var sb = StringBuilder_init_$Create$(inputLength);
    $l$block_4: {
      // Inline function 'io.ktor.utils.io.js.decodeWrap' call
      try {
        // Inline function 'io.ktor.utils.io.charsets.decodeExactBytesSlow.<anonymous>' call
        $l$block: {
          // Inline function 'io.ktor.utils.io.core.takeWhileSize' call
          var release = true;
          var tmp0_elvis_lhs = prepareReadFirstHead(input, 6);
          var tmp;
          if (tmp0_elvis_lhs == null) {
            break $l$block;
          } else {
            tmp = tmp0_elvis_lhs;
          }
          var current = tmp;
          var size = 6;
          try {
            $l$loop: do {
              // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
              var this_0 = current;
              var before = this_0.d29_1 - this_0.c29_1 | 0;
              var after;
              if (before >= size) {
                try {
                  // Inline function 'io.ktor.utils.io.charsets.decodeExactBytesSlow.<anonymous>.<anonymous>' call
                  var buffer = current;
                  // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
                  var chunkSize = buffer.d29_1 - buffer.c29_1 | 0;
                  // Inline function 'kotlin.comparisons.minOf' call
                  var b = inputRemaining;
                  var size_0 = Math.min(chunkSize, b);
                  var tmp_0;
                  if (buffer.c29_1 === 0 ? buffer.b29_1.c2e_1.byteLength === size_0 : false) {
                    var tmp$ret$4;
                    $l$block_0: {
                      // Inline function 'io.ktor.utils.io.js.decodeStream' call
                      var buffer_0 = buffer.b29_1.c2e_1;
                      // Inline function 'io.ktor.utils.io.js.decodeWrap' call
                      try {
                        tmp$ret$4 = decoder.y2k(buffer_0, decodeOptions(true));
                        break $l$block_0;
                      } catch ($p) {
                        if ($p instanceof Error) {
                          var t = $p;
                          var tmp0_elvis_lhs_0 = t.message;
                          throw new MalformedInputException('Failed to decode bytes: ' + (tmp0_elvis_lhs_0 == null ? 'no cause provided' : tmp0_elvis_lhs_0));
                        } else {
                          throw $p;
                        }
                      }
                    }
                    tmp_0 = tmp$ret$4;
                  } else {
                    var tmp$ret$6;
                    $l$block_1: {
                      // Inline function 'io.ktor.utils.io.js.decodeStream' call
                      var buffer_1 = new Int8Array(buffer.b29_1.c2e_1.buffer, buffer.b29_1.c2e_1.byteOffset + buffer.c29_1 | 0, size_0);
                      // Inline function 'io.ktor.utils.io.js.decodeWrap' call
                      try {
                        tmp$ret$6 = decoder.y2k(buffer_1, decodeOptions(true));
                        break $l$block_1;
                      } catch ($p) {
                        if ($p instanceof Error) {
                          var t_0 = $p;
                          var tmp0_elvis_lhs_1 = t_0.message;
                          throw new MalformedInputException('Failed to decode bytes: ' + (tmp0_elvis_lhs_1 == null ? 'no cause provided' : tmp0_elvis_lhs_1));
                        } else {
                          throw $p;
                        }
                      }
                    }
                    tmp_0 = tmp$ret$6;
                  }
                  var text = tmp_0;
                  sb.y5(text);
                  buffer.d2e(size_0);
                  inputRemaining = inputRemaining - size_0 | 0;
                  size = inputRemaining > 0 ? 6 : 0;
                }finally {
                  // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
                  var this_1 = current;
                  after = this_1.d29_1 - this_1.c29_1 | 0;
                }
              } else {
                after = before;
              }
              release = false;
              var tmp_1;
              if (after === 0) {
                tmp_1 = prepareReadNextHead(input, current);
              } else {
                var tmp_2;
                if (after < size) {
                  tmp_2 = true;
                } else {
                  // Inline function 'io.ktor.utils.io.core.Buffer.endGap' call
                  var this_2 = current;
                  var tmp_3 = this_2.g29_1 - this_2.f29_1 | 0;
                  tmp_2 = tmp_3 < 8;
                }
                if (tmp_2) {
                  completeReadHead(input, current);
                  tmp_1 = prepareReadFirstHead(input, size);
                } else {
                  tmp_1 = current;
                }
              }
              var tmp1_elvis_lhs = tmp_1;
              var tmp_4;
              if (tmp1_elvis_lhs == null) {
                break $l$loop;
              } else {
                tmp_4 = tmp1_elvis_lhs;
              }
              var next = tmp_4;
              current = next;
              release = true;
            }
             while (size > 0);
          }finally {
            if (release) {
              completeReadHead(input, current);
            }
          }
        }
        if (inputRemaining > 0) {
          $l$block_2: {
            // Inline function 'io.ktor.utils.io.core.takeWhile' call
            var release_0 = true;
            var tmp0_elvis_lhs_2 = prepareReadFirstHead(input, 1);
            var tmp_5;
            if (tmp0_elvis_lhs_2 == null) {
              break $l$block_2;
            } else {
              tmp_5 = tmp0_elvis_lhs_2;
            }
            var current_0 = tmp_5;
            try {
              $l$loop_1: do {
                // Inline function 'io.ktor.utils.io.charsets.decodeExactBytesSlow.<anonymous>.<anonymous>' call
                var buffer_2 = current_0;
                // Inline function 'io.ktor.utils.io.core.Buffer.readRemaining' call
                var chunkSize_0 = buffer_2.d29_1 - buffer_2.c29_1 | 0;
                // Inline function 'kotlin.comparisons.minOf' call
                var b_0 = inputRemaining;
                var size_1 = Math.min(chunkSize_0, b_0);
                var tmp_6;
                if (buffer_2.c29_1 === 0 ? buffer_2.b29_1.c2e_1.byteLength === size_1 : false) {
                  tmp_6 = decoder.c2l(buffer_2.b29_1.c2e_1);
                } else {
                  var tmp$ret$14;
                  $l$block_3: {
                    // Inline function 'io.ktor.utils.io.js.decodeStream' call
                    var buffer_3 = new Int8Array(buffer_2.b29_1.c2e_1.buffer, buffer_2.b29_1.c2e_1.byteOffset + buffer_2.c29_1 | 0, size_1);
                    // Inline function 'io.ktor.utils.io.js.decodeWrap' call
                    try {
                      tmp$ret$14 = decoder.y2k(buffer_3, decodeOptions(true));
                      break $l$block_3;
                    } catch ($p) {
                      if ($p instanceof Error) {
                        var t_1 = $p;
                        var tmp0_elvis_lhs_3 = t_1.message;
                        throw new MalformedInputException('Failed to decode bytes: ' + (tmp0_elvis_lhs_3 == null ? 'no cause provided' : tmp0_elvis_lhs_3));
                      } else {
                        throw $p;
                      }
                    }
                  }
                  tmp_6 = tmp$ret$14;
                }
                var text_0 = tmp_6;
                sb.y5(text_0);
                buffer_2.d2e(size_1);
                inputRemaining = inputRemaining - size_1 | 0;
                if (!true) {
                  break $l$loop_1;
                }
                release_0 = false;
                var tmp1_elvis_lhs_0 = prepareReadNextHead(input, current_0);
                var tmp_7;
                if (tmp1_elvis_lhs_0 == null) {
                  break $l$loop_1;
                } else {
                  tmp_7 = tmp1_elvis_lhs_0;
                }
                var next_0 = tmp_7;
                current_0 = next_0;
                release_0 = true;
              }
               while (true);
            }finally {
              if (release_0) {
                completeReadHead(input, current_0);
              }
            }
          }
        }
        sb.y5(decoder.z2k());
        break $l$block_4;
      } catch ($p) {
        if ($p instanceof Error) {
          var t_2 = $p;
          var tmp0_elvis_lhs_4 = t_2.message;
          throw new MalformedInputException('Failed to decode bytes: ' + (tmp0_elvis_lhs_4 == null ? 'no cause provided' : tmp0_elvis_lhs_4));
        } else {
          throw $p;
        }
      }
    }
    if (inputRemaining > 0) {
      throw new EOFException('Not enough bytes available: had only ' + (inputLength - inputRemaining | 0) + ' instead of ' + inputLength);
    }
    return sb.toString();
  }
  function get_MAX_CHARACTERS_SIZE_IN_BYTES() {
    return MAX_CHARACTERS_SIZE_IN_BYTES;
  }
  var MAX_CHARACTERS_SIZE_IN_BYTES;
  function DecodeBufferResult(charactersDecoded, bytesConsumed) {
    this.a2l_1 = charactersDecoded;
    this.b2l_1 = bytesConsumed;
  }
  protoOf(DecodeBufferResult).toString = function () {
    return 'DecodeBufferResult(charactersDecoded=' + this.a2l_1 + ', bytesConsumed=' + this.b2l_1 + ')';
  };
  protoOf(DecodeBufferResult).hashCode = function () {
    var result = getStringHashCode(this.a2l_1);
    result = imul(result, 31) + this.b2l_1 | 0;
    return result;
  };
  protoOf(DecodeBufferResult).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof DecodeBufferResult))
      return false;
    var tmp0_other_with_cast = other instanceof DecodeBufferResult ? other : THROW_CCE();
    if (!(this.a2l_1 === tmp0_other_with_cast.a2l_1))
      return false;
    if (!(this.b2l_1 === tmp0_other_with_cast.b2l_1))
      return false;
    return true;
  };
  function decodeBufferImpl(_this__u8e3s4, nativeDecoder, maxCharacters) {
    if (maxCharacters === 0) {
      return new DecodeBufferResult('', 0);
    }
    try {
      var sizeInBytes = coerceAtMost(maxCharacters, _this__u8e3s4.byteLength);
      var text = nativeDecoder.c2l(_this__u8e3s4.subarray(0, sizeInBytes));
      if (text.length <= maxCharacters) {
        return new DecodeBufferResult(text, sizeInBytes);
      }
    } catch ($p) {
      var _ = $p;
    }
    return decodeBufferImplSlow(_this__u8e3s4, nativeDecoder, maxCharacters);
  }
  function decodeBufferImplSlow(_this__u8e3s4, nativeDecoder, maxCharacters) {
    var maxBytes = coerceAtMost(maxCharacters >= 268435455 ? IntCompanionObject_instance.MAX_VALUE : imul(maxCharacters, 8), _this__u8e3s4.byteLength);
    var sizeInBytes = maxBytes;
    while (sizeInBytes > 8) {
      try {
        var text = nativeDecoder.c2l(_this__u8e3s4.subarray(0, sizeInBytes));
        if (text.length <= maxCharacters) {
          return new DecodeBufferResult(text, sizeInBytes);
        }
      } catch ($p) {
        var _ = $p;
      }
      sizeInBytes = sizeInBytes / 2 | 0;
    }
    sizeInBytes = 8;
    while (sizeInBytes > 0) {
      try {
        var text_0 = nativeDecoder.c2l(_this__u8e3s4.subarray(0, sizeInBytes));
        if (text_0.length <= maxCharacters) {
          return new DecodeBufferResult(text_0, sizeInBytes);
        }
      } catch ($p) {
        var __0 = $p;
      }
      sizeInBytes = sizeInBytes - 1 | 0;
    }
    $l$block: {
      // Inline function 'io.ktor.utils.io.js.decodeWrap' call
      try {
        // Inline function 'io.ktor.utils.io.charsets.decodeBufferImplSlow.<anonymous>' call
        nativeDecoder.c2l(_this__u8e3s4);
        break $l$block;
      } catch ($p) {
        if ($p instanceof Error) {
          var t = $p;
          var tmp0_elvis_lhs = t.message;
          throw new MalformedInputException('Failed to decode bytes: ' + (tmp0_elvis_lhs == null ? 'no cause provided' : tmp0_elvis_lhs));
        } else {
          throw $p;
        }
      }
    }
    throw new MalformedInputException('Unable to decode buffer');
  }
  function encodeISO88591(input, fromIndex, toIndex, dst) {
    if (fromIndex >= toIndex)
      return 0;
    // Inline function 'io.ktor.utils.io.core.writeDirect' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.write' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.writeDirect.<anonymous>' call
    var memory = dst.b29_1;
    var start = dst.d29_1;
    var endExclusive = dst.f29_1;
    // Inline function 'io.ktor.utils.io.charsets.encodeISO88591.<anonymous>' call
    var view = memory.n2k(start, endExclusive - start | 0).c2e_1;
    var i8 = new Int8Array(view.buffer, view.byteOffset, view.byteLength);
    var writeIndex = 0;
    var inductionVariable = fromIndex;
    if (inductionVariable < toIndex)
      do {
        var index = inductionVariable;
        inductionVariable = inductionVariable + 1 | 0;
        // Inline function 'kotlin.code' call
        var this_0 = charSequenceGet(input, index);
        var character = Char__toInt_impl_vasixd(this_0);
        if (character > 255) {
          failedToMapError(character);
        }
        // Inline function 'org.khronos.webgl.set' call
        var tmp1 = writeIndex;
        writeIndex = tmp1 + 1 | 0;
        // Inline function 'kotlin.js.asDynamic' call
        i8[tmp1] = toByte(character);
      }
       while (inductionVariable < toIndex);
    var rc = writeIndex;
    dst.e2e(rc);
    return toIndex - fromIndex | 0;
  }
  function failedToMapError(ch) {
    throw new MalformedInputException('The character with unicode point ' + ch + " couldn't be mapped to ISO-8859-1 character");
  }
  function writeFully_4(_this__u8e3s4, src, offset, length) {
    offset = offset === VOID ? 0 : offset;
    length = length === VOID ? src.byteLength - offset | 0 : length;
    // Inline function 'io.ktor.utils.io.core.write' call
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.core.writeFully.<anonymous>' call
    var memory = _this__u8e3s4.b29_1;
    var dstOffset = _this__u8e3s4.d29_1;
    if ((_this__u8e3s4.f29_1 - dstOffset | 0) < length) {
      throw new InsufficientSpaceException('Not enough free space to write ' + length + ' bytes');
    }
    copyTo_0(src, memory, offset, length, dstOffset);
    var rc = length;
    _this__u8e3s4.e2e(rc);
  }
  function get_PACKET_MAX_COPY_SIZE() {
    return PACKET_MAX_COPY_SIZE;
  }
  var PACKET_MAX_COPY_SIZE;
  function String_0(bytes, offset, length, charset) {
    offset = offset === VOID ? 0 : offset;
    length = length === VOID ? bytes.length : length;
    charset = charset === VOID ? Charsets_getInstance().m2h_1 : charset;
    if ((offset < 0 ? true : length < 0) ? true : (offset + length | 0) > bytes.length) {
      checkIndices(offset, length, bytes);
    }
    // Inline function 'kotlin.js.asDynamic' call
    var i8 = bytes;
    var bufferOffset = i8.byteOffset + offset | 0;
    var buffer = i8.buffer.slice(bufferOffset, bufferOffset + length | 0);
    var view = new ChunkBuffer(of_1(Companion_getInstance_6(), buffer), null, Companion_getInstance_4().r2c_1);
    view.k2e();
    var packet = ByteReadPacket_init_$Create$(view, Companion_getInstance_4().s2c_1);
    return decode(charset.p2h(), packet, IntCompanionObject_instance.MAX_VALUE);
  }
  function checkIndices(offset, length, bytes) {
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(offset >= 0)) {
      throw IndexOutOfBoundsException_init_$Create$('offset (' + offset + ") shouldn't be negative");
    }
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!(length >= 0)) {
      throw IndexOutOfBoundsException_init_$Create$('length (' + length + ") shouldn't be negative");
    }
    // Inline function 'kotlin.require' call
    // Inline function 'kotlin.contracts.contract' call
    if (!((offset + length | 0) <= bytes.length)) {
      throw IndexOutOfBoundsException_init_$Create$('offset (' + offset + ') + length (' + length + ') > bytes.size (' + bytes.length + ')');
    }
    throw IndexOutOfBoundsException_init_$Create$_0();
  }
  function EOFException(message) {
    IOException_init_$Init$(message, this);
    captureStack(this, EOFException);
  }
  function IOException_init_$Init$(message, $this) {
    IOException.call($this, message, null);
    return $this;
  }
  function IOException(message, cause) {
    Exception_init_$Init$_0(message, cause, this);
    captureStack(this, IOException);
  }
  function Decoder(encoding, fatal) {
    fatal = fatal === VOID ? true : fatal;
    var tmp;
    try {
      tmp = toKtor(new TextDecoder(encoding, textDecoderOptions(fatal)));
    } catch ($p) {
      var tmp_0;
      if ($p instanceof Error) {
        var cause = $p;
        tmp_0 = new TextDecoderFallback(encoding, fatal);
      } else {
        throw $p;
      }
      tmp = tmp_0;
    }
    return tmp;
  }
  function decodeOptions(stream) {
    // Inline function 'kotlin.apply' call
    var this_0 = new Object();
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.js.decodeOptions.<anonymous>' call
    // Inline function 'kotlin.with' call
    // Inline function 'kotlin.js.asDynamic' call
    // Inline function 'kotlin.contracts.contract' call
    this_0.stream = stream;
    return this_0;
  }
  function toKtor(_this__u8e3s4) {
    return new toKtor$1(_this__u8e3s4);
  }
  function textDecoderOptions(fatal) {
    fatal = fatal === VOID ? false : fatal;
    // Inline function 'kotlin.apply' call
    var this_0 = new Object();
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'io.ktor.utils.io.js.textDecoderOptions.<anonymous>' call
    // Inline function 'kotlin.with' call
    // Inline function 'kotlin.js.asDynamic' call
    // Inline function 'kotlin.contracts.contract' call
    this_0.fatal = fatal;
    return this_0;
  }
  function toKtor$1($this_toKtor) {
    this.d2l_1 = $this_toKtor;
  }
  protoOf(toKtor$1).z2k = function () {
    return this.d2l_1.decode();
  };
  protoOf(toKtor$1).c2l = function (buffer) {
    return this.d2l_1.decode(buffer);
  };
  protoOf(toKtor$1).y2k = function (buffer, options) {
    return this.d2l_1.decode(buffer, options);
  };
  function get_ENCODING_ALIASES() {
    _init_properties_TextDecoderFallback_kt__nrrftl();
    return ENCODING_ALIASES;
  }
  var ENCODING_ALIASES;
  function get_REPLACEMENT() {
    _init_properties_TextDecoderFallback_kt__nrrftl();
    return REPLACEMENT;
  }
  var REPLACEMENT;
  function TextDecoderFallback(encoding, fatal) {
    this.e2l_1 = fatal;
    // Inline function 'kotlin.text.lowercase' call
    // Inline function 'kotlin.text.trim' call
    // Inline function 'kotlin.js.asDynamic' call
    var requestedEncoding = toString(trim(isCharSequence(encoding) ? encoding : THROW_CCE())).toLowerCase();
    // Inline function 'kotlin.check' call
    // Inline function 'kotlin.contracts.contract' call
    if (!get_ENCODING_ALIASES().a1(requestedEncoding)) {
      // Inline function 'io.ktor.utils.io.js.TextDecoderFallback.<anonymous>' call
      var message = encoding + ' is not supported.';
      throw IllegalStateException_init_$Create$(toString(message));
    }
  }
  protoOf(TextDecoderFallback).z2k = function () {
    return '';
  };
  protoOf(TextDecoderFallback).c2l = function (buffer) {
    var tmp$ret$3;
    $l$block: {
      // Inline function 'io.ktor.utils.io.core.buildPacket' call
      // Inline function 'kotlin.contracts.contract' call
      var builder = new BytePacketBuilder();
      try {
        // Inline function 'io.ktor.utils.io.js.TextDecoderFallback.decode.<anonymous>' call
        var bytes = buffer instanceof Int8Array ? buffer : THROW_CCE();
        var inductionVariable = 0;
        var last = bytes.length;
        if (inductionVariable < last)
          $l$loop: do {
            var index = inductionVariable;
            inductionVariable = inductionVariable + 1 | 0;
            // Inline function 'org.khronos.webgl.get' call
            // Inline function 'kotlin.js.asDynamic' call
            var byte = bytes[index];
            var point = toCodePoint(byte);
            if (point < 0) {
              // Inline function 'kotlin.check' call
              // Inline function 'kotlin.contracts.contract' call
              if (!!this.e2l_1) {
                // Inline function 'io.ktor.utils.io.js.TextDecoderFallback.decode.<anonymous>.<anonymous>' call
                var message = 'Invalid character: ' + point;
                throw IllegalStateException_init_$Create$(toString(message));
              }
              writeFully_3(builder, get_REPLACEMENT());
              continue $l$loop;
            }
            if (point > 255) {
              builder.s2e(toByte(point >> 8));
            }
            builder.s2e(toByte(point & 255));
          }
           while (inductionVariable < last);
        tmp$ret$3 = builder.f3();
        break $l$block;
      } catch ($p) {
        if ($p instanceof Error) {
          var t = $p;
          builder.qy();
          throw t;
        } else {
          throw $p;
        }
      }
    }
    return decodeToString(readBytes(tmp$ret$3));
  };
  protoOf(TextDecoderFallback).y2k = function (buffer, options) {
    return this.c2l(buffer);
  };
  function toCodePoint(_this__u8e3s4) {
    _init_properties_TextDecoderFallback_kt__nrrftl();
    var value = _this__u8e3s4 & 255;
    if (isASCII(value)) {
      return value;
    }
    return get_WIN1252_TABLE()[value - 128 | 0];
  }
  function isASCII(_this__u8e3s4) {
    _init_properties_TextDecoderFallback_kt__nrrftl();
    return 0 <= _this__u8e3s4 ? _this__u8e3s4 <= 127 : false;
  }
  var properties_initialized_TextDecoderFallback_kt_7y92ax;
  function _init_properties_TextDecoderFallback_kt__nrrftl() {
    if (!properties_initialized_TextDecoderFallback_kt_7y92ax) {
      properties_initialized_TextDecoderFallback_kt_7y92ax = true;
      ENCODING_ALIASES = setOf(['ansi_x3.4-1968', 'ascii', 'cp1252', 'cp819', 'csisolatin1', 'ibm819', 'iso-8859-1', 'iso-ir-100', 'iso8859-1', 'iso88591', 'iso_8859-1', 'iso_8859-1:1987', 'l1', 'latin1', 'us-ascii', 'windows-1252', 'x-cp1252']);
      // Inline function 'kotlin.byteArrayOf' call
      REPLACEMENT = new Int8Array([-17, -65, -67]);
    }
  }
  function get_WIN1252_TABLE() {
    _init_properties_Win1252Table_kt__tl0v64();
    return WIN1252_TABLE;
  }
  var WIN1252_TABLE;
  var properties_initialized_Win1252Table_kt_pkmjoq;
  function _init_properties_Win1252Table_kt__tl0v64() {
    if (!properties_initialized_Win1252Table_kt_pkmjoq) {
      properties_initialized_Win1252Table_kt_pkmjoq = true;
      // Inline function 'kotlin.intArrayOf' call
      WIN1252_TABLE = new Int32Array([8364, -1, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, -1, 381, -1, -1, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, -1, 382, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255]);
    }
  }
  function DefaultPool(capacity) {
    this.e2f_1 = capacity;
    var tmp = this;
    // Inline function 'kotlin.arrayOfNulls' call
    var size = this.e2f_1;
    tmp.f2f_1 = fillArrayVal(Array(size), null);
    this.g2f_1 = 0;
  }
  protoOf(DefaultPool).h2f = function (instance) {
  };
  protoOf(DefaultPool).x2f = function (instance) {
    return instance;
  };
  protoOf(DefaultPool).u2f = function (instance) {
  };
  protoOf(DefaultPool).z2f = function () {
    if (this.g2f_1 === 0)
      return this.a2f();
    this.g2f_1 = this.g2f_1 - 1 | 0;
    var idx = this.g2f_1;
    var tmp = this.f2f_1[idx];
    var instance = !(tmp == null) ? tmp : THROW_CCE();
    this.f2f_1[idx] = null;
    return this.x2f(instance);
  };
  protoOf(DefaultPool).a2g = function (instance) {
    this.u2f(instance);
    if (this.g2f_1 === this.e2f_1) {
      this.h2f(instance);
    } else {
      var tmp1 = this.g2f_1;
      this.g2f_1 = tmp1 + 1 | 0;
      this.f2f_1[tmp1] = instance;
    }
  };
  //region block: post-declaration
  protoOf(ByteChannelSequentialBase).y2c = readRemaining$default;
  protoOf(ChannelJob).mr = cancel$default;
  protoOf(ChannelJob).hr = invokeOnCompletion$default;
  //endregion
  //region block: init
  Companion_instance = new Companion();
  DEFAULT_BUFFER_SIZE = 4096;
  Companion_instance_1 = new Companion_1();
  DefaultAllocator_instance = new DefaultAllocator();
  Companion_instance_5 = new Companion_5();
  MAX_CHARACTERS_SIZE_IN_BYTES = 8;
  PACKET_MAX_COPY_SIZE = 200;
  //endregion
  //region block: exports
  _.$_$ = _.$_$ || {};
  _.$_$.a = copyTo;
  _.$_$.b = readAvailable;
  _.$_$.c = writeFully;
  _.$_$.d = IOException_init_$Init$;
  _.$_$.e = Companion_instance_5;
  _.$_$.f = Charsets_getInstance;
  _.$_$.g = Companion_getInstance_5;
  _.$_$.h = MalformedInputException;
  _.$_$.i = decode;
  _.$_$.j = encodeToByteArray;
  _.$_$.k = encode;
  _.$_$.l = get_name;
  _.$_$.m = completeReadHead;
  _.$_$.n = prepareReadFirstHead;
  _.$_$.o = prepareReadNextHead;
  _.$_$.p = BytePacketBuilder;
  _.$_$.q = ByteReadPacket;
  _.$_$.r = Input;
  _.$_$.s = String_0;
  _.$_$.t = discard;
  _.$_$.u = readAvailable_0;
  _.$_$.v = readBytes_0;
  _.$_$.w = readBytes;
  _.$_$.x = readShort_0;
  _.$_$.y = readText;
  _.$_$.z = writeFully_3;
  _.$_$.a1 = writeShort_0;
  _.$_$.b1 = writeText;
  _.$_$.c1 = IOException;
  _.$_$.d1 = get_ByteArrayPool;
  _.$_$.e1 = ByteReadChannel;
  _.$_$.f1 = ByteReadChannel_1;
  _.$_$.g1 = WriterScope;
  _.$_$.h1 = cancel;
  _.$_$.i1 = writer;
  //endregion
  return _;
}(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./kotlinx-atomicfu.js'), require('./kotlinx-coroutines-core.js')));

//# sourceMappingURL=ktor-ktor-io.js.map
