// File: /workspace/github_cpp_makefile_star2_O2/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, %r12
movq %rdi, 0x8(%rsp)
pushq $0x50
popq %r14
movq %r14, %rdi
callq 0xb720
movq %rax, %rbx
pushq $0xa
popq %r13
pushq $0x1
popq %rdx
movsd 0x43a61(%rip), %xmm0    # 0x50008
movsd 0x43a61(%rip), %xmm1    # 0x50010
movq %rax, %rdi
movq %r13, %rsi
callq 0xd144
leaq 0x18(%rsp), %rbp
movq %rbp, %rdi
callq 0xe17c
leaq 0x43b9a(%rip), %rsi     # 0x50168
leaq 0x4b8(%rsp), %r15
movq %r15, %rdi
movq %r12, %rdx
callq 0xed28
movq %r15, %rdi
movq %rbp, %rsi
callq 0xfac0
leaq 0x43b7c(%rip), %rdi     # 0x5016f
movq %rbx, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0xb070
movq %rbx, %rdi
movq %r13, %rsi
callq 0x109fb
leaq 0x43b74(%rip), %rsi     # 0x50186
movq %r15, %rdi
movq %r13, %rdx
callq 0xf486
leaq 0x43b68(%rip), %rsi     # 0x5018c
movq %r15, %rdi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x10a05
leaq 0x10(%rsp), %rax
movq $0xa, (%rax)
movq %r14, %rdi
callq 0xb720
movq %rax, %rbp
movq %rsp, %r12
movq %rax, (%r12)
leaq 0x43b3b(%rip), %rdi     # 0x50192
movq %rax, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0xb070
leaq 0x43b3e(%rip), %rsi     # 0x501a9
movq %r15, %rdi
movq %r13, %rdx
callq 0xf486
leaq 0x43b32(%rip), %r14     # 0x501af
movq %r15, %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x10a0f
movq %r15, %rdi
callq 0xee69
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %r14
movq %r12, %rdx
leaq 0x10(%rsp), %r12
movq %r12, %rcx
callq 0x10a14
movq (%r14), %rsi
movq (%r12), %rdx
leaq 0x43ad5(%rip), %rdi     # 0x50192
xorl %eax, %eax
callq 0xb070
movq (%r14), %rdi
movq (%r12), %rsi
callq 0x109fb
movq 0x688e1(%rip), %rbp     # 0x74fb8
movq (%rbp), %rdi
leaq 0x43990(%rip), %rsi     # 0x50072
leaq 0x43acc(%rip), %rdx     # 0x501b5
xorl %eax, %eax
callq 0xb7c0
movq (%rbp), %r14
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xfc63
leaq 0x4404a(%rip), %rsi     # 0x50751
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xb7c0
movq (%rbp), %rsi
pushq $0xa
popq %rdi
callq 0xb6b0
movq %r15, %rdi
callq 0xede5
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0xe1d5
leaq 0x43a84(%rip), %rsi     # 0x501c0
movq %r15, %rdi
movq 0x8(%rsp), %rdx
callq 0xed28
movq %r15, %rdi
movq %r14, %rsi
callq 0xfac0
leaq 0x43a14(%rip), %rdi     # 0x5016f
movq %rbx, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0xb070
movq %rbx, %rdi
movq %r13, %rsi
callq 0x109fb
movq %r15, %rdi
leaq 0x43a09(%rip), %rsi     # 0x50186
movq %r13, %rdx
callq 0xf486
movq %r15, %rdi
leaq 0x439fd(%rip), %rsi     # 0x5018c
movq %rbx, %rdx
movq %r13, %rcx
callq 0x10a05
pushq $0x50
popq %rdi
callq 0xb720
movq %rax, %r14
movsd 0x4387b(%rip), %xmm0    # 0x50028
movq %rax, %rdi
movq %r13, %rsi
pushq $0x1
popq %rdx
movsd 0x43852(%rip), %xmm1    # 0x50010
callq 0xd144
leaq 0x439fd(%rip), %rdi     # 0x501c7
movq %r14, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0xb070
movq %r14, %rdi
movq %r13, %rsi
callq 0x109fb
leaq 0x439f5(%rip), %rsi     # 0x501de
movq %r15, %rdi
movq %r13, %rdx
callq 0xf486
leaq 0x439e9(%rip), %rsi     # 0x501e4
movq %r15, %rdi
movq %r14, %rdx
movq %r13, %rcx
callq 0x10a05
movq (%r12), %r12
movq %rsp, %rax
movq (%rax), %r13
leaq 0x439d0(%rip), %rdi     # 0x501ea
movq %r13, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0xb070
movq %r13, %rdi
movq %r12, %rsi
callq 0x109fb
leaq 0x439c8(%rip), %rsi     # 0x50201
movq %r15, %rdi
movq %r12, %rdx
callq 0xf486
leaq 0x439bc(%rip), %rsi     # 0x50207
movq %r15, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0x10a05
movq %r15, %rdi
callq 0xee69
movq (%rbp), %rdi
leaq 0x43806(%rip), %rsi     # 0x50072
leaq 0x43942(%rip), %rdx     # 0x501b5
xorl %eax, %eax
callq 0xb7c0
movq (%rbp), %r12
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xfc63
movq %r12, %rdi
leaq 0x43ebd(%rip), %rsi     # 0x50751
movq %rax, %rdx
xorl %eax, %eax
callq 0xb7c0
movq (%rbp), %rsi
pushq $0xa
popq %rdi
callq 0xb6b0
movq %r15, %rdi
callq 0xede5
leaq 0x18(%rsp), %rdi
callq 0xe1dd
movq %rbx, %rdi
callq 0xb670
movq %r14, %rdi
callq 0xb670
movq %rsp, %rax
movq (%rax), %rdi
callq 0xb670
addq $0x1068, %rsp           # imm = 0x1068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq