// File: /workspace/github_cpp_makefile_star2_O3/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 $0xc8, %rsp
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
movq 0x7cc6b(%rip), %r13     # 0x8bfa0
movq (%r13), %rdi
leaq 0x5a24f(%rip), %rsi     # 0x6958f
leaq 0x5a3d7(%rip), %rdx     # 0x6971e
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %rdi
leaq 0x5a3dc(%rip), %rsi     # 0x69737
movq %r12, %rdx
movq %r15, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %rsi
movl $0xa, %edi
callq 0xb690
leaq 0x5a29a(%rip), %rsi     # 0x6961a
movq %r12, %rdi
callq 0xb770
testl %eax, %eax
jne 0xf5be
leaq 0x8(%r14), %rdx
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r14)
addq $0x8, %rbx
movq %rbx, 0x8(%rsp)
leaq 0x5a296(%rip), %rsi     # 0x69642
movq %r15, %rdi
movq %rdx, 0x20(%rsp)
xorl %eax, %eax
callq 0xb4e0
cmpq $0x0, 0x8(%r14)
jle 0xf572
movq %r15, %rdi
movl $0x3a, %esi
callq 0xb1e0
movq %rax, %r12
leaq 0x18(%r14), %rax
movq %rax, 0x10(%rsp)
leaq 0x2a8(%r14), %rax
movq %rax, 0x18(%rsp)
xorl %ecx, %ecx
xorl %ebp, %ebp
movq %rbp, 0x28(%rsp)
incq %r12
leaq (%rcx,%rcx,4), %r13
movq 0x10(%rsp), %rax
movq %rcx, %rbx
leaq (%rax,%r13,8), %rdx
leaq 0x8(%rax,%r13,8), %r15
movq %r12, %rdi
leaq 0x5a231(%rip), %rsi     # 0x69647
movq %r15, %rcx
xorl %eax, %eax
callq 0xb4e0
movq %r12, %rdi
movl $0x3a, %esi
callq 0xb1e0
leaq 0x1(%rax), %rdi
movl $0x3a, %esi
callq 0xb1e0
movq %rax, 0x38(%rsp)
movq 0x7cb59(%rip), %r12     # 0x8bfa0
movq (%r12), %rdi
leaq 0x5a13d(%rip), %rsi     # 0x6958f
leaq 0x5a2c5(%rip), %rdx     # 0x6971e
xorl %eax, %eax
callq 0xb7a0
movq (%r12), %rdi
movl -0x8(%r15), %ecx
movq (%r15), %r8
leaq 0x5a1e9(%rip), %rsi     # 0x6965b
movq %rbx, 0x30(%rsp)
movq %rbx, %rdx
xorl %eax, %eax
callq 0xb7a0
movq (%r12), %rsi
movl $0xa, %edi
callq 0xb690
xorl %eax, %eax
movq %rax, 0x8(%r15)
movq %rax, 0x18(%r15)
movq 0x298(%r14), %rax
movl $0x0, %r15d
testq %rax, %rax
jle 0xf4eb
movq 0x10(%rsp), %rdx
movl (%rdx,%r13,8), %ecx
movq 0x8(%rdx,%r13,8), %rdx
movq 0x18(%rsp), %rsi
xorl %edi, %edi
xorl %r15d, %r15d
cmpl %ecx, -0x8(%rsi)
jne 0xf4df
cmpq %rdx, (%rsi)
jne 0xf4df
movq %rdi, 0x40(%rsp,%r15,8)
leaq 0x1(%r15), %r8
cmpq $0xe, %r15
movq %r8, %r15
jg 0xf4eb
incq %rdi
addq $0x20, %rsi
cmpq %rdi, %rax
jne 0xf4c3
movq %r14, %rbx
movq 0x8(%rsp), %rax
movq 0x28(%rsp), %r14
leaq (%rax,%r14), %rdi
leaq 0x5a13f(%rip), %rsi     # 0x69642
movq %r15, %rdx
xorl %eax, %eax
callq 0xb0d0
movslq %eax, %rbp
addq %r14, %rbp
testq %r15, %r15
jle 0xf554
xorl %r12d, %r12d
movq 0x8(%rsp), %r14
movq 0x40(%rsp,%r12,8), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0xf623
leaq (%r14,%rbp), %rdi
leaq 0x5a220(%rip), %rsi     # 0x6975b
movl %eax, %edx
movq %r13, %rcx
xorl %eax, %eax
callq 0xb0d0
cltq
addq %rax, %rbp
incq %r12
cmpq %r12, %r15
jne 0xf520
movq 0x30(%rsp), %rcx
incq %rcx
movq 0x20(%rsp), %rax
cmpq (%rax), %rcx
movq 0x38(%rsp), %r12
movq %rbx, %r14
jl 0xf3ef
movq 0x7ca27(%rip), %r14     # 0x8bfa0
movq (%r14), %rdi
leaq 0x5a00c(%rip), %rsi     # 0x6958f
leaq 0x5a194(%rip), %rdx     # 0x6971e
xorl %eax, %eax
callq 0xb7a0
movq (%r14), %rdi
leaq 0x5a1ca(%rip), %rsi     # 0x69765
movl $0x1, %ebp
movl $0x1, %edx
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0xb7a0
movq (%r14), %rsi
movl $0xa, %edi
callq 0xb690
movl %ebp, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq