// File: /workspace/github_cpp_makefile_star2_O3/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 0x50(%rsp), %r14
leaq 0x40(%rsp), %rdi
testq %rdx, %rdx
je 0x22226
movq %r14, (%rdi)
movq 0x30(%rbp), %rsi
addq %rsi, %rdx
callq 0xcd6e
jmp 0x2223c
movq %r14, (%rdi)
leaq 0x1a4b7(%rip), %rsi     # 0x3c6e7
leaq 0x1a4b2(%rip), %rdx     # 0x3c6e9
callq 0xefcc
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0xd0(%rsp), %rdi
callq 0x1f924
xorps %xmm0, %xmm0
leaq 0x100(%rsp), %rdx
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, (%rdx)
leaq 0x30(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
movl $0x1, %ecx
callq 0x1ca76
movq 0x110(%rsp), %rax
testq %rax, %rax
je 0x2229e
leaq 0x100(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x222b0
callq 0xef5c
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x222c7
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xa5d0
movq 0xe8(%rbp), %r15
movb (%r15), %al
leaq 0x40(%rsp), %r14
movb %al, (%r14)
movq 0x8(%r15), %rax
movq %rax, 0x8(%r14)
movq %r15, %rdi
callq 0xf13a
movb $0x0, (%r15)
movq $0x0, 0x8(%r15)
movq %r14, %rdi
callq 0xf13a
leaq 0x60(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq 0x10(%r15), %rcx
leaq 0x20(%r15), %rax
cmpq %rax, %rcx
je 0x22322
movq %rcx, 0x50(%rsp)
movq (%rax), %rcx
movq %rcx, 0x60(%rsp)
jmp 0x22328
movups (%rax), %xmm0
movups %xmm0, (%rdx)
movq 0x18(%r15), %rcx
leaq 0x80(%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 0x2236c
movq %rcx, 0x70(%rsp)
movq (%rax), %rcx
movq %rcx, 0x80(%rsp)
jmp 0x22372
movups (%rax), %xmm0
movups %xmm0, (%rdx)
movq 0x38(%r15), %rcx
leaq 0xa0(%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 0x223b9
movq %rcx, 0x90(%rsp)
movq (%rax), %rcx
movq %rcx, 0xa0(%rsp)
jmp 0x223bf
movups (%rax), %xmm0
movups %xmm0, (%rdx)
leaq 0xd8(%rbp), %rdi
movq 0x58(%r15), %rcx
leaq 0xb0(%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 0x2241e
movups 0x70(%r15), %xmm1
subq $-0x80, %r15
movups %xmm1, (%rdx)
movq %rax, 0xc0(%rsp)
movups %xmm0, (%r15)
callq 0x2406a
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1c1bd(%rip), %rsi     # 0x3e5f0
leaq 0x1c1cb(%rip), %rdx     # 0x3e605
movq %rsp, %rdi
callq 0xefcc
leaq 0x50(%rbp), %r12
movq %rsp, %rsi
movq %r12, %rdi
callq 0x24c78
movq %rax, %r15
leaq 0x58(%rbp), %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x2246e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
cmpq %rbx, %r15
je 0x22875
movq %rsp, %rdi
movq %r14, (%rdi)
leaq 0x1c16c(%rip), %rsi     # 0x3e5f0
leaq 0x1c17a(%rip), %rdx     # 0x3e605
callq 0xefcc
movq %rbp, 0x28(%rsp)
movq %rsp, %rsi
movq %r12, %rdi
callq 0x2409e
movq (%rax), %rbp
callq 0xa090
movl (%rax), %r15d
movq %rax, 0x20(%rsp)
movl $0x0, (%rax)
leaq 0x128(%rsp), %r14
movq %rbp, %rdi
movq %r14, %rsi
movl $0xa, %edx
callq 0xa860
cmpq %rbp, (%r14)
je 0x22992
movq %rax, %r13
movslq %r13d, %rax
cmpq %r13, %rax
leaq 0x10(%rsp), %r14
jne 0x2299e
movq 0x20(%rsp), %rax
movl (%rax), %eax
cmpl $0x22, %eax
je 0x2299e
testl %eax, %eax
movq 0x28(%rsp), %rbp
jne 0x2250c
movq 0x20(%rsp), %rax
movl %r15d, (%rax)
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x22522
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
testl %r13d, %r13d
jg 0x22875
movq %rsp, %rdi
movq %r14, (%rdi)
leaq 0x1c0ce(%rip), %rsi     # 0x3e606
leaq 0x1c0d8(%rip), %rdx     # 0x3e617
callq 0xefcc
movq %rsp, %rsi
movq %r12, %rdi
callq 0x24c78
movq %rax, %r13
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x22568
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
cmpq %rbx, %r13
je 0x225f9
xorl %edi, %edi
callq 0xa560
movq %rax, %r13
movq %rsp, %rdi
movq %r14, (%rdi)
leaq 0x1c07e(%rip), %rsi     # 0x3e606
leaq 0x1c088(%rip), %rdx     # 0x3e617
callq 0xefcc
movq %rsp, %rsi
movq %r12, %rdi
callq 0x2409e
movq 0x20(%rsp), %rbx
movq (%rax), %r14
movl (%rbx), %r15d
movl $0x0, (%rbx)
leaq 0x128(%rsp), %rbp
movq %r14, %rdi
movq %rbp, %rsi
movl $0xa, %edx
callq 0xa860
cmpq %r14, (%rbp)
je 0x229aa
movq %rax, %r12
movl (%rbx), %eax
testl %eax, %eax
leaq 0x10(%rsp), %rcx
je 0x226bc
cmpl $0x22, %eax
jne 0x226bf
leaq 0x1c03c(%rip), %rdi     # 0x3e630
callq 0xa8c0
movq %rsp, %rdi
movq %r14, (%rdi)
leaq 0x1c012(%rip), %rsi     # 0x3e618
leaq 0x1c016(%rip), %rdx     # 0x3e623
callq 0xefcc
movq %rsp, %rsi
movq %r12, %rdi
callq 0x24c78
movq %rax, %r13
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x22636
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
cmpq %rbx, %r13
je 0x22967
movq %rsp, %rdi
movq %r14, (%rdi)
leaq 0x1bfcc(%rip), %rsi     # 0x3e618
leaq 0x1bfd0(%rip), %rdx     # 0x3e623
callq 0xefcc
movq %rsp, %rsi
movq %r12, %rdi
callq 0x2409e
movq 0x20(%rsp), %rbx
movq (%rax), %r14
movl (%rbx), %ebp
movl $0x0, (%rbx)
leaq 0x128(%rsp), %r13
movq %r14, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0xa860
cmpq %r14, (%r13)
je 0x229b6
movq %rax, %r12
movl (%rbx), %eax
testl %eax, %eax
leaq 0x10(%rsp), %rcx
je 0x2296c
cmpl $0x22, %eax
jne 0x2296e
leaq 0x1bf79(%rip), %rdi     # 0x3e630
callq 0xa8c0
movl %r15d, (%rbx)
movq (%rsp), %rdi
cmpq %rcx, %rdi
je 0x226d5
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
subq %r13, %r12
imulq $0x3e8, %r12, %r12      # imm = 0x3E8
leaq 0xf0(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1bf32(%rip), %rsi     # 0x3e624
leaq 0x1bf31(%rip), %rdx     # 0x3e62a
leaq 0xe0(%rsp), %rdi
callq 0xefcc
movq %rsp, %rdi
leaq 0x30(%rsp), %r15
leaq 0xe0(%rsp), %rdx
movq %r15, %rsi
callq 0x2411a
leaq 0x128(%rsp), %r14
movq %r15, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r14)
movq $0x0, 0x18(%r14)
movq %r14, %rdi
callq 0x25014
movq %rsp, %rdi
movq %r14, %rsi
callq 0x2506c
movl %eax, %ebp
movq 0xe0(%rsp), %rdi
cmpq %r13, %rdi
je 0x2276b
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0xa5d0
testb %bpl, %bpl
jne 0x22816
leaq 0x1bea9(%rip), %rsi     # 0x3e624
leaq 0x30(%rsp), %rdi
callq 0xf994
movq %rsp, %rdi
movq %rax, %rsi
callq 0xfb96
leaq 0x1a090(%rip), %rsi     # 0x3c827
movq %rsp, %r14
movq %r14, %rdi
callq 0xa190
movl %eax, %ebp
movq (%r14), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x227be
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
testl %ebp, %ebp
jne 0x22816
movq 0x28(%rsp), %rax
movb $0x1, 0x80(%rax)
movq (%rax), %rdi
movq %rsp, %rcx
movq $0x0, 0x8(%rcx)
movq %rax, (%rcx)
leaq 0x77e(%rip), %rax       # 0x22f64
movq %rax, 0x18(%rcx)
leaq 0x783(%rip), %rax       # 0x22f74
movq %rax, 0x10(%rcx)
movq %r12, %rsi
xorl %edx, %edx
callq 0x258ca
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x22816
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x40(%rsp), %rsi
movq 0x28(%rsp), %rbp
movq %rbp, %rdi
callq 0x21584
movb $0x1, (%rax)
movq (%rbp), %rdi
movq %rsp, %rcx
movq $0x0, 0x8(%rcx)
movq %rbp, (%rcx)
leaq 0x756(%rip), %rdx       # 0x22f9a
movq %rdx, 0x18(%rcx)
leaq 0x757(%rip), %rdx       # 0x22fa6
movq %rdx, 0x10(%rcx)
movq %r12, %rsi
movq %rax, %rdx
callq 0x258ca
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x22875
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq %rbp, %rdi
callq 0x22b6e
leaq 0xb0(%rsp), %rbx
cmpq $0x0, 0xc0(%rsp)
je 0x2298d
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq *0xc8(%rsp)
movq 0xc0(%rsp), %rax
testq %rax, %rax
je 0x228bd
movq %rbx, %rdi
movq %rbx, %rsi
movl $0x3, %edx
callq *%rax
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x228e2
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0xa5d0
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x22904
movq 0x80(%rsp), %rsi
incq %rsi
callq 0xa5d0
leaq 0x48(%rsp), %rbx
movq 0x8(%rbx), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x22924
movq 0x60(%rsp), %rsi
incq %rsi
callq 0xa5d0
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0xf13a
movzbl (%r14), %esi
movq %rbx, %rdi
callq 0xf1dc
leaq 0x30(%rsp), %rdi
callq 0xf13a
leaq 0x38(%rsp), %rdi
movzbl -0x8(%rdi), %esi
callq 0xf1dc
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x226df
movl %ebp, (%rbx)
movq (%rsp), %rdi
cmpq %rcx, %rdi
je 0x226df
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
jmp 0x226df
callq 0xa240
leaq 0x1bc92(%rip), %rdi     # 0x3e62b
callq 0xa380
leaq 0x1bc86(%rip), %rdi     # 0x3e62b
callq 0xa8c0
leaq 0x1bc7f(%rip), %rdi     # 0x3e630
callq 0xa380
leaq 0x1bc73(%rip), %rdi     # 0x3e630
callq 0xa380
jmp 0x22af3
movq %rax, %rbx
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x22b51
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x22b51
jmp 0x22af3
jmp 0x22a94
jmp 0x22b4e
movq %rax, %rbx
movq 0x20(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x22b31
movq 0x20(%rsp), %rax
movl %ebp, (%rax)
jmp 0x22b31
jmp 0x22aa3
jmp 0x22b4e
jmp 0x22af3
jmp 0x22a94
jmp 0x22b4e
jmp 0x22b1c
movq %rax, %rbx
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x22b51
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x22b51
jmp 0x22af3
jmp 0x22b4e
jmp 0x22b4e
jmp 0x22a65
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
cmpq %r13, %rdi
je 0x22b51
movq 0xf0(%rsp), %rsi
jmp 0x22b44
jmp 0x22b4e
jmp 0x22aa3
jmp 0x22b4e
jmp 0x22af3
movq %rax, %rbx
jmp 0x22b31
jmp 0x22b4e
jmp 0x22af3
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
jne 0x22b3f
jmp 0x22b51
jmp 0x22b4e
movq %rax, %rbx
movq 0x110(%rsp), %rax
testq %rax, %rax
je 0x22adf
leaq 0x100(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x22afe
callq 0xef5c
jmp 0x22afe
movq %rax, %rdi
callq 0xd3a3
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x22b65
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xa5d0
jmp 0x22b65
movq %rax, %rbx
jmp 0x22b65
movq %rax, %rbx
movq 0x20(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x22b31
movq 0x20(%rsp), %rax
movl %r15d, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x22b51
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5d0
jmp 0x22b51
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x23fbc
leaq 0x30(%rsp), %rdi
callq 0xd47e
movq %rbx, %rdi
callq 0xaa30
nop