// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/mysch.c
// Function: run_prog
int run_prog(prog_t* prog)
{

    time_t now = time(NULL);
    if(prog->flag > 0 &&
            prog->time != 0) {
        // 防止死循环，常驻进程启动不成功需等待
        time_t diff = now - prog->time;
        if(diff <= g_info.sleep_time) {
            LOG_INFO("pause start program %s, timediff %d\n",
                    prog->cmd, diff);
            return -1;
        }
    }

    LOG_INFO("run program: %s\n", prog->cmd);
    int i = 0;
    for(i=0; i<prog->argc; i++) {
        LOG_DEBUG("arg%d=%s\n", i, prog->argv[i]);
    }
    pid_t p = fork();
    if(p == 0){
        int r = runas(prog->user);
        if(r == 0) {
            char* argv[prog->argc + 1];
            for(r = 0; r < prog->argc; r++) {
                argv[r] = prog->argv[r];
            }
            argv[prog->argc] = NULL;
            if(execv(prog->cmd, argv) != 0) {
                printf("execv %s failed. error: %s\n",
                        prog->cmd, strerror(errno));
                exit(-1);
            }
            exit(0);
        }
        exit(-1);
    }else{
        prog->pid = p;
        prog->update_pid = 0;

        pid_t* dp = (pid_t*)malloc(sizeof(dp));
        prog_t** dpp = (prog_t**)malloc(sizeof(dpp));

        *dp = p;
        *dpp = prog;

        dict_add(g_info.waitq, dp, sizeof(*dp), dpp, sizeof(*dpp));

        LOG_DEBUG("new proccess: %d\n", *dp);

        prog->time = now;
        if(prog->flag > 0 && !prog->has_pid_file) {
            prog->update_pid = 1;
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
xorl %edi, %edi
callq 0x2270
cmpl $0x0, 0xa50(%rbx)
jle 0x6889
movq 0xa68(%rbx), %rcx
testq %rcx, %rcx
je 0x6889
movq %rax, %rdx
subq %rcx, %rdx
movslq 0x4ce8(%rip), %rcx      # 0xb568
cmpq %rcx, %rdx
jle 0x6964
movq %rax, -0x38(%rbp)
leaq 0x10c(%rbx), %rsi
leaq 0xdb0(%rip), %rdi       # 0x764b
movq %rsi, -0x30(%rbp)
xorl %eax, %eax
callq 0x4266
leaq 0x210(%rbx), %r15
leaq 0xda8(%rip), %r12       # 0x765c
movq %r15, %r13
xorl %r14d, %r14d
movslq 0x20c(%rbx), %rax
cmpq %rax, %r14
jge 0x68df
movq %r12, %rdi
movl %r14d, %esi
movq %r13, %rdx
xorl %eax, %eax
callq 0x3fa2
incq %r14
subq $-0x80, %r13
jmp 0x68ba
callq 0x23a0
testl %eax, %eax
je 0x6992
movl %eax, %r14d
movl %eax, (%rbx)
andl $0x0, 0x4(%rbx)
pushq $0x8
popq %r12
movq %r12, %rdi
callq 0x22a0
movq %rax, %r13
movq %r12, %rdi
callq 0x22a0
movl %r14d, (%r13)
movq %rbx, (%rax)
movq 0x4e9e(%rip), %rdi      # 0xb7b8
pushq $0x4
popq %rdx
pushq $0x8
popq %r8
movq %r13, %rsi
movq %rax, %rcx
callq 0x27ec
movl (%r13), %esi
leaq 0xd4b(%rip), %rdi       # 0x7682
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x3fa2
movq -0x38(%rbp), %rax
movq %rax, 0xa68(%rbx)
cmpl $0x0, 0xa50(%rbx)
jle 0x6980
cmpl $0x0, 0x8(%rbx)
jne 0x6980
movl $0x1, 0x4(%rbx)
jmp 0x6980
addq $0x10c, %rbx            # imm = 0x10C
leaq 0xcb4(%rip), %rdi       # 0x7626
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4266
pushq $-0x1
popq %r14
movl %r14d, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa10(%rbx), %rdi
callq 0x4eff
testl %eax, %eax
jne 0x6a19
movslq 0x20c(%rbx), %rax
leal 0x1(%rax), %ecx
movq %rsp, %rsi
leaq 0xf(,%rcx,8), %rcx
andq $-0x10, %rcx
subq %rcx, %rsi
movq %rsi, %rsp
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
cmpq %rcx, %rdx
je 0x69df
movq %r15, (%rsi,%rcx,8)
incq %rcx
subq $-0x80, %r15
jmp 0x69cd
andq $0x0, (%rsi,%rax,8)
movq -0x30(%rbp), %rdi
callq 0x2390
testl %eax, %eax
jne 0x69f8
xorl %edi, %edi
callq 0x2340
callq 0x2060
movl (%rax), %edi
callq 0x2370
leaq 0xc5b(%rip), %rdi       # 0x7666
movq -0x30(%rbp), %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2160
pushq $-0x1
popq %rdi
callq 0x2340