// File: mh0fm4[P]SCDC/test/demos/convert/compC.c
// Function: compC_hook_dataset_cmd
static scdcint_t compC_hook_dataset_cmd(void *dataprov, void *dataset, const char *cmd, const char *params, scdc_dataset_input_t *input, scdc_dataset_output_t *output, scdc_result_t *result)
{
  TRACE_F("cmd: '%s', params: '%s'", cmd, params);

  char s[1024], uri_in[256], uri_out[256];

  char *c = strchr(params, ' ');
  strncpy(uri_in, params, c - params);
  strcpy(uri_out, c + 1);

  const char *file_in, *file_out;
  c = strrchr(uri_in, '/'); *c = '\0'; file_in = c + 1;
  c = strrchr(uri_out, '/'); *c = '\0'; file_out = c + 1;

  char temp_in[256], temp_out[256], temp_log[256];
  make_temp_file(temp_in, file_in);
  make_temp_file(temp_out, file_out);
  make_temp_file(temp_log, "gmsh.log");

  scdc_dataset_output_t _outp, *outp = &_outp;
  scdc_dataset_input_t _inp, *inp = &_inp;

  /* step C1: get from compS */
  sprintf(s, "%s get %s", uri_in, file_in);
  TRACE_F("cmd: '%s'", s);
  outp = scdc_dataset_output_create(outp, "file", temp_in);
  scdc_dataset_cmd(SCDC_DATASET_NULL, s, NULL, outp);
  scdc_dataset_output_destroy(outp);

  /* step C2: convert with gmsh */
  sprintf(s, "%s -0 -o %s %s >%s 2>&1", GMSH, temp_out, temp_in, temp_log);
  TRACE_F("system: '%s'", s);
  system(s);

  /* step C3: put to compS */
  sprintf(s, "%s put %s", uri_out, file_out);
  TRACE_F("cmd: '%s'", s);
  inp = scdc_dataset_input_create(inp, "file", temp_out);
  scdc_dataset_cmd(SCDC_DATASET_NULL, s, inp, NULL);
  scdc_dataset_input_destroy(inp);

  remove(temp_in);
  remove(temp_out);
  remove(temp_log);

  return SCDC_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa10, %rsp            # imm = 0xA10
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
leaq 0x7c71c(%rip), %rdi     # 0x8a04a
leaq 0x7c6e5(%rip), %rsi     # 0x8a01a
movb $0x0, %al
callq 0xcd20
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq 0x7c6d7(%rip), %rdi     # 0x8a022
movb $0x0, %al
callq 0xcd20
leaq 0x7c6b7(%rip), %rdi     # 0x8a010
movb $0x0, %al
callq 0xcd20
movq -0x20(%rbp), %rdi
movl $0x20, %esi
callq 0xc220
movq %rax, -0x638(%rbp)
leaq -0x530(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x638(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
callq 0xc320
leaq -0x630(%rbp), %rdi
movq -0x638(%rbp), %rsi
addq $0x1, %rsi
callq 0xc600
leaq -0x530(%rbp), %rdi
movl $0x2f, %esi
callq 0xc780
movq %rax, -0x638(%rbp)
movq -0x638(%rbp), %rax
movb $0x0, (%rax)
movq -0x638(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x640(%rbp)
leaq -0x630(%rbp), %rdi
movl $0x2f, %esi
callq 0xc780
movq %rax, -0x638(%rbp)
movq -0x638(%rbp), %rax
movb $0x0, (%rax)
movq -0x638(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x648(%rbp)
leaq -0x750(%rbp), %rdi
movq -0x640(%rbp), %rsi
callq 0xdc60
leaq -0x850(%rbp), %rdi
movq -0x648(%rbp), %rsi
callq 0xdc60
leaq -0x950(%rbp), %rdi
leaq 0x7c5f4(%rip), %rsi     # 0x8a03a
callq 0xdc60
leaq -0x9a8(%rbp), %rax
movq %rax, -0x9b0(%rbp)
leaq -0xa08(%rbp), %rax
movq %rax, -0xa10(%rbp)
leaq -0x430(%rbp), %rdi
leaq -0x530(%rbp), %rdx
movq -0x640(%rbp), %rcx
leaq 0x7c5c0(%rip), %rsi     # 0x8a043
movb $0x0, %al
callq 0xc0f0
leaq 0x7c5b9(%rip), %rdi     # 0x8a04a
leaq 0x7c582(%rip), %rsi     # 0x8a01a
movb $0x0, %al
callq 0xcd20
leaq -0x430(%rbp), %rsi
leaq 0x7c5a0(%rip), %rdi     # 0x8a04d
movb $0x0, %al
callq 0xcd20
leaq 0x7c555(%rip), %rdi     # 0x8a010
movb $0x0, %al
callq 0xcd20
movq -0x9b0(%rbp), %rdi
leaq -0x750(%rbp), %rdx
leaq 0x7db84(%rip), %rsi     # 0x8b65b
movb $0x0, %al
callq 0x32dd0
movq %rax, -0x9b0(%rbp)
leaq -0x430(%rbp), %rsi
movq -0x9b0(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rdi
movb $0x0, %al
callq 0x10060
movq -0x9b0(%rbp), %rdi
callq 0x32ea0
leaq -0x430(%rbp), %rdi
leaq -0x850(%rbp), %rcx
leaq -0x750(%rbp), %r8
leaq -0x950(%rbp), %r9
leaq 0x7c527(%rip), %rsi     # 0x8a057
leaq 0x7c538(%rip), %rdx     # 0x8a06f
movb $0x0, %al
callq 0xc0f0
leaq 0x7c505(%rip), %rdi     # 0x8a04a
leaq 0x7c4ce(%rip), %rsi     # 0x8a01a
movb $0x0, %al
callq 0xcd20
leaq -0x430(%rbp), %rsi
leaq 0x7c51c(%rip), %rdi     # 0x8a07d
movb $0x0, %al
callq 0xcd20
leaq 0x7c4a1(%rip), %rdi     # 0x8a010
movb $0x0, %al
callq 0xcd20
leaq -0x430(%rbp), %rdi
callq 0xc550
leaq -0x430(%rbp), %rdi
leaq -0x630(%rbp), %rdx
movq -0x648(%rbp), %rcx
leaq 0x7c4ec(%rip), %rsi     # 0x8a08a
movb $0x0, %al
callq 0xc0f0
leaq 0x7c49e(%rip), %rdi     # 0x8a04a
leaq 0x7c467(%rip), %rsi     # 0x8a01a
movb $0x0, %al
callq 0xcd20
leaq -0x430(%rbp), %rsi
leaq 0x7c485(%rip), %rdi     # 0x8a04d
movb $0x0, %al
callq 0xcd20
leaq 0x7c43a(%rip), %rdi     # 0x8a010
movb $0x0, %al
callq 0xcd20
movq -0xa10(%rbp), %rdi
leaq -0x850(%rbp), %rdx
leaq 0x7da69(%rip), %rsi     # 0x8b65b
movb $0x0, %al
callq 0x317a0
movq %rax, -0xa10(%rbp)
leaq -0x430(%rbp), %rsi
movq -0xa10(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdi
movb $0x0, %al
callq 0x10060
movq -0xa10(%rbp), %rdi
callq 0x31920
leaq -0x750(%rbp), %rdi
callq 0xcbd0
leaq -0x850(%rbp), %rdi
callq 0xcbd0
leaq -0x950(%rbp), %rdi
callq 0xcbd0
movl $0x1, %eax
addq $0xa10, %rsp            # imm = 0xA10
popq %rbp
retq
nopw (%rax,%rax)