// File: /workspace/github_c_makefile_star2_O1/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
pushq %rax
movq %rdi, %rbx
xorl %edi, %edi
callq 0x2270
movq %rax, %r15
cmpl $0x0, 0xa50(%rbx)
jle 0x6f9e
movq 0xa68(%rbx), %rax
testq %rax, %rax
je 0x6f9e
movq %r15, %rdx
subq %rax, %rdx
movslq 0x55d3(%rip), %rax      # 0xc568
cmpq %rax, %rdx
jle 0x707c
leaq 0x10c(%rbx), %rsi
leaq 0x16bd(%rip), %rdi      # 0x8669
movq %rsi, -0x30(%rbp)
xorl %eax, %eax
callq 0x46e4
cmpl $0x0, 0x20c(%rbx)
jle 0x6ff4
leaq 0x210(%rbx), %r12
leaq 0x16ac(%rip), %r13      # 0x867a
xorl %r14d, %r14d
movq %r13, %rdi
movl %r14d, %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0x4433
incq %r14
movslq 0x20c(%rbx), %rax
subq $-0x80, %r12
cmpq %rax, %r14
jl 0x6fd1
callq 0x23a0
testl %eax, %eax
je 0x70ac
movl %eax, %r14d
movl %eax, (%rbx)
movl $0x0, 0x4(%rbx)
movl $0x8, %edi
callq 0x22a0
movq %rax, %r12
movl $0x8, %edi
callq 0x22a0
movl %r14d, (%r12)
movq %rbx, (%rax)
movq 0x5786(%rip), %rdi      # 0xc7b8
movq %r12, %rsi
movl $0x4, %edx
movq %rax, %rcx
movl $0x8, %r8d
callq 0x2a3a
movl (%r12), %esi
leaq 0x164d(%rip), %rdi      # 0x86a0
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x4433
movq %r15, 0xa68(%rbx)
cmpl $0x0, 0xa50(%rbx)
jle 0x709a
cmpl $0x0, 0x8(%rbx)
jne 0x709a
movl $0x1, 0x4(%rbx)
jmp 0x709a
addq $0x10c, %rbx            # imm = 0x10C
leaq 0x15ba(%rip), %rdi      # 0x8644
movq %rbx, %rsi
xorl %eax, %eax
callq 0x46e4
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
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 0x536b
testl %eax, %eax
jne 0x7136
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
testq %rax, %rax
jle 0x70f9
addq $0x210, %rbx            # imm = 0x210
xorl %ecx, %ecx
movq %rbx, (%rsi,%rcx,8)
incq %rcx
subq $-0x80, %rbx
cmpq %rcx, %rax
jne 0x70e9
movq $0x0, (%rsi,%rax,8)
movq -0x30(%rbp), %rdi
callq 0x2390
testl %eax, %eax
jne 0x7115
xorl %edi, %edi
callq 0x2340
callq 0x2060
movl (%rax), %edi
callq 0x2370
leaq 0x155c(%rip), %rdi      # 0x8684
movq -0x30(%rbp), %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2160
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2340