// File: 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
movq %rsp, %rbp
subq $0x10b0, %rsp           # imm = 0x10B0
movq %rdi, -0x8(%rbp)
movq $0xa, -0xbc0(%rbp)
movq -0xbc0(%rbp), %rdi
shlq $0x3, %rdi
callq 0xc900
movq %rax, -0xbc8(%rbp)
movq -0xbc8(%rbp), %rdi
movq -0xbc0(%rbp), %rsi
movl $0x1, %edx
movsd 0x97294(%rip), %xmm0    # 0xa5010
movsd 0x97294(%rip), %xmm1    # 0xa5018
callq 0xedd0
leaq -0x1068(%rbp), %rdi
callq 0x10490
movq -0x8(%rbp), %rdx
leaq -0xbb8(%rbp), %rdi
leaq 0x973c1(%rip), %rsi     # 0xa5168
callq 0x118e0
leaq -0xbb8(%rbp), %rdi
leaq -0x1068(%rbp), %rsi
callq 0x133a0
movq -0xbc8(%rbp), %rsi
movq -0xbc0(%rbp), %rdx
leaq 0x9739b(%rip), %rdi     # 0xa516f
movb $0x0, %al
callq 0xcd30
movq -0xbc8(%rbp), %rdi
movq -0xbc0(%rbp), %rsi
callq 0x14d30
movq -0xbc0(%rbp), %rdx
leaq -0xbb8(%rbp), %rdi
leaq 0x97383(%rip), %rsi     # 0xa5186
callq 0x12550
movq -0xbc8(%rbp), %rdx
movq -0xbc0(%rbp), %rcx
leaq -0xbb8(%rbp), %rdi
leaq 0x97368(%rip), %rsi     # 0xa518c
callq 0x14d90
movq $0xa, -0x1070(%rbp)
movq -0x1070(%rbp), %rdi
shlq $0x3, %rdi
callq 0xc900
movq %rax, -0x1078(%rbp)
movq -0x1078(%rbp), %rsi
movq -0x1070(%rbp), %rdx
leaq 0x97332(%rip), %rdi     # 0xa5192
movb $0x0, %al
callq 0xcd30
movq -0x1070(%rbp), %rdx
leaq -0xbb8(%rbp), %rdi
leaq 0x9732d(%rip), %rsi     # 0xa51a9
callq 0x12550
movq -0x1078(%rbp), %rdx
movq -0x1070(%rbp), %rcx
leaq -0xbb8(%rbp), %rdi
leaq 0x97312(%rip), %rsi     # 0xa51af
callq 0x14e10
leaq -0xbb8(%rbp), %rdi
callq 0x11af0
leaq -0xbb8(%rbp), %rdi
leaq 0x972f3(%rip), %rsi     # 0xa51af
leaq -0x1078(%rbp), %rdx
leaq -0x1070(%rbp), %rcx
callq 0x14e50
movq -0x1078(%rbp), %rsi
movq -0x1070(%rbp), %rdx
leaq 0x972ae(%rip), %rdi     # 0xa5192
movb $0x0, %al
callq 0xcd30
movq -0x1078(%rbp), %rdi
movq -0x1070(%rbp), %rsi
callq 0x14d30
movq 0xc60ab(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x97163(%rip), %rsi     # 0xa5072
leaq 0x9729f(%rip), %rdx     # 0xa51b5
movb $0x0, %al
callq 0xc9a0
movq 0xc608c(%rip), %rax     # 0xd3fb0
movq (%rax), %rax
movq %rax, -0x10a0(%rbp)
leaq -0xbb8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x13700
movq -0x10a0(%rbp), %rdi
movq %rax, %rdx
leaq 0x97807(%rip), %rsi     # 0xa5759
movb $0x0, %al
callq 0xc9a0
movq 0xc6050(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x9793e(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
leaq -0xbb8(%rbp), %rdi
callq 0x11a50
leaq -0x1068(%rbp), %rdi
callq 0x10520
movq -0x8(%rbp), %rdx
leaq -0xbb8(%rbp), %rdi
leaq 0x97225(%rip), %rsi     # 0xa51c0
callq 0x118e0
leaq -0xbb8(%rbp), %rdi
leaq -0x1068(%rbp), %rsi
callq 0x133a0
movq -0xbc8(%rbp), %rsi
movq -0xbc0(%rbp), %rdx
leaq 0x971a7(%rip), %rdi     # 0xa516f
movb $0x0, %al
callq 0xcd30
movq -0xbc8(%rbp), %rdi
movq -0xbc0(%rbp), %rsi
callq 0x14d30
movq -0xbc0(%rbp), %rdx
leaq -0xbb8(%rbp), %rdi
leaq 0x9718f(%rip), %rsi     # 0xa5186
callq 0x12550
movq -0xbc8(%rbp), %rdx
movq -0xbc0(%rbp), %rcx
leaq -0xbb8(%rbp), %rdi
leaq 0x97174(%rip), %rsi     # 0xa518c
callq 0x14d90
movq $0xa, -0x1080(%rbp)
movq -0x1080(%rbp), %rdi
shlq $0x3, %rdi
callq 0xc900
movq %rax, -0x1088(%rbp)
movq -0x1088(%rbp), %rdi
movq -0x1080(%rbp), %rsi
movl $0x1, %edx
movsd 0x96fc6(%rip), %xmm0    # 0xa5020
movsd 0x96fb6(%rip), %xmm1    # 0xa5018
callq 0xedd0
movq -0x1088(%rbp), %rsi
movq -0x1080(%rbp), %rdx
leaq 0x9714b(%rip), %rdi     # 0xa51c7
movb $0x0, %al
callq 0xcd30
movq -0x1088(%rbp), %rdi
movq -0x1080(%rbp), %rsi
callq 0x14d30
movq -0x1080(%rbp), %rdx
leaq -0xbb8(%rbp), %rdi
leaq 0x97133(%rip), %rsi     # 0xa51de
callq 0x12550
movq -0x1088(%rbp), %rdx
movq -0x1080(%rbp), %rcx
leaq -0xbb8(%rbp), %rdi
leaq 0x97118(%rip), %rsi     # 0xa51e4
callq 0x14d90
movq -0x1070(%rbp), %rax
movq %rax, -0x1090(%rbp)
movq -0x1078(%rbp), %rax
movq %rax, -0x1098(%rbp)
movq -0x1098(%rbp), %rsi
movq -0x1090(%rbp), %rdx
leaq 0x970e8(%rip), %rdi     # 0xa51ea
movb $0x0, %al
callq 0xcd30
movq -0x1098(%rbp), %rdi
movq -0x1090(%rbp), %rsi
callq 0x14d30
movq -0x1090(%rbp), %rdx
leaq -0xbb8(%rbp), %rdi
leaq 0x970d0(%rip), %rsi     # 0xa5201
callq 0x12550
movq -0x1098(%rbp), %rdx
movq -0x1090(%rbp), %rcx
leaq -0xbb8(%rbp), %rdi
leaq 0x970b5(%rip), %rsi     # 0xa5207
callq 0x14d90
leaq -0xbb8(%rbp), %rdi
callq 0x11af0
movq 0xc5e46(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x96efe(%rip), %rsi     # 0xa5072
leaq 0x9703a(%rip), %rdx     # 0xa51b5
movb $0x0, %al
callq 0xc9a0
movq 0xc5e27(%rip), %rax     # 0xd3fb0
movq (%rax), %rax
movq %rax, -0x10a8(%rbp)
leaq -0xbb8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x13700
movq -0x10a8(%rbp), %rdi
movq %rax, %rdx
leaq 0x975a2(%rip), %rsi     # 0xa5759
movb $0x0, %al
callq 0xc9a0
movq 0xc5deb(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x976d9(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
leaq -0xbb8(%rbp), %rdi
callq 0x11a50
leaq -0x1068(%rbp), %rdi
callq 0x10550
movq -0xbc8(%rbp), %rdi
callq 0xc830
movq -0x1088(%rbp), %rdi
callq 0xc830
movq -0x1078(%rbp), %rdi
callq 0xc830
addq $0x10b0, %rsp           # imm = 0x10B0
popq %rbp
retq
nopl (%rax,%rax)