// File: /workspace/github_cpp_makefile_star2_O1/king1600[P]cordpp/src/http.cc
// Function: cordpp::RestClient::handle_response()
void RestClient::handle_response() {
  // if response.gzipped: response.body = ....
  const Json data = Json::parse(
    response.body.empty() ? "{}" : response.body);
  const RestTask task = std::move(tasks.front());
  std::map<std::string, std::string> &headers = response.headers;
  tasks.pop_front();

  // check if next request will be rate limited
  if (headers.find("X-RateLimit-Remaining") != headers.end()) {
    if (std::stoi(headers["X-RateLimit-Remaining"], nullptr, 10) < 1) {

      // get time to wait for rate limit
      long wait_time;
      if (headers.find("X-RateLimit-Reset") != headers.end()) {
        const long now = static_cast<const long>(std::time(nullptr));
        long reset = std::stol(headers["X-RateLimit-Reset"], nullptr, 10);
        wait_time = (reset - now) * 1000;
      } else if (headers.find("Retry-After") != headers.end()) {
        wait_time = std::stol(headers["Retry-After"], nullptr, 10);
      }

      // if global, limit global route
      if (data.find("global") != data.end()) {
        if (data["global"].get<std::string>() == "true") {
          global_route.rate_limited = true;
          service.call_later(wait_time, nullptr, [this](void *data) {
            flush_route(global_route);
          });
        }
      }

      // limit request route as well
      RestRoute &route = get_route(task.req);
      route.rate_limited = true;
      service.call_later(wait_time, &route, [this](void *data) {
        flush_route(*reinterpret_cast<RestRoute*>(data));
      });
    }
  }

  // start parsing again and perform callback with data
  parse_data();
  task.action(data);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, %rbp
movq 0x38(%rdi), %rdx
leaq 0x70(%rsp), %r14
leaq 0x60(%rsp), %rdi
testq %rdx, %rdx
je 0x22736
movq %r14, (%rdi)
movq 0x30(%rbp), %rsi
addq %rsi, %rdx
callq 0xcd56
jmp 0x2274c
movq %r14, (%rdi)
leaq 0x1af9f(%rip), %rsi     # 0x3d6df
leaq 0x1af9a(%rip), %rdx     # 0x3d6e1
callq 0xf09e
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
leaq 0xf0(%rsp), %rdi
callq 0x1fe7a
xorps %xmm0, %xmm0
leaq 0x120(%rsp), %rdx
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, (%rdx)
leaq 0x30(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
movl $0x1, %ecx
callq 0x1cef6
movq 0x130(%rsp), %rax
testq %rax, %rax
je 0x227ae
leaq 0x120(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x227c0
callq 0xf02e
movq 0x60(%rsp), %rdi
cmpq %r14, %rdi
je 0x227d7
movq 0x70(%rsp), %rsi
incq %rsi
callq 0xa5d0
movq 0xe8(%rbp), %r15
movb (%r15), %al
leaq 0x60(%rsp), %r14
movb %al, (%r14)
movq 0x8(%r15), %rax
movq %rax, 0x8(%r14)
movq %r15, %rdi
callq 0xf20e
movb $0x0, (%r15)
movq $0x0, 0x8(%r15)
movq %r14, %rdi
callq 0xf20e
leaq 0x80(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq 0x10(%r15), %rcx
leaq 0x20(%r15), %rax
cmpq %rax, %rcx
je 0x22838
movq %rcx, 0x70(%rsp)
movq (%rax), %rcx
movq %rcx, 0x80(%rsp)
jmp 0x2283e
movups (%rax), %xmm0
movups %xmm0, (%rdx)
movq 0x18(%r15), %rcx
leaq 0xa0(%rsp), %rdx
movq %rcx, -0x28(%rdx)
movq %rax, 0x10(%r15)
movq $0x0, 0x18(%r15)
movb $0x0, 0x20(%r15)
movq %rdx, -0x10(%rdx)
movq 0x30(%r15), %rcx
leaq 0x40(%r15), %rax
cmpq %rax, %rcx
je 0x22885
movq %rcx, 0x90(%rsp)
movq (%rax), %rcx
movq %rcx, 0xa0(%rsp)
jmp 0x2288b
movups (%rax), %xmm0
movups %xmm0, (%rdx)
movq 0x38(%r15), %rcx
leaq 0xc0(%rsp), %rdx
movq %rcx, -0x28(%rdx)
movq %rax, 0x30(%r15)
movq $0x0, 0x38(%r15)
movb $0x0, 0x40(%r15)
movq %rdx, -0x10(%rdx)
movq 0x50(%r15), %rcx
leaq 0x60(%r15), %rax
cmpq %rax, %rcx
je 0x228d2
movq %rcx, 0xb0(%rsp)
movq (%rax), %rcx
movq %rcx, 0xc0(%rsp)
jmp 0x228d8
movups (%rax), %xmm0
movups %xmm0, (%rdx)
leaq 0xd8(%rbp), %rdi
movq 0x58(%r15), %rcx
leaq 0xd0(%rsp), %rdx
movq %rcx, -0x18(%rdx)
movq %rax, 0x50(%r15)
xorl %eax, %eax
movq %rax, 0x58(%r15)
movb $0x0, 0x60(%r15)
movq %rax, 0x10(%rdx)
xorps %xmm0, %xmm0
movups %xmm0, (%rdx)
movq 0x88(%r15), %rax
movq %rax, 0x18(%rdx)
movq 0x80(%r15), %rax
testq %rax, %rax
je 0x22937
movups 0x70(%r15), %xmm1
subq $-0x80, %r15
movups %xmm1, (%rdx)
movq %rax, 0xe0(%rsp)
movups %xmm0, (%r15)
callq 0x245ba
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1ccd8(%rip), %rsi     # 0x3f624
leaq 0x1cce6(%rip), %rdx     # 0x3f639
movq %rsp, %rdi
callq 0xf09e
leaq 0x50(%rbp), %r12
movq %rsp, %rsi
movq %r12, %rdi
callq 0x251c8
movq %rax, %r15
leaq 0x58(%rbp), %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x22987
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
cmpq %rbx, %r15
je 0x22db2
movq %rsp, %rdi
movq %r14, (%rdi)
leaq 0x1cc87(%rip), %rsi     # 0x3f624
leaq 0x1cc95(%rip), %rdx     # 0x3f639
callq 0xf09e
movq %rbp, 0x28(%rsp)
movq %rsp, %rsi
movq %r12, %rdi
callq 0x245ee
movq (%rax), %rbp
callq 0xa090
movl (%rax), %r15d
movq %rax, 0x20(%rsp)
movl $0x0, (%rax)
leaq 0x40(%rsp), %r14
movq %rbp, %rdi
movq %r14, %rsi
movl $0xa, %edx
callq 0xa860
cmpq %rbp, (%r14)
je 0x22ed8
movq %rax, %r13
movslq %r13d, %rax
cmpq %r13, %rax
leaq 0x10(%rsp), %r14
jne 0x22ee4
movq 0x20(%rsp), %rax
movl (%rax), %eax
cmpl $0x22, %eax
je 0x22ee4
testl %eax, %eax
movq 0x28(%rsp), %rbp
jne 0x22a22
movq 0x20(%rsp), %rax
movl %r15d, (%rax)
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x22a38
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
testl %r13d, %r13d
jg 0x22db2
movq %rsp, %rdi
movq %r14, (%rdi)
leaq 0x1cbec(%rip), %rsi     # 0x3f63a
leaq 0x1cbf6(%rip), %rdx     # 0x3f64b
callq 0xf09e
movq %rsp, %rsi
movq %r12, %rdi
callq 0x251c8
movq %rax, %r13
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x22a7e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
cmpq %rbx, %r13
je 0x22b0c
xorl %edi, %edi
callq 0xa560
movq %rax, %r13
movq %rsp, %rdi
movq %r14, (%rdi)
leaq 0x1cb9c(%rip), %rsi     # 0x3f63a
leaq 0x1cba6(%rip), %rdx     # 0x3f64b
callq 0xf09e
movq %rsp, %rsi
movq %r12, %rdi
callq 0x245ee
movq 0x20(%rsp), %rbx
movq (%rax), %r14
movl (%rbx), %r15d
movl $0x0, (%rbx)
leaq 0x40(%rsp), %rbp
movq %r14, %rdi
movq %rbp, %rsi
movl $0xa, %edx
callq 0xa860
cmpq %r14, (%rbp)
je 0x22ef0
movq %rax, %r12
movl (%rbx), %eax
testl %eax, %eax
leaq 0x10(%rsp), %rcx
je 0x22bcc
cmpl $0x22, %eax
jne 0x22bcf
leaq 0x1cb5d(%rip), %rdi     # 0x3f664
callq 0xa8c0
movq %rsp, %rdi
movq %r14, (%rdi)
leaq 0x1cb33(%rip), %rsi     # 0x3f64c
leaq 0x1cb37(%rip), %rdx     # 0x3f657
callq 0xf09e
movq %rsp, %rsi
movq %r12, %rdi
callq 0x251c8
movq %rax, %r13
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x22b49
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
cmpq %rbx, %r13
je 0x22ead
movq %rsp, %rdi
movq %r14, (%rdi)
leaq 0x1caed(%rip), %rsi     # 0x3f64c
leaq 0x1caf1(%rip), %rdx     # 0x3f657
callq 0xf09e
movq %rsp, %rsi
movq %r12, %rdi
callq 0x245ee
movq 0x20(%rsp), %rbx
movq (%rax), %r14
movl (%rbx), %ebp
movl $0x0, (%rbx)
leaq 0x40(%rsp), %r13
movq %r14, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0xa860
cmpq %r14, (%r13)
je 0x22efc
movq %rax, %r12
movl (%rbx), %eax
testl %eax, %eax
leaq 0x10(%rsp), %rcx
je 0x22eb2
cmpl $0x22, %eax
jne 0x22eb4
leaq 0x1ca9d(%rip), %rdi     # 0x3f664
callq 0xa8c0
movl %r15d, (%rbx)
movq (%rsp), %rdi
cmpq %rcx, %rdi
je 0x22be5
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
subq %r13, %r12
imulq $0x3e8, %r12, %r12      # imm = 0x3E8
leaq 0x110(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1ca56(%rip), %rsi     # 0x3f658
leaq 0x1ca55(%rip), %rdx     # 0x3f65e
leaq 0x100(%rsp), %rdi
callq 0xf09e
movq %rsp, %rdi
leaq 0x30(%rsp), %r15
leaq 0x100(%rsp), %rdx
movq %r15, %rsi
callq 0x2466a
movq %r15, 0x40(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x48(%rsp)
movq $0x0, 0x58(%rsp)
movzbl 0x30(%rsp), %eax
cmpl $0x1, %eax
je 0x22c5a
cmpl $0x2, %eax
jne 0x22c61
leaq 0x50(%rsp), %rax
jmp 0x22c66
leaq 0x48(%rsp), %rax
jmp 0x22c66
leaq 0x58(%rsp), %rax
movq $0x0, (%rax)
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x255ac
movq %rsp, %rdi
movq %r14, %rsi
callq 0x25604
movl %eax, %ebp
movq 0x100(%rsp), %rdi
cmpq %r13, %rdi
je 0x22ca4
movq 0x110(%rsp), %rsi
incq %rsi
callq 0xa5d0
testb %bpl, %bpl
jne 0x22d51
leaq 0x1c9a4(%rip), %rsi     # 0x3f658
leaq 0x30(%rsp), %rdi
callq 0xfa62
movq %rsp, %rdi
movq %rax, %rsi
callq 0xfc46
leaq 0x1ab4f(%rip), %rsi     # 0x3d81f
movq %rsp, %r14
movq %r14, %rdi
callq 0xa190
movl %eax, %ebp
movq (%r14), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x22cf7
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
testl %ebp, %ebp
jne 0x22d51
movq 0x28(%rsp), %rax
movb $0x1, 0x80(%rax)
movq (%rax), %rdi
xorps %xmm0, %xmm0
movq %rsp, %rcx
movaps %xmm0, (%rcx)
movaps %xmm0, 0x10(%rcx)
movq %rax, (%rcx)
leaq 0x78d(%rip), %rax       # 0x234ae
movq %rax, 0x18(%rcx)
leaq 0x792(%rip), %rax       # 0x234be
movq %rax, 0x10(%rcx)
movq %r12, %rsi
xorl %edx, %edx
callq 0x25e52
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x22d51
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x60(%rsp), %rsi
movq 0x28(%rsp), %rbp
movq %rbp, %rdi
callq 0x21a80
movb $0x1, (%rax)
movq (%rbp), %rdi
xorps %xmm0, %xmm0
movq %rsp, %rcx
movaps %xmm0, (%rcx)
movaps %xmm0, 0x10(%rcx)
movq %rbp, (%rcx)
leaq 0x763(%rip), %rdx       # 0x234e4
movq %rdx, 0x18(%rcx)
leaq 0x764(%rip), %rdx       # 0x234f0
movq %rdx, 0x10(%rcx)
movq %r12, %rsi
movq %rax, %rdx
callq 0x25e52
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x22db2
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq %rbp, %rdi
callq 0x230b4
leaq 0xd0(%rsp), %rbx
cmpq $0x0, 0xe0(%rsp)
je 0x22ed3
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq *0xe8(%rsp)
movq 0xe0(%rsp), %rax
testq %rax, %rax
je 0x22dfa
movq %rbx, %rdi
movq %rbx, %rsi
movl $0x3, %edx
callq *%rax
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x22e1f
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0xa5d0
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x22e44
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0xa5d0
leaq 0x68(%rsp), %rbx
movq 0x8(%rbx), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x22e6a
movq 0x80(%rsp), %rsi
incq %rsi
callq 0xa5d0
leaq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0xf20e
movzbl (%r14), %esi
movq %rbx, %rdi
callq 0xf2b0
leaq 0x30(%rsp), %rdi
callq 0xf20e
leaq 0x38(%rsp), %rdi
movzbl -0x8(%rdi), %esi
callq 0xf2b0
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x22bef
movl %ebp, (%rbx)
movq (%rsp), %rdi
cmpq %rcx, %rdi
je 0x22bef
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
jmp 0x22bef
callq 0xa240
leaq 0x1c780(%rip), %rdi     # 0x3f65f
callq 0xa380
leaq 0x1c774(%rip), %rdi     # 0x3f65f
callq 0xa8c0
leaq 0x1c76d(%rip), %rdi     # 0x3f664
callq 0xa380
leaq 0x1c761(%rip), %rdi     # 0x3f664
callq 0xa380
jmp 0x23039
movq %rax, %rbx
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x23097
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x23097
jmp 0x23039
jmp 0x22fda
jmp 0x23094
movq %rax, %rbx
movq 0x20(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x23077
movq 0x20(%rsp), %rax
movl %ebp, (%rax)
jmp 0x23077
jmp 0x22fe9
jmp 0x23094
jmp 0x23039
jmp 0x22fda
jmp 0x23094
jmp 0x23062
movq %rax, %rbx
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x23097
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x23097
jmp 0x23039
jmp 0x23094
jmp 0x23094
jmp 0x22fab
movq %rax, %rbx
movq 0x100(%rsp), %rdi
cmpq %r13, %rdi
je 0x23097
movq 0x110(%rsp), %rsi
jmp 0x2308a
jmp 0x23094
jmp 0x22fe9
jmp 0x23094
jmp 0x23039
movq %rax, %rbx
jmp 0x23077
jmp 0x23094
jmp 0x23039
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
jne 0x23085
jmp 0x23097
jmp 0x23094
movq %rax, %rbx
movq 0x130(%rsp), %rax
testq %rax, %rax
je 0x23025
leaq 0x120(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x23044
callq 0xf02e
jmp 0x23044
movq %rax, %rdi
callq 0xd3bb
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r14, %rdi
je 0x230ab
movq 0x70(%rsp), %rsi
incq %rsi
callq 0xa5d0
jmp 0x230ab
movq %rax, %rbx
jmp 0x230ab
movq %rax, %rbx
movq 0x20(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x23077
movq 0x20(%rsp), %rax
movl %r15d, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x23097
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
jmp 0x23097
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x2450c
leaq 0x30(%rsp), %rdi
callq 0xd48e
movq %rbx, %rdi
callq 0xaa30
nop