// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x2270
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xa50(%rax)
jle 0x9134
movq -0x10(%rbp), %rax
cmpq $0x0, 0xa68(%rax)
je 0x9134
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq 0xa68(%rcx), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movslq 0x5466(%rip), %rcx      # 0xe568
cmpq %rcx, %rax
jg 0x9132
jmp 0x9109
movq -0x10(%rbp), %rsi
addq $0x10c, %rsi            # imm = 0x10C
movq -0x20(%rbp), %rdx
leaq 0x16fb(%rip), %rdi      # 0xa81a
movb $0x0, %al
callq 0x5720
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x936b
jmp 0x9134
jmp 0x9136
movq -0x10(%rbp), %rsi
addq $0x10c, %rsi            # imm = 0x10C
leaq 0x16f7(%rip), %rdi      # 0xa83f
movb $0x0, %al
callq 0x5720
movl $0x0, -0x24(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x20c(%rcx), %eax
jge 0x91a2
jmp 0x916e
movl -0x24(%rbp), %esi
movq -0x10(%rbp), %rdx
addq $0x210, %rdx            # imm = 0x210
movslq -0x24(%rbp), %rax
shlq $0x7, %rax
addq %rax, %rdx
leaq 0x16c2(%rip), %rdi      # 0xa850
movb $0x0, %al
callq 0x5520
jmp 0x9197
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x915d
callq 0x23a0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x92ba
movq -0x10(%rbp), %rdi
addq $0xa10, %rdi            # imm = 0xA10
callq 0x68f0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x92b0
movq -0x10(%rbp), %rax
movl 0x20c(%rax), %eax
incl %eax
movq %rsp, %rcx
movq %rcx, -0x38(%rbp)
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x58(%rbp)
movq %rcx, %rsp
movq %rax, -0x40(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x20c(%rcx), %eax
jge 0x9244
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rdx
addq $0x210, %rdx            # imm = 0x210
movslq -0x2c(%rbp), %rcx
shlq $0x7, %rcx
addq %rcx, %rdx
movslq -0x2c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x9208
movq -0x58(%rbp), %rsi
movq -0x10(%rbp), %rax
movslq 0x20c(%rax), %rax
movq $0x0, (%rsi,%rax,8)
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
callq 0x2390
cmpl $0x0, %eax
je 0x92a9
movq -0x10(%rbp), %rax
addq $0x10c, %rax            # imm = 0x10C
movq %rax, -0x60(%rbp)
callq 0x2060
movl (%rax), %edi
callq 0x2370
movq -0x60(%rbp), %rsi
movq %rax, %rdx
leaq 0x15c2(%rip), %rdi      # 0xa85a
movb $0x0, %al
callq 0x2150
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2340
xorl %edi, %edi
callq 0x2340
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2340
movl -0x28(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x4(%rax)
movl $0x8, %edi
callq 0x22b0
movq %rax, -0x48(%rbp)
movl $0x8, %edi
callq 0x22b0
movq %rax, -0x50(%rbp)
movl -0x28(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, (%rax)
movq 0x54b3(%rip), %rdi      # 0xe7b8
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rcx
movl $0x4, %edx
movl $0x8, %r8d
callq 0x2ac0
movq -0x48(%rbp), %rax
movl (%rax), %esi
leaq 0x154c(%rip), %rdi      # 0xa876
movb $0x0, %al
callq 0x5520
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa68(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xa50(%rax)
jle 0x9362
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x9362
movq -0x10(%rbp), %rax
movl $0x1, 0x4(%rax)
jmp 0x9364
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)