// File: /workspace/github_cpp_makefile_star2_O2/mh0fm4[P]SCDC/src/lib/redirect/redirect/redirect_cache.cc
// Function: redirect_cache_check_cmd
int redirect_cache_check_cmd(redirect_cache_t *rch, const char *cmd, const char *params, scdc_result_t *result)
{
  TRACE_F("cmd: '%s', params: '%s', result: %p", cmd, params, result);

  if (strcmp(cmd, "cache_check") != 0) return 0;

  redirect_cache_reset_params(rch);

  const char *s = params;
  char *r = SCDC_RESULT_STR(result);
  rdint_t r_size = 0;

  sscanf(s, "%" rdint_fmt ":", &rch->nparams);
  s = strchr(s, ':') + 1;
  rdint_t i, j;
  for (i = 0; i < rch->nparams; ++i)
  {
    sscanf(s, "t%d:s%" rdint_fmt ":", &rch->params[i].type, &rch->params[i].size);
    s = strchr(s, ':') + 1;
    s = strchr(s, ':') + 1;
    TRACE_F("param %" rdint_fmt ": type: %d, size: %" rdint_fmt, i, rch->params[i].type, rch->params[i].size);

    rch->params[i].buf = 0;
    rch->params[i].entry_index = 0;

    rdint_t entries[REDIRECT_CACHE_FIND_ENTRIES_MAX];
    rdint_t nentries = redirect_cache_find_entries(rch, rch->params[i].type, rch->params[i].size, entries);

    r_size += sprintf(r + r_size, "%" rdint_fmt ":", nentries);

    for (j = 0; j < nentries; ++j)
    {
      redirect_param_hash_t h = redirect_cache_get_entry_hash(rch, entries[j]);
      r_size += sprintf(r + r_size, "%" redirect_param_hash_fmt ":%" rdint_fmt ":", h, entries[j]);
    }
  }

  TRACE_F("return: %d, result: '%s'", 1, r);

  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
movq 0x667b0(%rip), %r13     # 0x74fb8
movq (%r13), %rdi
leaq 0x41d5c(%rip), %rsi     # 0x5056f
leaq 0x41ee4(%rip), %rdx     # 0x506fe
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xb7c0
movq (%r13), %rdi
leaq 0x41ee9(%rip), %rsi     # 0x50717
movq %r12, %rdx
movq %r15, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0xb7c0
movq (%r13), %rsi
pushq $0xa
popq %rdi
callq 0xb6b0
leaq 0x41da9(%rip), %rsi     # 0x505fa
movq %r12, %rdi
callq 0xb7a0
testl %eax, %eax
jne 0xea1f
leaq 0x8(%r14), %rdx
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r14)
addq $0x8, %rbx
leaq 0x41daa(%rip), %rsi     # 0x50622
movq %r15, %rdi
movq %rdx, 0x10(%rsp)
xorl %eax, %eax
callq 0xb510
pushq $0x3a
popq %rsi
movq %r15, %rdi
callq 0xb1e0
movq %rax, (%rsp)
leaq 0x18(%r14), %rax
movq %rax, 0x8(%rsp)
xorl %r15d, %r15d
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
cmpq (%rax), %r13
jge 0xe9dc
movq (%rsp), %r12
incq %r12
imulq $0x28, %r13, %rax
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax), %rdx
leaq (%rcx,%rax), %rbp
addq $0x8, %rbp
movq %r12, %rdi
leaq 0x41d4e(%rip), %rsi     # 0x50627
movq %rbp, %rcx
xorl %eax, %eax
callq 0xb510
movq %r12, %rdi
pushq $0x3a
popq %r12
movl %r12d, %esi
callq 0xb1e0
leaq 0x1(%rax), %rdi
movl %r12d, %esi
callq 0xb1e0
movq %rax, (%rsp)
movq 0x666af(%rip), %r12     # 0x74fb8
movq (%r12), %rdi
leaq 0x41c5b(%rip), %rsi     # 0x5056f
leaq 0x41de3(%rip), %rdx     # 0x506fe
xorl %eax, %eax
callq 0xb7c0
movq (%r12), %rdi
movl -0x8(%rbp), %ecx
movq (%rbp), %r8
leaq 0x41d07(%rip), %rsi     # 0x5063b
movq %r13, 0x18(%rsp)
movq %r13, %rdx
xorl %eax, %eax
callq 0xb7c0
movq (%r12), %rsi
pushq $0xa
popq %rdi
callq 0xb6b0
andq $0x0, 0x8(%rbp)
andq $0x0, 0x18(%rbp)
movl -0x8(%rbp), %esi
movq (%rbp), %rdx
movq %r14, %rdi
leaq 0x20(%rsp), %rcx
callq 0xea33
movq %rax, %rbp
leaq (%rbx,%r15), %rdi
leaq 0x41ca7(%rip), %rsi     # 0x50622
movq %rax, %rdx
xorl %eax, %eax
callq 0xb0c0
cltq
addq %rax, %r15
testq %rbp, %rbp
movl $0x0, %eax
cmovleq %rax, %rbp
xorl %r13d, %r13d
cmpq %r13, %rbp
je 0xe9cf
movq 0x20(%rsp,%r13,8), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0xea72
leaq (%rbx,%r15), %rdi
leaq 0x41d82(%rip), %rsi     # 0x5073b
movl %eax, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0xb0c0
cltq
addq %rax, %r15
incq %r13
jmp 0xe999
movq 0x18(%rsp), %r13
incq %r13
jmp 0xe8a5
movq 0x665d5(%rip), %r14     # 0x74fb8
movq (%r14), %rdi
leaq 0x41b82(%rip), %rsi     # 0x5056f
leaq 0x41d0a(%rip), %rdx     # 0x506fe
xorl %eax, %eax
callq 0xb7c0
movq (%r14), %rdi
leaq 0x41d40(%rip), %rsi     # 0x50745
pushq $0x1
popq %rbp
movl %ebp, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0xb7c0
movq (%r14), %rsi
pushq $0xa
popq %rdi
callq 0xb6b0
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq