// File: /workspace/github_c_makefile_star2_O1/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 $0x2008, %rsp           # imm = 0x2008
movq %rdx, %rbp
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x2b0c6a(%rip), %rdi    # 0x351341
callq 0x120955
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x12097f
leaq 0x2b0c65(%rip), %rsi    # 0x351356
movq %r14, %rdi
callq 0x12097f
movq %r14, %rdi
movq %r15, %rsi
callq 0x12097f
movq %r14, %rdi
callq 0x120d23
movq %rax, %rbx
leaq 0x2b0c46(%rip), %rdi    # 0x35135c
movq %rax, %rsi
xorl %eax, %eax
callq 0x108e02
leaq 0x2c37a2(%rip), %rsi    # 0x363ec9
movq %rbx, %rdi
callq 0x17210
testq %rax, %rax
je 0xa07c6
movq %rax, %r15
movq %rsp, %rdi
movb $0x0, 0x2000(%rdi)
movl $0x2000, %esi           # imm = 0x2000
movq %rax, %rdx
callq 0x17c30
testq %rax, %rax
je 0xa079d
movq %rsp, %r12
leaq 0x340a35(%rip), %r13    # 0x3e1196
movq %r12, %rdi
movl $0xa, %esi
callq 0x17880
testq %rax, %rax
je 0xa0776
movb $0x0, (%rax)
movq %r13, %rdi
movl $0x2000, %esi           # imm = 0x2000
movq %r12, %rdx
xorl %eax, %eax
callq 0x108e02
movq %r12, %rdi
movl $0x2000, %esi           # imm = 0x2000
movq %r15, %rdx
callq 0x17c30
testq %rax, %rax
jne 0xa0761
movq %r14, %rdi
callq 0x121b03
movq %r15, %rdi
callq 0x17a70
testl %eax, %eax
je 0xa07e1
movl %eax, %ebx
callq 0x17060
cmpl $0xa, (%rax)
jne 0xa07e5
leaq 0x2b0bd3(%rip), %rsi    # 0x351397
jmp 0xa07f4
leaq 0x2b0ba2(%rip), %rsi    # 0x35136f
movq %rbp, %rdi
xorl %eax, %eax
callq 0x1019cf
movq %r14, %rdi
callq 0x121b03
jmp 0xa0811
xorl %eax, %eax
jmp 0xa0816
movzbl %bh, %edx
cmpl $0x7f, %edx
jne 0xa0800
leaq 0x2b0bbe(%rip), %rsi    # 0x3513b2
movq %rbp, %rdi
xorl %eax, %eax
callq 0x1019cf
jmp 0xa0811
leaq 0x2b0bda(%rip), %rsi    # 0x3513e1
movq %rbp, %rdi
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x2008, %rsp           # imm = 0x2008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq