// File: /workspace/github_cpp_makefile_star2_O2/mh0fm4[P]SCDC/src/components/dataprov/dataprov_jobrun.cc
// Function: sched_run_routine(void*)
static void *sched_run_routine(void *arg)
{
  SCDC_TRACE(__func__ << ": arg: '" << arg << "'");

  scdc_dataprov_jobrun *dataprov_jobrun = static_cast<scdc_dataprov_jobrun *>(arg);

  pthread_mutex_lock(&dataprov_jobrun->sched_lock);
  while (dataprov_jobrun->sched_run)
  {
    struct timespec abstime;
    abstimeout(&abstime, 0.1, -1);

    pthread_cond_timedwait(&dataprov_jobrun->sched_cond, &dataprov_jobrun->sched_lock, &abstime);

/*    SCDC_TRACE(__func__ << ": " << time(NULL) << " TICK-TACK");*/

    if (!dataprov_jobrun->runjobs) continue;

    while (dataprov_jobrun->sched_jobs_wait.size() > 0)
    {
      /* check scheduling method */
      dataprov_jobrun->sched->update(dataprov_jobrun->sched_method);

      string jobid;
      scdc_dataprov_jobrun_job_t job;
      scdc_dataprov_jobrun_res_t jobres;
      scdcint_t m;

      if (!dataprov_jobrun->sched->job_get_runable(jobid, job, jobres, m)) break;

      sched_job_arg_t *sched_job_arg = new sched_job_arg_t;
      sched_job_arg->dataprov_jobrun = dataprov_jobrun;
      sched_job_arg->jobid = jobid;
      sched_job_arg->jobcmds = job.jobcmds;
      sched_job_arg->jobres = jobres;
      sched_job_arg->m = m;

      dataprov_jobrun->sched->job_started(m, jobid, sched_job_arg->jobres);

      pthread_t thread;
      pthread_create(&thread, NULL, sched_job_routine, sched_job_arg);

      dataprov_jobrun->sched_jobs_run.insert(scdc_dataprov_jobrun::sched_jobs_run_t::value_type(jobid, thread));

      job.waiting = false;
      dataprov_jobrun->set_job(jobid, job);

      pthread_cond_signal(&dataprov_jobrun->sched_cond_finished);
    }
  }
  pthread_mutex_unlock(&dataprov_jobrun->sched_lock);

  SCDC_TRACE(__func__ << ": return");

  pthread_exit(NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdi, %r14
addq $0x190, %rdi            # imm = 0x190
movq %rdi, 0x8(%rsp)
callq 0xb800
leaq 0x1b8(%r14), %rax
movq %rax, 0x30(%rsp)
leaq 0xf0(%r14), %rax
movq %rax, 0x48(%rsp)
leaq 0x240(%r14), %rax
movq %rax, 0x40(%rsp)
leaq 0x1e8(%r14), %rax
movq %rax, 0x38(%rsp)
xorl %ebx, %ebx
leaq 0x60(%rsp), %r15
leaq 0x80(%rsp), %rbp
cmpb $0x1, 0x188(%r14)
jne 0x3e663
leaq 0x118(%rsp), %r12
movq %r12, %rdi
movsd 0x15585(%rip), %xmm0    # 0x539d0
movsd 0x11f5d(%rip), %xmm1    # 0x503b0
callq 0x1b0db
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
callq 0xb840
cmpb $0x1, 0xc8(%r14)
jne 0x3e42a
cmpq $0x0, 0x238(%r14)
je 0x3e42a
movq 0x180(%r14), %rdi
movq 0x48(%rsp), %rsi
callq 0x41bb6
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
andq $0x0, 0x68(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
leaq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
andq $0x0, 0xa8(%rsp)
movb %bl, 0xb0(%rsp)
leaq 0xd0(%rsp), %rax
movq %rax, 0xc0(%rsp)
andq $0x0, 0xc8(%rsp)
movb %bl, 0x70(%rsp)
movb %bl, 0xd0(%rsp)
movb $0x1, 0xe0(%rsp)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq 0x180(%r14), %rdi
movq %r15, %rsi
movq %rbp, %rdx
leaq 0x10(%rsp), %rcx
leaq 0x58(%rsp), %r8
callq 0x41c94
testb %al, %al
je 0x3e644
pushq $0x68
popq %rdi
callq 0xb540
movq %rax, %r13
addq $0x18, %rax
movq %rax, 0x8(%r13)
andq $0x0, 0x10(%r13)
movb %bl, 0x18(%r13)
leaq 0x38(%r13), %rax
movq %rax, 0x28(%r13)
andq $0x0, 0x30(%r13)
leaq 0x8(%r13), %rdi
movb %bl, 0x38(%r13)
xorps %xmm0, %xmm0
movups %xmm0, 0x48(%r13)
andq $0x0, 0x58(%r13)
movq %r14, (%r13)
movq %r15, %rsi
callq 0xb2e0
leaq 0x28(%r13), %rdi
leaq 0xc0(%rsp), %rsi
callq 0xb2e0
movq %r13, %r12
addq $0x48, %r12
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0x41ca8
movq 0x58(%rsp), %rsi
movq %rsi, 0x60(%r13)
movq 0x180(%r14), %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x41d86
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
leaq 0x1cb0(%rip), %rdx      # 0x40275
movq %r13, %rcx
callq 0xb9f0
leaq 0xf0(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0xb750
movq 0x50(%rsp), %rax
movq %rax, 0x110(%rsp)
movq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x4245c
movq %r12, %rdi
callq 0xb230
movb $0x0, 0xe0(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %r12
movq %rbp, %rdx
callq 0x3db60
movq 0x38(%rsp), %rdi
callq 0xb030
leaq 0x10(%rsp), %rdi
callq 0x403ca
movq %r12, %rdi
callq 0x4113a
movq %r15, %rdi
callq 0xb230
jmp 0x3e474
leaq 0x10(%rsp), %rdi
callq 0x403ca
movq %rbp, %rdi
callq 0x4113a
movq %r15, %rdi
callq 0xb230
jmp 0x3e42a
movq 0x8(%rsp), %rdi
callq 0xb3e0
xorl %edi, %edi
callq 0xb9b0
jmp 0x3e68c
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0xb230
jmp 0x3e68f
jmp 0x3e68c
jmp 0x3e68c
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x403ca
leaq 0x80(%rsp), %rdi
callq 0x4113a
leaq 0x60(%rsp), %rdi
callq 0xb230
movq %rbx, %rdi
callq 0xb9a0