// File: mh0fm4[P]SCDC/test/units/dataprov_store/test_store.c
// Function: test_store
int test_store(const char *uri)
{
  char *cmd;
  scdc_dataset_t ds;
  scdc_dataset_input_t _ip, *ip = &_ip;
  scdc_dataset_output_t _op, *op = &_op;


  /* open dataset */
  ds = scdc_dataset_open(uri);
  if (ds == SCDC_DATASET_NULL)
  {
    printf("ERROR: open dataset failed!\n");
    goto do_return;

  } else printf("open dataset '%s': OK\n", uri);

  /* become admin */
  cmd = "cd ADMIN";
  if (scdc_dataset_cmd(ds, cmd, NULL, NULL) != SCDC_SUCCESS)
  {
    printf("ERROR: command '%s' failed!\n", cmd);
    goto do_return;

  } else printf("becoming admin with command '%s': OK\n", cmd);

#if 1
  /* remove store (do not care whether it fails or not) */
  cmd = "rm storage_demo";
  if (scdc_dataset_cmd(ds, cmd, NULL, NULL) != SCDC_SUCCESS)
  {
    printf("WARNING: command '%s' failed!\n", cmd);

  } else printf("removing store with command '%s': OK\n", cmd);
#endif

#if 1
  /* add store */
  cmd = "put storage_demo";
  if (scdc_dataset_cmd(ds, cmd, NULL, NULL) != SCDC_SUCCESS)
  {
    printf("ERROR: command '%s' failed!\n", cmd);
    goto do_return;

  } else printf("adding store with command '%s': OK\n", cmd);
#endif

  /* select store */
  cmd = "cd storage_demo";
  if (scdc_dataset_cmd(ds, cmd, NULL, NULL) != SCDC_SUCCESS)
  {
    printf("ERROR: command '%s' failed!\n", cmd);
    goto do_return;

  } else printf("selecting store with command '%s': OK\n", cmd);

  /* create input object to read from file */
  ip = scdc_dataset_input_create(ip, "file", INPUT_FILE);
  if (ip == NULL)
  {
    printf("ERROR: open input file failed!\n");
    goto do_return;
  }

  /* store data from input object to dataset */
  cmd = "put " TARGET;
  if (scdc_dataset_cmd(ds, cmd, ip, NULL) != SCDC_SUCCESS)
  {
    printf("ERROR: command '%s' failed!\n", cmd);
    goto do_return;

  } else printf("storing data with command '%s': OK\n", cmd);

  /* destroy input object */
  scdc_dataset_input_destroy(ip);

#if 1
  /* create output object to write to file */
  op = scdc_dataset_output_create(op, "file", OUTPUT_FILE);
  if (op == NULL)
  {
    printf("ERROR: open output file failed!\n");
    goto do_return;
  }

  /* retrieve data from dataset to output object */
  cmd = "get " TARGET;
  if (scdc_dataset_cmd(ds, cmd, NULL, op) != SCDC_SUCCESS)
  {
    printf("ERROR: command '%s' failed!\n", cmd);
    goto do_return;

  } else printf("retrieving data with command '%s': OK\n", cmd);

  /* destroy output object */
  scdc_dataset_output_destroy(op);
#endif

  /* info entry */
  cmd = "info " TARGET;
  if (scdc_dataset_cmd(ds, cmd, NULL, NULL) != SCDC_SUCCESS)
  {
    printf("ERROR: command '%s' failed!\n", cmd);
    goto do_return;

  } else printf("getting info with command '%s': OK\n", cmd);

  /* list store */
  cmd = "ls";
  if (scdc_dataset_cmd(ds, cmd, NULL, NULL) != SCDC_SUCCESS)
  {
    printf("ERROR: command '%s' failed!\n", cmd);
    goto do_return;

  } else printf("listing data with command '%s': OK\n", cmd);

  /* remove the data stored */
  cmd = "rm " TARGET;
  if (scdc_dataset_cmd(ds, cmd, NULL, NULL) != SCDC_SUCCESS)
  {
    printf("ERROR: command '%s' failed!\n", cmd);
    goto do_return;

  } else printf("removing data with command '%s': OK\n", cmd);

#if 1
  /* become admin */
  cmd = "cd ADMIN";
  if (scdc_dataset_cmd(ds, cmd, NULL, NULL) != SCDC_SUCCESS)
  {
    printf("ERROR: command '%s' failed!\n", cmd);
    goto do_return;

  } else printf("becoming admin with command '%s': OK\n", cmd);

  /* remove store (do not care whether it fails or not) */
  cmd = "rm storage_demo";
  if (scdc_dataset_cmd(ds, cmd, NULL, NULL) != SCDC_SUCCESS)
  {
    printf("WARNING: command '%s' failed!\n", cmd);

  } else printf("removing store with command '%s': OK\n", cmd);
#endif

  scdc_dataset_close(ds);

do_return:
  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0xd0(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x8(%rbp), %rdi
movb $0x0, %al
callq 0xef60
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xd82e
leaq 0x7b7e2(%rip), %rdi     # 0x89004
movb $0x0, %al
callq 0xcd00
jmp 0xdc41
movq -0x8(%rbp), %rsi
leaq 0x7b7e8(%rip), %rdi     # 0x89021
movb $0x0, %al
callq 0xcd00
leaq 0x7b7f1(%rip), %rax     # 0x89038
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
movb $0x0, %al
callq 0xfdf0
cmpq $0x1, %rax
je 0xd87e
movq -0x10(%rbp), %rsi
leaq 0x7b7cf(%rip), %rdi     # 0x89041
movb $0x0, %al
callq 0xcd00
jmp 0xdc41
movq -0x10(%rbp), %rsi
leaq 0x7b7d5(%rip), %rdi     # 0x8905e
movb $0x0, %al
callq 0xcd00
leaq 0x7b7ed(%rip), %rax     # 0x89084
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
movb $0x0, %al
callq 0xfdf0
cmpq $0x1, %rax
je 0xd8cb
movq -0x10(%rbp), %rsi
leaq 0x7b7d2(%rip), %rdi     # 0x89094
movb $0x0, %al
callq 0xcd00
jmp 0xd8dd
movq -0x10(%rbp), %rsi
leaq 0x7b7dd(%rip), %rdi     # 0x890b3
movb $0x0, %al
callq 0xcd00
leaq 0x7b7f5(%rip), %rax     # 0x890d9
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
movb $0x0, %al
callq 0xfdf0
cmpq $0x1, %rax
je 0xd91b
movq -0x10(%rbp), %rsi
leaq 0x7b732(%rip), %rdi     # 0x89041
movb $0x0, %al
callq 0xcd00
jmp 0xdc41
movq -0x10(%rbp), %rsi
leaq 0x7b7c4(%rip), %rdi     # 0x890ea
movb $0x0, %al
callq 0xcd00
leaq 0x7b7da(%rip), %rax     # 0x8910e
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
movb $0x0, %al
callq 0xfdf0
cmpq $0x1, %rax
je 0xd96b
movq -0x10(%rbp), %rsi
leaq 0x7b6e2(%rip), %rdi     # 0x89041
movb $0x0, %al
callq 0xcd00
jmp 0xdc41
movq -0x10(%rbp), %rsi
leaq 0x7b7a8(%rip), %rdi     # 0x8911e
movb $0x0, %al
callq 0xcd00
movq -0x78(%rbp), %rdi
leaq 0x7ce73(%rip), %rsi     # 0x8a7fb
leaq 0x7b7b6(%rip), %rdx     # 0x89145
movb $0x0, %al
callq 0x31530
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0xd9b4
leaq 0x7b7ab(%rip), %rdi     # 0x89153
movb $0x0, %al
callq 0xcd00
jmp 0xdc41
leaq 0x7b7b8(%rip), %rax     # 0x89173
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x78(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0xfdf0
cmpq $0x1, %rax
je 0xd9f3
movq -0x10(%rbp), %rsi
leaq 0x7b65a(%rip), %rdi     # 0x89041
movb $0x0, %al
callq 0xcd00
jmp 0xdc41
movq -0x10(%rbp), %rsi
leaq 0x7b784(%rip), %rdi     # 0x89182
movb $0x0, %al
callq 0xcd00
movq -0x78(%rbp), %rdi
callq 0x316b0
movq -0xd8(%rbp), %rdi
leaq 0x7cddf(%rip), %rsi     # 0x8a7fb
leaq 0x7b783(%rip), %rdx     # 0x891a6
movb $0x0, %al
callq 0x32b60
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0xd8(%rbp)
jne 0xda4e
leaq 0x7b773(%rip), %rdi     # 0x891b5
movb $0x0, %al
callq 0xcd00
jmp 0xdc41
leaq 0x7b781(%rip), %rax     # 0x891d6
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0xd8(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0xfdf0
cmpq $0x1, %rax
je 0xda90
movq -0x10(%rbp), %rsi
leaq 0x7b5bd(%rip), %rdi     # 0x89041
movb $0x0, %al
callq 0xcd00
jmp 0xdc41
movq -0x10(%rbp), %rsi
leaq 0x7b74a(%rip), %rdi     # 0x891e5
movb $0x0, %al
callq 0xcd00
movq -0xd8(%rbp), %rdi
callq 0x32c30
leaq 0x7b757(%rip), %rax     # 0x8920c
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
movb $0x0, %al
callq 0xfdf0
cmpq $0x1, %rax
je 0xdaec
movq -0x10(%rbp), %rsi
leaq 0x7b561(%rip), %rdi     # 0x89041
movb $0x0, %al
callq 0xcd00
jmp 0xdc41
movq -0x10(%rbp), %rsi
leaq 0x7b725(%rip), %rdi     # 0x8921c
movb $0x0, %al
callq 0xcd00
leaq 0x7c1eb(%rip), %rax     # 0x89cf0
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
movb $0x0, %al
callq 0xfdf0
cmpq $0x1, %rax
je 0xdb3c
movq -0x10(%rbp), %rsi
leaq 0x7b511(%rip), %rdi     # 0x89041
movb $0x0, %al
callq 0xcd00
jmp 0xdc41
movq -0x10(%rbp), %rsi
leaq 0x7b6f9(%rip), %rdi     # 0x89240
movb $0x0, %al
callq 0xcd00
leaq 0x7b70f(%rip), %rax     # 0x89264
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
movb $0x0, %al
callq 0xfdf0
cmpq $0x1, %rax
je 0xdb8c
movq -0x10(%rbp), %rsi
leaq 0x7b4c1(%rip), %rdi     # 0x89041
movb $0x0, %al
callq 0xcd00
jmp 0xdc41
movq -0x10(%rbp), %rsi
leaq 0x7b6db(%rip), %rdi     # 0x89272
movb $0x0, %al
callq 0xcd00
leaq 0x7b493(%rip), %rax     # 0x89038
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
movb $0x0, %al
callq 0xfdf0
cmpq $0x1, %rax
je 0xdbd9
movq -0x10(%rbp), %rsi
leaq 0x7b471(%rip), %rdi     # 0x89041
movb $0x0, %al
callq 0xcd00
jmp 0xdc41
movq -0x10(%rbp), %rsi
leaq 0x7b47a(%rip), %rdi     # 0x8905e
movb $0x0, %al
callq 0xcd00
leaq 0x7b492(%rip), %rax     # 0x89084
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
movb $0x0, %al
callq 0xfdf0
cmpq $0x1, %rax
je 0xdc26
movq -0x10(%rbp), %rsi
leaq 0x7b477(%rip), %rdi     # 0x89094
movb $0x0, %al
callq 0xcd00
jmp 0xdc38
movq -0x10(%rbp), %rsi
leaq 0x7b482(%rip), %rdi     # 0x890b3
movb $0x0, %al
callq 0xcd00
movq -0x18(%rbp), %rdi
callq 0xf030
movl $0x1, %eax
addq $0xe0, %rsp
popq %rbp
retq
nop