// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/tools/gt_condenseq_blast.c
// Function: gt_condenseq_blast_create_blastdb
static inline int gt_condenseq_blast_create_blastdb(const char *dbfile,
                                                    const char *dbtype,
                                                    GtError *err) {
  int had_err = 0,
  pipe_status;
  GtStr *call = gt_str_new_cstr("makeblastdb -dbtype ");
  char *call_str;
  FILE* fpipe;
  gt_str_append_cstr(call, dbtype);
  gt_str_append_cstr(call, " -in ");
  gt_str_append_cstr(call, dbfile);

  call_str = gt_str_get(call);
  gt_log_log("create blastdb: %s", call_str);
  if ((fpipe = popen(call_str, "r")) == NULL) {
    gt_error_set(err, "Could not open pipe to call makeblastdb");
    had_err = -1;
  }
  if (!had_err) {
    char *newline = NULL;
    char line[BUFSIZ + 1];
    line[BUFSIZ] = '\0';
    while (fgets(line, (int) BUFSIZ, fpipe) != NULL) {
      if ((newline = strrchr(line, '\n')) != NULL) {
        *newline = '\0';
        newline = NULL;
      }
      gt_log_log("%.*s", BUFSIZ, line);
    }
  }
  gt_str_delete(call);
  if (!had_err) {
    pipe_status = pclose(fpipe);
    if (pipe_status != 0) {
      had_err = -1;
      if (errno == ECHILD)
        gt_error_set(err, "Error calling makeblastdb.");
#ifndef _WIN32
      else if (WEXITSTATUS(pipe_status) == 127)
        gt_error_set(err, "shell returned 127, makeblastdb not installed?");
      else
        gt_error_set(err, "makeblastdb error, returned %d",
                     WEXITSTATUS(pipe_status));
#else
      /* TODO DW check if this can be done in windows */
      else
        gt_error_set(err, "not implemented on Windows");
#endif
    }
  }
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2018, %rsp           # imm = 0x2018
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x2c8cca(%rip), %rdi    # 0x2e832f
callq 0xacbd1
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0xacbfb
leaq 0x2c8cc5(%rip), %rsi    # 0x2e8344
movq %r14, %rdi
callq 0xacbfb
movq %r14, %rdi
movq %r15, %rsi
callq 0xacbfb
movq %r14, %rdi
callq 0xad1fa
movq %rax, %rbx
leaq 0x2c8ca6(%rip), %rdi    # 0x2e834a
movq %rax, %rsi
xorl %eax, %eax
callq 0x92a82
leaq 0x2db778(%rip), %rsi    # 0x2fae2d
movq %rbx, %rdi
callq 0x171f0
testq %rax, %rax
je 0x1f74f
movq %rax, %r15
movq %r12, 0x8(%rsp)
leaq 0x10(%rsp), %r12
movb $0x0, 0x2000(%r12)
pushq $0xa
popq %rbp
leaq 0x35877b(%rip), %r13    # 0x377e61
movq %r12, %rdi
movl $0x2000, %esi           # imm = 0x2000
movq %r15, %rdx
callq 0x17bc0
testq %rax, %rax
je 0x1f721
movq %r12, %rdi
movl %ebp, %esi
callq 0x17830
testq %rax, %rax
je 0x1f70d
movb $0x0, (%rax)
movq %r13, %rdi
movl $0x2000, %esi           # imm = 0x2000
movq %r12, %rdx
xorl %eax, %eax
callq 0x92a82
jmp 0x1f6e6
movq %r14, %rdi
callq 0xae103
movq %r15, %rdi
callq 0x17a10
testl %eax, %eax
je 0x1f76a
movl %eax, %ebx
callq 0x17060
cmpl $0xa, (%rax)
jne 0x1f76e
leaq 0x2c8c3d(%rip), %rsi    # 0x2e8385
movq 0x8(%rsp), %rdi
jmp 0x1f782
leaq 0x2c8c07(%rip), %rsi    # 0x2e835d
movq %r12, %rdi
xorl %eax, %eax
callq 0x89dbb
movq %r14, %rdi
callq 0xae103
jmp 0x1f799
xorl %eax, %eax
jmp 0x1f79c
movzbl %bh, %edx
cmpl $0x7f, %edx
movq 0x8(%rsp), %rdi
jne 0x1f78b
leaq 0x2c8c1e(%rip), %rsi    # 0x2e83a0
xorl %eax, %eax
callq 0x89dbb
jmp 0x1f799
leaq 0x2c8c3d(%rip), %rsi    # 0x2e83cf
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %rax
addq $0x2018, %rsp           # imm = 0x2018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq