// File: /workspace/github_c_makefile_star2_O3/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 0x6d65
movq 0xa68(%rbx), %rax
testq %rax, %rax
je 0x6d65
movq %r15, %rdx
subq %rax, %rdx
movslq 0x580c(%rip), %rax      # 0xc568
cmpq %rax, %rdx
jle 0x6e43
leaq 0x10c(%rbx), %rsi
leaq 0x18d8(%rip), %rdi      # 0x864b
movq %rsi, -0x30(%rbp)
xorl %eax, %eax
callq 0x45cb
cmpl $0x0, 0x20c(%rbx)
jle 0x6dbb
leaq 0x210(%rbx), %r12
leaq 0x18c7(%rip), %r13      # 0x865c
xorl %r14d, %r14d
movq %r13, %rdi
movl %r14d, %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0x4316
incq %r14
movslq 0x20c(%rbx), %rax
subq $-0x80, %r12
cmpq %rax, %r14
jl 0x6d98
callq 0x23a0
testl %eax, %eax
je 0x6e73
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 0x59bf(%rip), %rdi      # 0xc7b8
movq %r12, %rsi
movl $0x4, %edx
movq %rax, %rcx
movl $0x8, %r8d
callq 0x2a34
movl (%r12), %esi
leaq 0x1868(%rip), %rdi      # 0x8682
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x4316
movq %r15, 0xa68(%rbx)
cmpl $0x0, 0xa50(%rbx)
jle 0x6e61
cmpl $0x0, 0x8(%rbx)
jne 0x6e61
movl $0x1, 0x4(%rbx)
jmp 0x6e61
addq $0x10c, %rbx            # imm = 0x10C
leaq 0x17d5(%rip), %rdi      # 0x8626
movq %rbx, %rsi
xorl %eax, %eax
callq 0x45cb
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 0x5246
testl %eax, %eax
jne 0x6efd
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 0x6ec0
addq $0x210, %rbx            # imm = 0x210
xorl %ecx, %ecx
movq %rbx, (%rsi,%rcx,8)
incq %rcx
subq $-0x80, %rbx
cmpq %rcx, %rax
jne 0x6eb0
movq $0x0, (%rsi,%rax,8)
movq -0x30(%rbp), %rdi
callq 0x2390
testl %eax, %eax
jne 0x6edc
xorl %edi, %edi
callq 0x2340
callq 0x2060
movl (%rax), %edi
callq 0x2370
leaq 0x1777(%rip), %rdi      # 0x8666
movq -0x30(%rbp), %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2160
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2340