// File: 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
movq %rsp, %rbp
subq $0x4b0, %rsp            # imm = 0x4B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x3d0(%rbp)
jmp 0x7f71c
movb $0x1, -0x29(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x282ca(%rip), %rsi     # 0xa79f5
callq 0x25b80
testb $0x1, %al
jne 0x7f739
jmp 0x7f842
jmp 0x7f73b
jmp 0x7f73d
movq -0x3d0(%rbp), %rdi
movq $0x0, -0x38(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0x98(%rbp)
addq $0x158, %rdi            # imm = 0x158
callq 0xc9f0
movq -0x3d0(%rbp), %rsi
movq -0x98(%rbp), %rax
movq %rax, -0x3e0(%rbp)
movq -0x10(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x3e8(%rbp)
callq 0x80090
movq -0x3e8(%rbp), %rdi
callq 0xc260
movq -0x3e0(%rbp), %rdi
movq %rax, %rdx
leaq 0x28ced(%rip), %rsi     # 0xa849c
xorl %eax, %eax
callq 0x46af0
movq %rax, -0x3d8(%rbp)
jmp 0x7f7bf
movq -0x3d8(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xc3e0
movq -0x20(%rbp), %rdi
callq 0xc260
movq %rax, %rsi
movq -0x38(%rbp), %rdx
movq -0x98(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edi
movb $0x0, %al
callq 0x23d80
movq -0x98(%rbp), %rdi
callq 0x46bc0
movq -0x3d0(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
callq 0xc4c0
jmp 0x80069
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xc3e0
jmp 0x80077
movq -0x18(%rbp), %rdi
leaq 0x297a3(%rip), %rsi     # 0xa8ff0
callq 0x25b80
testb $0x1, %al
jne 0x7f85b
jmp 0x7f9a3
jmp 0x7f85d
jmp 0x7f85f
movq -0x3d0(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x148(%rbp), %rdi
movq %rdi, -0x3f0(%rbp)
callq 0x80090
movq -0x3f0(%rbp), %rdx
leaq 0x284b1(%rip), %rsi     # 0xa7d3c
leaq -0x128(%rbp), %rdi
callq 0x3b040
jmp 0x7f899
leaq 0x29755(%rip), %rdx     # 0xa8ff5
leaq -0x108(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x2eef0
jmp 0x7f8b5
movq -0x20(%rbp), %rdx
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x34a30
jmp 0x7f8ce
leaq -0x108(%rbp), %rdi
callq 0xc3e0
leaq -0x128(%rbp), %rdi
callq 0xc3e0
leaq -0x148(%rbp), %rdi
callq 0xc3e0
jmp 0x7f8f4
jmp 0x7f8f6
leaq -0xe8(%rbp), %rdi
callq 0xc260
movq %rax, %rdi
callq 0xc560
jmp 0x7f90c
leaq -0xe8(%rbp), %rdi
callq 0xc3e0
jmp 0x80067
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x7f96f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x7f963
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x108(%rbp), %rdi
callq 0xc3e0
leaq -0x128(%rbp), %rdi
callq 0xc3e0
leaq -0x148(%rbp), %rdi
callq 0xc3e0
jmp 0x80077
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0xc3e0
jmp 0x80077
movq -0x18(%rbp), %rdi
leaq 0x294b1(%rip), %rsi     # 0xa8e5f
callq 0x25b80
testb $0x1, %al
jne 0x7f9bc
jmp 0x80061
jmp 0x7f9be
jmp 0x7f9c0
jmp 0x7f9c2
leaq 0x54cdf(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x257e0
cmpq $0x0, %rax
je 0x7fb07
leaq 0x54cc6(%rip), %rax     # 0xd46a8
movq %rax, -0x410(%rbp)
movq (%rax), %rdi
callq 0x25800
movq -0x410(%rbp), %rax
movq (%rax), %rdi
callq 0x257e0
movq %rax, %rdi
leaq 0x27516(%rip), %rsi     # 0xa6f20
callq 0xc670
movq %rax, -0x408(%rbp)
leaq -0x168(%rbp), %rdi
movq %rdi, -0x400(%rbp)
callq 0x7d410
movq -0x408(%rbp), %rdi
movq -0x400(%rbp), %rsi
callq 0xc5b0
movq %rax, -0x3f8(%rbp)
jmp 0x7fa45
movq -0x3f8(%rbp), %rdi
leaq 0x29351(%rip), %rsi     # 0xa8da4
callq 0xc670
movq %rax, -0x418(%rbp)
jmp 0x7fa61
movq -0x418(%rbp), %rdi
leaq 0x2958b(%rip), %rsi     # 0xa8ffa
callq 0xc670
movq %rax, -0x420(%rbp)
jmp 0x7fa7d
movq -0x420(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xc5b0
movq %rax, -0x428(%rbp)
jmp 0x7fa96
movq -0x428(%rbp), %rdi
leaq 0x2892f(%rip), %rsi     # 0xa83d3
callq 0xc670
movq %rax, -0x430(%rbp)
jmp 0x7fab2
movq -0x430(%rbp), %rdi
movq 0x54500(%rip), %rsi     # 0xd3fc0
callq 0xc6d0
jmp 0x7fac7
leaq -0x168(%rbp), %rdi
callq 0xc3e0
leaq 0x54bce(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x25820
jmp 0x7fb07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x168(%rbp), %rdi
callq 0xc3e0
jmp 0x80077
jmp 0x7fb09
leaq -0x188(%rbp), %rdi
callq 0xc960
movq -0x3d0(%rbp), %rdi
addq $0x68, %rdi
callq 0xc260
movq %rax, -0x440(%rbp)
leaq -0x1a9(%rbp), %rdi
movq %rdi, -0x438(%rbp)
callq 0xcbc0
movq -0x440(%rbp), %rsi
movq -0x438(%rbp), %rdx
leaq -0x1a8(%rbp), %rdi
callq 0x27820
jmp 0x7fb5b
movq -0x10(%rbp), %rdi
callq 0xc260
movq %rax, -0x450(%rbp)
leaq -0x1d1(%rbp), %rdi
movq %rdi, -0x448(%rbp)
callq 0xcbc0
movq -0x450(%rbp), %rsi
movq -0x448(%rbp), %rdx
leaq -0x1d0(%rbp), %rdi
callq 0x27820
jmp 0x7fb9a
movq -0x20(%rbp), %rdi
callq 0xc260
movq %rax, -0x460(%rbp)
leaq -0x1f9(%rbp), %rdi
movq %rdi, -0x458(%rbp)
callq 0xcbc0
movq -0x460(%rbp), %rsi
movq -0x458(%rbp), %rdx
leaq -0x1f8(%rbp), %rdi
callq 0x27820
jmp 0x7fbd9
movq -0x28(%rbp), %r8
leaq 0x2927b(%rip), %rsi     # 0xa8e5f
leaq -0x1a8(%rbp), %rdi
leaq -0x1d0(%rbp), %rdx
leaq -0x1f8(%rbp), %rcx
leaq -0x188(%rbp), %r9
callq 0x80120
jmp 0x7fc07
leaq -0x1f8(%rbp), %rdi
callq 0xc3e0
leaq -0x1f9(%rbp), %rdi
callq 0xc730
leaq -0x1d0(%rbp), %rdi
callq 0xc3e0
leaq -0x1d1(%rbp), %rdi
callq 0xc730
leaq -0x1a8(%rbp), %rdi
callq 0xc3e0
leaq -0x1a9(%rbp), %rdi
callq 0xc730
leaq -0x388(%rbp), %rdi
callq 0xc470
jmp 0x7fc5d
movq -0x3d0(%rbp), %rax
testb $0x1, 0x290(%rax)
je 0x7fd6f
movq -0x3d0(%rbp), %rax
leaq -0x378(%rbp), %rdi
movb 0x291(%rax), %cl
leaq 0x29385(%rip), %rax     # 0xa9011
leaq 0x2938f(%rip), %rsi     # 0xa9022
testb $0x1, %cl
cmovneq %rax, %rsi
callq 0xc670
jmp 0x7fca1
jmp 0x7fd6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x7fd30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x7fd18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x7fd00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0xc3e0
leaq -0x1f9(%rbp), %rdi
callq 0xc730
leaq -0x1d0(%rbp), %rdi
callq 0xc3e0
leaq -0x1d1(%rbp), %rdi
callq 0xc730
leaq -0x1a8(%rbp), %rdi
callq 0xc3e0
leaq -0x1a9(%rbp), %rdi
callq 0xc730
jmp 0x80053
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x80053
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x80047
movq -0x3d0(%rbp), %rax
cmpq $0x0, 0x298(%rax)
jle 0x7fdd6
leaq -0x378(%rbp), %rdi
leaq 0x2929f(%rip), %rsi     # 0xa902d
callq 0xc670
movq %rax, -0x468(%rbp)
jmp 0x7fd9c
movq -0x468(%rbp), %rdi
movq -0x3d0(%rbp), %rax
movq 0x298(%rax), %rsi
callq 0xc340
movq %rax, -0x470(%rbp)
jmp 0x7fdbf
movq -0x470(%rbp), %rdi
leaq 0x29296(%rip), %rsi     # 0xa9063
callq 0xc670
jmp 0x7fdd4
jmp 0x7fdd6
movq -0x3d0(%rbp), %rax
testb $0x1, 0x292(%rax)
je 0x7fdfd
leaq -0x378(%rbp), %rdi
leaq 0x29240(%rip), %rsi     # 0xa9034
callq 0xc670
jmp 0x7fdfb
jmp 0x7fdfd
leaq -0x378(%rbp), %rdi
leaq 0x27f31(%rip), %rsi     # 0xa7d3c
callq 0xc670
movq %rax, -0x478(%rbp)
jmp 0x7fe19
movq -0x3d0(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x3a8(%rbp), %rdi
callq 0x80090
jmp 0x7fe32
movq -0x478(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
callq 0xc5b0
movq %rax, -0x480(%rbp)
jmp 0x7fe4e
movq -0x480(%rbp), %rdi
leaq 0x29207(%rip), %rsi     # 0xa9063
callq 0xc670
movq %rax, -0x488(%rbp)
jmp 0x7fe6a
movq -0x488(%rbp), %rdi
leaq 0x291ee(%rip), %rsi     # 0xa9066
callq 0xc670
movq %rax, -0x490(%rbp)
jmp 0x7fe86
movq -0x490(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0xc5b0
movq %rax, -0x498(%rbp)
jmp 0x7fea2
movq -0x498(%rbp), %rdi
leaq 0x291b8(%rip), %rsi     # 0xa9068
callq 0xc670
movq %rax, -0x4a0(%rbp)
jmp 0x7febe
movq -0x4a0(%rbp), %rdi
movq -0x3d0(%rbp), %rax
movb 0x293(%rax), %cl
leaq 0x29197(%rip), %rax     # 0xa9070
leaq 0x291a3(%rip), %rsi     # 0xa9083
testb $0x1, %cl
cmovneq %rax, %rsi
callq 0xc670
jmp 0x7feee
leaq -0x3a8(%rbp), %rdi
callq 0xc3e0
movq -0x3d0(%rbp), %rax
testb $0x1, 0x292(%rax)
je 0x7ff44
leaq -0x378(%rbp), %rdi
leaq 0x29180(%rip), %rsi     # 0xa9098
callq 0xc670
jmp 0x7ff1f
jmp 0x7ff44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0xc3e0
jmp 0x80047
movq -0x3d0(%rbp), %rax
cmpq $0x0, 0x2a0(%rax)
jle 0x7ffab
leaq -0x378(%rbp), %rdi
leaq 0x290ca(%rip), %rsi     # 0xa902d
callq 0xc670
movq %rax, -0x4a8(%rbp)
jmp 0x7ff71
movq -0x4a8(%rbp), %rdi
movq -0x3d0(%rbp), %rax
movq 0x2a0(%rax), %rsi
callq 0xc340
movq %rax, -0x4b0(%rbp)
jmp 0x7ff94
movq -0x4b0(%rbp), %rdi
leaq 0x290c1(%rip), %rsi     # 0xa9063
callq 0xc670
jmp 0x7ffa9
jmp 0x7ffab
movq -0x3d0(%rbp), %rax
testb $0x1, 0x290(%rax)
je 0x7ffd2
leaq -0x378(%rbp), %rdi
leaq 0x290ee(%rip), %rsi     # 0xa90b7
callq 0xc670
jmp 0x7ffd0
jmp 0x7ffd2
jmp 0x7ffd4
jmp 0x7ffd6
jmp 0x7ffd8
leaq -0x3c8(%rbp), %rdi
leaq -0x388(%rbp), %rsi
callq 0xc650
jmp 0x7ffed
leaq -0x3c8(%rbp), %rdi
callq 0xc260
movq %rax, %rdi
callq 0xc560
jmp 0x80003
leaq -0x3c8(%rbp), %rdi
callq 0xc3e0
leaq -0x388(%rbp), %rdi
callq 0xc4b0
leaq -0x188(%rbp), %rdi
callq 0xc3e0
jmp 0x80065
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x3c8(%rbp), %rdi
callq 0xc3e0
leaq -0x388(%rbp), %rdi
callq 0xc4b0
leaq -0x188(%rbp), %rdi
callq 0xc3e0
jmp 0x80077
movb $0x0, -0x29(%rbp)
jmp 0x80067
jmp 0x80069
movb -0x29(%rbp), %al
andb $0x1, %al
addq $0x4b0, %rsp            # imm = 0x4B0
popq %rbp
retq
movq -0xc0(%rbp), %rdi
callq 0xcba0
nopw %cs:(%rax,%rax)