// File: /workspace/github_cpp_makefile_star2_O3/mh0fm4[P]SCDC/test/units/redirect/redirect_cli.c
// Function: test_cache
void test_cache(const char *uri)
{
  redirect_call_t rc;

  rdint_t in_n0 = 10;
  double *in_v0 = malloc(in_n0 * sizeof(*in_v0));
  vector_init(in_v0, in_n0, 1, 1.0, NAN);

  redirect_cache_t rch;

  redirect_cache_create(&rch);

  redirect_call_create_scdc(&rc, "cache0", uri);

  redirect_call_set_cache_ptr(&rc, &rch);

  printf("in_v0: %p, in_n0: %" rdint_fmt "\n", in_v0, in_n0);
  redirect_call_print_param_array_double(in_v0, in_n0);
  redirect_call_put_input_conf_rdint(&rc, "in_n0", in_n0);
  redirect_call_put_input_param_array_double(&rc, "in_v0", in_v0, in_n0);

  rdint_t out_n = 10;
  double *out_v = malloc(out_n * sizeof(*out_v));
  printf("out_v: %p, out_n: %" rdint_fmt "\n", out_v, out_n);
  redirect_call_put_input_conf_rdint(&rc, "out_n", out_n);
  redirect_call_put_output_param_array_double(&rc, "out_v", out_v, out_n);

  redirect_call_execute(&rc);

  redirect_call_get_output_param_array_double(&rc, "out_v", &out_v, &out_n);
  printf("out_v: %p, out_n: %" rdint_fmt "\n", out_v, out_n);
  redirect_call_print_param_array_double(out_v, out_n);

  TRACE_F("result: '%s'", redirect_call_get_result_str(&rc, NULL, 0));

  redirect_call_destroy_scdc(&rc);

  redirect_cache_reset_params(&rch);

  redirect_call_create_scdc(&rc, "cache1", uri);

  redirect_call_set_cache_ptr(&rc, &rch);

  printf("in_v0: %p, in_n0: %" rdint_fmt "\n", in_v0, in_n0);
  redirect_call_print_param_array_double(in_v0, in_n0);
  redirect_call_put_input_conf_rdint(&rc, "in_n0", in_n0);
  redirect_call_put_input_param_array_double(&rc, "in_v0", in_v0, in_n0);

  rdint_t in_n1 = 10;
  double *in_v1 = malloc(in_n1 * sizeof(*in_v1));
  vector_init(in_v1, in_n1, 1, 2.0, NAN);

  printf("in_v1: %p, in_n1: %" rdint_fmt "\n", in_v1, in_n1);
  redirect_call_print_param_array_double(in_v1, in_n1);
  redirect_call_put_input_conf_rdint(&rc, "in_n1", in_n1);
  redirect_call_put_input_param_array_double(&rc, "in_v1", in_v1, in_n1);

  rdint_t in_n2 = out_n;
  double *in_v2 = out_v;
  printf("in_v2: %p, in_n2: %" rdint_fmt "\n", in_v2, in_n2);
  redirect_call_print_param_array_double(in_v2, in_n2);
  redirect_call_put_input_conf_rdint(&rc, "in_n2", in_n2);
  redirect_call_put_input_param_array_double(&rc, "in_v2", in_v2, in_n2);

  redirect_call_execute(&rc);

  TRACE_F("result: '%s'", redirect_call_get_result_str(&rc, NULL, 0));

  redirect_call_destroy_scdc(&rc);

  redirect_cache_destroy(&rch);

  free(in_v0);
  free(in_v1);
  free(out_v);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1068, %rsp           # imm = 0x1068
movq %rdi, %r14
movq %rdi, 0x8(%rsp)
movl $0x50, %edi
callq 0xb6f0
movq %rax, %rbx
movsd 0x5c1a6(%rip), %xmm0    # 0x69008
movsd 0x5c1a6(%rip), %xmm1    # 0x69010
movl $0xa, %esi
movl $0x1, %edx
movq %rax, %rdi
callq 0xda80
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0xec5c
leaq 0x5c2d8(%rip), %rsi     # 0x69168
leaq 0x4b8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0xf8fc
movq %r15, %rdi
movq %r12, %rsi
callq 0x107da
leaq 0x5c2ba(%rip), %rdi     # 0x6916f
movl $0xa, %edx
movq %rbx, %rsi
xorl %eax, %eax
callq 0xb080
movl $0xa, %esi
movq %rbx, %rdi
callq 0x11969
leaq 0x5c2ae(%rip), %rsi     # 0x69186
movl $0xa, %edx
movq %r15, %rdi
callq 0x10051
leaq 0x5c2a0(%rip), %rsi     # 0x6918c
movl $0xa, %ecx
movq %r15, %rdi
movq %rbx, %rdx
callq 0x1198f
leaq 0x10(%rsp), %rax
movq $0xa, (%rax)
movl $0x50, %edi
callq 0xb6f0
movq %rax, %r12
movq %rsp, %rbp
movq %rax, (%rbp)
leaq 0x5c26f(%rip), %r14     # 0x69192
movl $0xa, %edx
movq %r14, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xb080
leaq 0x5c26d(%rip), %rsi     # 0x691a9
movl $0xa, %edx
movq %r15, %rdi
callq 0x10051
leaq 0x5c25f(%rip), %r13     # 0x691af
movl $0xa, %ecx
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x11999
movq %r15, %rdi
callq 0xfa4a
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
leaq 0x10(%rsp), %r13
movq %r13, %rcx
callq 0x1199e
movq (%rbp), %rsi
movq (%r13), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0xb080
movq (%rbp), %rdi
movq (%r13), %rsi
movq %r13, %r12
callq 0x11969
movq 0x7eff6(%rip), %r13     # 0x8bfa0
movq (%r13), %rdi
leaq 0x5c0bd(%rip), %rsi     # 0x69072
leaq 0x5c1f9(%rip), %rdx     # 0x691b5
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %r14
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10a7d
leaq 0x5c797(%rip), %rsi     # 0x69771
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %rsi
movl $0xa, %edi
callq 0xb690
movq %r15, %rdi
callq 0xf9c1
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0xecbc
leaq 0x5c1af(%rip), %rsi     # 0x691c0
movq %r15, %rdi
movq 0x8(%rsp), %rdx
callq 0xf8fc
movq %r15, %rdi
movq %r14, %rsi
callq 0x107da
movl $0xa, %edx
leaq 0x5c13a(%rip), %rdi     # 0x6916f
movq %rbx, %rsi
xorl %eax, %eax
callq 0xb080
movl $0xa, %esi
movq %rbx, %rdi
callq 0x11969
movl $0xa, %edx
movq %r15, %rdi
leaq 0x5c12b(%rip), %rsi     # 0x69186
callq 0x10051
movl $0xa, %ecx
movq %r15, %rdi
leaq 0x5c11d(%rip), %rsi     # 0x6918c
movq %rbx, %rdx
callq 0x1198f
movl $0x50, %edi
callq 0xb6f0
movq %rax, %rbp
movsd 0x5bfa4(%rip), %xmm0    # 0x69030
movl $0xa, %esi
movl $0x1, %edx
movq %rax, %rdi
movsd 0x5bf6f(%rip), %xmm1    # 0x69010
callq 0xda80
leaq 0x5c11a(%rip), %rdi     # 0x691c7
movl $0xa, %edx
movq %rbp, %rsi
xorl %eax, %eax
callq 0xb080
movl $0xa, %esi
movq %rbp, %rdi
callq 0x11969
leaq 0x5c10e(%rip), %rsi     # 0x691de
movl $0xa, %edx
movq %r15, %rdi
callq 0x10051
leaq 0x5c100(%rip), %rsi     # 0x691e4
movl $0xa, %ecx
movq %r15, %rdi
movq %rbp, %rdx
callq 0x1198f
movq (%r12), %r14
movq %rsp, %rax
movq (%rax), %r12
leaq 0x5c0e5(%rip), %rdi     # 0x691ea
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0xb080
movq %r12, %rdi
movq %r14, %rsi
callq 0x11969
leaq 0x5c0dd(%rip), %rsi     # 0x69201
movq %r15, %rdi
movq %r14, %rdx
callq 0x10051
leaq 0x5c0d1(%rip), %rsi     # 0x69207
movq %r15, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x1198f
movq %r15, %rdi
callq 0xfa4a
movq (%r13), %rdi
leaq 0x5bf1b(%rip), %rsi     # 0x69072
leaq 0x5c057(%rip), %rdx     # 0x691b5
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %r14
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10a7d
movq %r14, %rdi
leaq 0x5c5f2(%rip), %rsi     # 0x69771
movq %rax, %rdx
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %rsi
movl $0xa, %edi
callq 0xb690
movq %r15, %rdi
callq 0xf9c1
leaq 0x18(%rsp), %rdi
callq 0xecc4
movq %rbx, %rdi
callq 0xb650
movq %rbp, %rdi
callq 0xb650
movq %rsp, %rax
movq (%rax), %rdi
callq 0xb650
addq $0x1068, %rsp           # imm = 0x1068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq