// File: /workspace/github_cpp_makefile_star2_O1/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, (%rsp)
movl $0x50, %edi
callq 0xb6f0
movq %rax, %rbx
movsd 0x5c117(%rip), %xmm0    # 0x69008
movsd 0x5c117(%rip), %xmm1    # 0x69010
movl $0xa, %esi
movl $0x1, %edx
movq %rax, %rdi
callq 0xdb04
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0xec48
leaq 0x5c249(%rip), %rsi     # 0x69168
leaq 0x4b8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0xf8ec
movq %r15, %rdi
movq %r12, %rsi
callq 0x1082b
leaq 0x5c22b(%rip), %rdi     # 0x6916f
movl $0xa, %edx
movq %rbx, %rsi
xorl %eax, %eax
callq 0xb080
movl $0xa, %esi
movq %rbx, %rdi
callq 0x119cb
leaq 0x5c21f(%rip), %rsi     # 0x69186
movl $0xa, %edx
movq %r15, %rdi
callq 0x100a4
leaq 0x5c211(%rip), %rsi     # 0x6918c
movl $0xa, %ecx
movq %r15, %rdi
movq %rbx, %rdx
callq 0x119f1
leaq 0x10(%rsp), %r13
movq $0xa, (%r13)
movl $0x50, %edi
callq 0xb6f0
leaq 0x8(%rsp), %rbp
movq %rax, (%rbp)
leaq 0x5c1e0(%rip), %r14     # 0x69192
movl $0xa, %edx
movq %r14, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xb080
movq (%r13), %rdx
leaq 0x5c1da(%rip), %rsi     # 0x691a9
movq %r15, %rdi
callq 0x100a4
movq (%rbp), %rdx
movq (%r13), %rcx
leaq 0x5c1c9(%rip), %r12     # 0x691af
movq %r15, %rdi
movq %r12, %rsi
callq 0x119fb
movq %r15, %rdi
callq 0xfa40
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x11a00
movq (%rbp), %rsi
movq (%r13), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0xb080
movq (%rbp), %rdi
movq %rbp, %r12
movq (%r13), %rsi
callq 0x119cb
movq 0x7ef6d(%rip), %rax     # 0x8bfa0
movq (%rax), %rdi
movq %rax, %rbp
leaq 0x5c032(%rip), %rsi     # 0x69072
leaq 0x5c16e(%rip), %rdx     # 0x691b5
xorl %eax, %eax
callq 0xb7a0
movq (%rbp), %r14
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10ace
leaq 0x5c6ec(%rip), %rsi     # 0x69751
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xb7a0
movq (%rbp), %rsi
movl $0xa, %edi
callq 0xb690
movq %r15, %rdi
callq 0xf9b1
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0xeca8
leaq 0x5c124(%rip), %rsi     # 0x691c0
movq %r15, %rdi
movq (%rsp), %rdx
callq 0xf8ec
movq %r15, %rdi
movq %r14, %rsi
callq 0x1082b
movl $0xa, %edx
leaq 0x5c0b0(%rip), %rdi     # 0x6916f
movq %rbx, %rsi
xorl %eax, %eax
callq 0xb080
movl $0xa, %esi
movq %rbx, %rdi
callq 0x119cb
movl $0xa, %edx
movq %r15, %rdi
leaq 0x5c0a1(%rip), %rsi     # 0x69186
callq 0x100a4
movl $0xa, %ecx
movq %r15, %rdi
leaq 0x5c093(%rip), %rsi     # 0x6918c
movq %rbx, %rdx
callq 0x119f1
movl $0x50, %edi
callq 0xb6f0
movq %rax, %rbp
movsd 0x5bf1a(%rip), %xmm0    # 0x69030
movl $0xa, %esi
movl $0x1, %edx
movq %rax, %rdi
movsd 0x5bee5(%rip), %xmm1    # 0x69010
callq 0xdb04
leaq 0x5c090(%rip), %rdi     # 0x691c7
movl $0xa, %edx
movq %rbp, %rsi
xorl %eax, %eax
callq 0xb080
movl $0xa, %esi
movq %rbp, %rdi
callq 0x119cb
leaq 0x5c084(%rip), %rsi     # 0x691de
movl $0xa, %edx
movq %r15, %rdi
callq 0x100a4
leaq 0x5c076(%rip), %rsi     # 0x691e4
movl $0xa, %ecx
movq %r15, %rdi
movq %rbp, %rdx
callq 0x119f1
movq (%r13), %r14
movq %r12, %r13
movq (%r12), %r12
leaq 0x5c05a(%rip), %rdi     # 0x691ea
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0xb080
movq %r12, %rdi
movq %r14, %rsi
callq 0x119cb
leaq 0x5c052(%rip), %rsi     # 0x69201
movq %r15, %rdi
movq %r14, %rdx
callq 0x100a4
leaq 0x5c046(%rip), %rsi     # 0x69207
movq %r15, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x119f1
movq %r15, %rdi
callq 0xfa40
movq 0x7edc2(%rip), %r12     # 0x8bfa0
movq (%r12), %rdi
leaq 0x5be89(%rip), %rsi     # 0x69072
leaq 0x5bfc5(%rip), %rdx     # 0x691b5
xorl %eax, %eax
callq 0xb7a0
movq (%r12), %r14
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10ace
movq %r14, %rdi
leaq 0x5c540(%rip), %rsi     # 0x69751
movq %rax, %rdx
xorl %eax, %eax
callq 0xb7a0
movq (%r12), %rsi
movl $0xa, %edi
callq 0xb690
movq %r15, %rdi
callq 0xf9b1
leaq 0x18(%rsp), %rdi
callq 0xecb0
movq %rbx, %rdi
callq 0xb650
movq %rbp, %rdi
callq 0xb650
movq (%r13), %rdi
callq 0xb650
addq $0x1068, %rsp           # imm = 0x1068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq