// File: /workspace/github_cpp_makefile_star2_O2/mh0fm4[P]SCDC/src/components/dataprov/dataprov_jobrun.cc
// Function: scdc_dataprov_jobrun_system::job_do_run(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<scdc_dataprov_jobrun_res_proc_t, std::allocator<scdc_dataprov_jobrun_res_proc_t>> const&)
bool scdc_dataprov_jobrun_system::job_do_run(const std::string &jobid, const std::string &cmd, const std::string &params, const scdc_dataprov_jobrun_res_t &res)
{
  SCDC_TRACE(__func__ << ": jobid: '" << jobid << ", cmd: '" << cmd << "', params: '" << params << "', res: " << res.size());

  bool ret = true;

  if (cmd == "scdc")
  {
    SCDC_TRACE(__func__ << ": scdc '" << params << "'");

    scdc_dataset_input_t *get_input = NULL;
    scdc_dataset_output_t get_output_, *get_output = &get_output_;

#if LOCK_LIBSCDC
    pthread_mutex_lock(&libscdc_lock);
#endif
    get_output = scdc_dataset_output_create(get_output, "fs", get_workdir(jobid).c_str());
    scdc_dataset_cmd(SCDC_DATASET_NULL, params.c_str(), get_input, get_output);
    scdc_dataset_output_destroy(get_output);
#if LOCK_LIBSCDC
    pthread_mutex_unlock(&libscdc_lock);
#endif

  } else if (cmd == "exec")
  {
    SCDC_TRACE(__func__ << ": exec '" << params << "'");

    string execmd = "cd " + get_workdir(jobid) + " && " + params;

    SCDC_TRACE(__func__ << ": execmd: '" << execmd << "'");

    system(execmd.c_str());

  } else if (cmd == "run")
  {
    SCDC_TRACE(__func__ << ": running '" << params << "'");
    SCDC_INFO("executing run of job '" << jobid << "'");

    string c;

    build_cmd(jobcmd.c_str(), "run", jobid.c_str(), params.c_str(), res, c);

    stringstream ss;
    if (xterm) ss << (xterm_hold?"xterm -hold -e \"":"xterm -e \"");
    if (sleep_before_run > 0) ss << "sleep " << sleep_before_run << "; ";
    if (Xvfb) ss << "Xvfb :77 2>/dev/null & XVFB_PID=$!; DISPLAY=:77; ";
    ss << "cd " << get_workdir(jobid) << "; "
       << "(" << c << ") 2>&1 "
       << (show_output?"| tee run.output; ":"| cat > run.output; ");
    if (Xvfb) ss << "kill ${XVFB_PID} 2>/dev/null; ";
    if (sleep_after_run > 0) ss << "sleep " << sleep_after_run << "; ";
    if (xterm) ss << "exit; \"";

    SCDC_TRACE(__func__ << ": executing '" << ss.str() << "'");
#if USE_SYSTEM_PID
    pid_t pid = system_pid(ss.str().c_str());
    waitpid(pid, NULL, 0);
#else
    system(ss.str().c_str());
#endif

  } else ret = false;

  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %r8, %r12
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x1395e(%rip), %rsi     # 0x529cd
movq %rdx, %rdi
callq 0x19be0
testb %al, %al
je 0x3f0e7
leaq 0x158(%rbx), %r12
movq %r12, %rdi
callq 0xb800
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x3f548
movq (%r13), %rdx
leaq 0x14384(%rip), %rsi     # 0x5342c
leaq 0x70(%rsp), %rdi
xorl %eax, %eax
callq 0x26bec
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xb230
movq (%r15), %rsi
xorl %edi, %edi
xorl %edx, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1909c
movq %rbx, %rdi
callq 0x26caa
movq %r12, %rdi
callq 0xb3e0
jmp 0x3f492
leaq 0x14f0a(%rip), %rsi     # 0x53ff8
movq %r13, %rdi
callq 0x19be0
testb %al, %al
je 0x3f17f
leaq 0x50(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x3f548
leaq 0x13ba8(%rip), %rsi     # 0x52cc0
leaq 0x10(%rsp), %rdi
movq %r12, %rdx
callq 0x218cd
leaq 0x14ed1(%rip), %rdx     # 0x53ffd
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1cb18
leaq 0x70(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq %r15, %rdx
callq 0x1eeb2
leaq 0x30(%rsp), %rdi
callq 0xb230
leaq 0x10(%rsp), %rdi
callq 0xb230
leaq 0x50(%rsp), %rdi
callq 0xb230
movq 0x70(%rsp), %rdi
callq 0xb440
leaq 0x70(%rsp), %rdi
jmp 0x3f48d
leaq 0x14ce1(%rip), %rsi     # 0x53e67
movq %r13, %rdi
callq 0x19be0
testb %al, %al
je 0x3f4a6
leaq 0x363e3(%rip), %r13     # 0x75580
movq (%r13), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x3f241
addq $0x20, %rdi
callq 0xb800
movq (%r13), %rax
movq 0x8(%rax), %rdi
leaq 0x12d24(%rip), %rsi     # 0x51ee8
callq 0xb520
movq %rax, %r13
leaq 0x70(%rsp), %rbp
movq %rbp, %rdi
callq 0x3d9d9
movq %r13, %rdi
movq %rbp, %rsi
callq 0xb490
leaq 0x14bc1(%rip), %rsi     # 0x53dac
movq %rax, %rdi
callq 0xb520
leaq 0x14e08(%rip), %rsi     # 0x54002
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
movq %r14, %rsi
callq 0xb490
leaq 0x1414f(%rip), %rsi     # 0x53363
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
callq 0xb270
leaq 0x70(%rsp), %rdi
callq 0xb230
leaq 0x3634b(%rip), %rax     # 0x75580
movq (%rax), %rdi
addq $0x20, %rdi
callq 0xb3e0
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x68(%rbx), %rsi
leaq 0x70(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1a132
movq (%r14), %rsi
leaq 0x10(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x1a132
movq (%r15), %rsi
leaq 0x50(%rsp), %rdi
leaq 0xd(%rsp), %rdx
callq 0x1a132
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x50(%rsp), %rdx
leaq 0x30(%rsp), %r8
movq %r12, %rcx
callq 0x3f5a2
leaq 0x50(%rsp), %rdi
callq 0xb230
leaq 0x10(%rsp), %rdi
callq 0xb230
leaq 0x70(%rsp), %rdi
callq 0xb230
leaq 0x70(%rsp), %rdi
callq 0xb390
cmpb $0x1, 0x290(%rbx)
jne 0x3f2fc
leaq 0x80(%rsp), %rdi
leaq 0x14d34(%rip), %rax     # 0x54019
leaq 0x14d3e(%rip), %rsi     # 0x5402a
cmpb $0x0, 0x291(%rbx)
cmovneq %rax, %rsi
callq 0xb520
cmpq $0x0, 0x298(%rbx)
jle 0x3f338
leaq 0x80(%rsp), %rdi
leaq 0x14d20(%rip), %rsi     # 0x54035
callq 0xb520
movq 0x298(%rbx), %rsi
movq %rax, %rdi
callq 0xb1d0
leaq 0x14d3b(%rip), %rsi     # 0x5406b
movq %rax, %rdi
callq 0xb520
cmpb $0x1, 0x292(%rbx)
jne 0x3f355
leaq 0x80(%rsp), %rdi
leaq 0x14cec(%rip), %rsi     # 0x5403c
callq 0xb520
leaq 0x80(%rsp), %r15
leaq 0x1395c(%rip), %rsi     # 0x52cc0
movq %r15, %rdi
callq 0xb520
movq %rax, %r12
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x3f548
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
callq 0xb490
leaq 0x14cd8(%rip), %rsi     # 0x5406b
movq %rax, %rdi
callq 0xb520
leaq 0x14ccc(%rip), %rsi     # 0x5406e
movq %rax, %rdi
callq 0xb520
leaq 0x30(%rsp), %rsi
movq %rax, %rdi
callq 0xb490
leaq 0x14cb2(%rip), %rsi     # 0x54070
movq %rax, %rdi
callq 0xb520
leaq 0x14cab(%rip), %rcx     # 0x54078
leaq 0x14cb7(%rip), %rsi     # 0x5408b
cmpb $0x0, 0x293(%rbx)
cmovneq %rcx, %rsi
movq %rax, %rdi
callq 0xb520
leaq 0x10(%rsp), %rdi
callq 0xb230
cmpb $0x1, 0x292(%rbx)
jne 0x3f409
leaq 0x14c9f(%rip), %rsi     # 0x540a0
movq %r15, %rdi
callq 0xb520
cmpq $0x0, 0x2a0(%rbx)
jle 0x3f440
leaq 0x14c1b(%rip), %rsi     # 0x54035
movq %r15, %rdi
callq 0xb520
movq 0x2a0(%rbx), %rsi
movq %rax, %rdi
callq 0xb1d0
leaq 0x14c33(%rip), %rsi     # 0x5406b
movq %rax, %rdi
callq 0xb520
cmpb $0x1, 0x290(%rbx)
jne 0x3f458
leaq 0x14c6f(%rip), %rsi     # 0x540bf
movq %r15, %rdi
callq 0xb520
leaq 0x88(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0xb8d0
movq 0x10(%rsp), %rdi
callq 0xb440
leaq 0x10(%rsp), %rdi
callq 0xb230
leaq 0x70(%rsp), %rdi
callq 0xb3d0
leaq 0x30(%rsp), %rdi
callq 0xb230
movb $0x1, %al
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x3f494
jmp 0x3f51a
jmp 0x3f529
jmp 0x3f529
jmp 0x3f515
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xb230
jmp 0x3f4c4
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xb230
jmp 0x3f4d3
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0xb230
jmp 0x3f536
jmp 0x3f515
jmp 0x3f50b
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xb230
jmp 0x3f4f5
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xb230
jmp 0x3f504
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0x3f53b
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
jmp 0x3f53b
movq %rax, %rbx
jmp 0x3f536
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xb230
jmp 0x3f52c
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0xb3d0
leaq 0x30(%rsp), %rdi
callq 0xb230
movq %rbx, %rdi
callq 0xb9a0