LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/log.c
// Function: log_file_uninit_callback_fun
int log_file_uninit_callback_fun(void* args)
{
    FILE* fp = _file_log_ctx.fp;
    char* buf = _file_log_ctx.buf;
    if(fp) {
        if(log_file_switch(args) != LOG_SUCCESS) {
            return LOG_FAIL;
        }

        if(_file_log_ctx.buf && _file_log_ctx.w_pos > 0) {
            fwrite(_file_log_ctx.buf, 1,
                    _file_log_ctx.w_pos, _file_log_ctx.fp);
        }

        fclose(fp);

        char old_path[LOG_DEFAULT_MAX_PATH] = {0};
        char new_path[LOG_DEFAULT_MAX_PATH] = {0};

        snprintf(old_path, LOG_DEFAULT_MAX_PATH, "%s/%s.tmp",
                _file_log_ctx.path, _file_log_ctx.name);

        snprintf(new_path, LOG_DEFAULT_MAX_PATH, "%s/%s.log",
                        _file_log_ctx.path, _file_log_ctx.name);

        if(rename(old_path, new_path) != 0) {
            fprintf(stderr, "rename %s - > %s failed: %s\n", old_path, new_path, strerror(errno));
        }
    }
    if(buf) {
        free(buf);
    }
    memset(&_file_log_ctx, 0, sizeof(_file_log_ctx.buf));

    return LOG_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq 0x6a79(%rip), %r14      # 0xb538
movq 0x6a8a(%rip), %rbx      # 0xb550
testq %r14, %r14
je 0x4b99
callq 0x4c66
testl %eax, %eax
je 0x4ae0
pushq $-0x1
popq %rax
jmp 0x4bab
movq 0x6a69(%rip), %rdi      # 0xb550
testq %rdi, %rdi
setne %cl
movl 0x6a6d(%rip), %eax      # 0xb560
testl %eax, %eax
setg %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x4b10
movl %eax, %edx
movq 0x6a30(%rip), %rcx      # 0xb538
pushq $0x1
popq %rsi
callq 0x2350
movq %r14, %rdi
callq 0x2110
leaq -0x230(%rbp), %r14
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
xorl %esi, %esi
callq 0x21a0
leaq -0x130(%rbp), %r15
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
xorl %esi, %esi
callq 0x21a0
leaq 0x26bb(%rip), %rdx      # 0x7206
leaq 0x66de(%rip), %r12      # 0xb230
leaq 0x68d7(%rip), %r13      # 0xb430
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x2170
leaq 0x269b(%rip), %rdx      # 0x7210
movl $0x100, %esi            # imm = 0x100
movq %r15, %rdi
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x2170
movq %r14, %rdi
movq %r15, %rsi
callq 0x2310
testl %eax, %eax
jne 0x4bbd
movq %rbx, %rdi
callq 0x2030
andq $0x0, 0x6687(%rip)      # 0xb230
xorl %eax, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x6434(%rip), %rax      # 0xaff8
movq (%rax), %r14
callq 0x2060
movl (%rax), %edi
callq 0x2370
leaq 0x2640(%rip), %rsi      # 0x721a
leaq -0x230(%rbp), %rdx
leaq -0x130(%rbp), %rcx
movq %r14, %rdi
movq %rax, %r8
xorl %eax, %eax
callq 0x2220
jmp 0x4b99
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/log.c
// Function: log_file_flush_callback_fun
int log_file_flush_callback_fun(void* args)
{
    FILE* fp = _file_log_ctx.fp;
    if(fp) {
        if(log_file_switch(args) != LOG_SUCCESS) {
            return LOG_FAIL;
        }
        if(_file_log_ctx.buf && _file_log_ctx.w_pos > 0) {
            _file_log_ctx.w_size += fwrite(_file_log_ctx.buf, 1,
                    _file_log_ctx.w_pos, _file_log_ctx.fp);
            _file_log_ctx.w_pos = 0;

            fflush(fp);
        }
    }
    return LOG_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq 0x6933(%rip), %r14      # 0xb538
xorl %ebx, %ebx
testq %r14, %r14
je 0x4c5f
callq 0x4c66
testl %eax, %eax
je 0x4c1a
pushq $-0x1
popq %rbx
jmp 0x4c5f
movq 0x692f(%rip), %rdi      # 0xb550
testq %rdi, %rdi
setne %cl
movl 0x6933(%rip), %eax      # 0xb560
testl %eax, %eax
setg %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x4c5f
movl %eax, %edx
movq 0x68f6(%rip), %rcx      # 0xb538
pushq $0x1
popq %rsi
callq 0x2350
addl %eax, 0x690c(%rip)      # 0xb55c
andl $0x0, 0x6909(%rip)      # 0xb560
movq %r14, %rdi
callq 0x22b0
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/log.c
// Function: log_file_switch
static int log_file_switch(void* args)
{
    int sw_log = 0;

    if (_file_log_ctx.switch_time > 0) {
        struct timeval tv = { 0 };
        gettimeofday(&tv, NULL );
        struct tm* tm = localtime(&tv.tv_sec);

        if(tm->tm_mday != _file_log_ctx.sw_day) {
            int seconds = tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec;
            if (seconds >= _file_log_ctx.switch_time) {
                sw_log = 1;
                _file_log_ctx.sw_day = tm->tm_mday;
            }
        }
    }
    if (!sw_log) {
        if (_file_log_ctx.switch_size > 0
                && _file_log_ctx.w_size >= _file_log_ctx.switch_size) {
            sw_log = 1;
        }
    }
    if (sw_log) {

        if (log_file_init_callback_fun(&_file_log_ctx) != LOG_SUCCESS) {
            return LOG_FAIL;
        }
    }

    return LOG_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
cmpl $0x0, 0x68cc(%rip)      # 0xb544
jle 0x4cc7
xorps %xmm0, %xmm0
leaq -0x20(%rbp), %rbx
movaps %xmm0, (%rbx)
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2190
movq %rbx, %rdi
callq 0x2050
movl 0xc(%rax), %ecx
cmpl 0x688e(%rip), %ecx      # 0xb530
je 0x4cca
imull $0xe10, 0x8(%rax), %edx # imm = 0xE10
imull $0x3c, 0x4(%rax), %esi
addl %edx, %esi
addl (%rax), %esi
cmpl 0x688b(%rip), %esi      # 0xb544
jl 0x4cca
movl %ecx, 0x686f(%rip)      # 0xb530
pushq $0x1
popq %r14
jmp 0x4cca
xorl %r14d, %r14d
movl 0x6878(%rip), %eax      # 0xb548
xorl %ecx, %ecx
cmpl %eax, 0x6884(%rip)      # 0xb55c
setge %cl
testl %eax, %eax
cmovlel %r14d, %ecx
testl %r14d, %r14d
cmovnel %r14d, %ecx
testl %ecx, %ecx
je 0x4cfa
callq 0x4767
testl %eax, %eax
je 0x4cfa
pushq $-0x1
popq %rax
jmp 0x4cfc
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: set_signal
sigfunc* set_signal(int signo, sigfunc* func, int interupt)
{
    struct sigaction act, oact;
    act.sa_handler = func;
    sigemptyset(&act.sa_mask);
    act.sa_flags = 0;

    if (!interupt){
        act.sa_flags |= SA_RESTART;
    }
    if (sigaction(signo, &act, &oact) < 0) {
        return SIG_ERR ;
    }
    return oact.sa_handler;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movl %edx, %ebx
movl %edi, %r14d
leaq -0x140(%rbp), %r15
movq %rsi, -0x8(%r15)
movq %r15, %rdi
callq 0x2230
xorl %eax, %eax
testl %ebx, %ebx
sete %al
shll $0x1c, %eax
movl %eax, 0x80(%r15)
leaq -0x148(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
movl %r14d, %edi
callq 0x20c0
testl %eax, %eax
js 0x4d64
movq -0xb0(%rbp), %rax
jmp 0x4d67
pushq $-0x1
popq %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: make_daemon
int make_daemon()
{
    if (fork() > 0) {
        exit(0);
    }
    setsid();
    if (fork() > 0) {
        exit(0);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
callq 0x23a0
testl %eax, %eax
jg 0x4d94
callq 0x21d0
callq 0x23a0
testl %eax, %eax
jg 0x4d94
xorl %eax, %eax
popq %rbp
retq
xorl %edi, %edi
callq 0x2340
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: is_prog_running
int is_prog_running(const char* name)
{
    if(name == NULL || name[0] == 0) return -1;

    char file[MAX_PATH_LEN] = { 0 };
    snprintf(file, MAX_PATH_LEN - 1, "/tmp/%s.running", name);

    umask(0111);

    int fd = open(file, O_RDWR | O_CREAT | O_SYNC, 0666);
    if (fd < 0) {
        return -1;
    }

    struct flock lck = {0};
    lck.l_type = F_WRLCK;
    lck.l_whence = SEEK_SET;
    lck.l_start = sizeof(pid_t);

    int len = 0;
    pid_t pid = -1;

    if(fcntl(fd, F_SETLK, &lck) < 0){
        len = read(fd, &pid, sizeof(pid_t));
        if(len != sizeof(pid_t)) {
            printf("read pid failed. error: %s\n", strerror(errno));
            close(fd);
            return -1;
        }
        close(fd);
        return 1;
    }

    pid = getpid();

    lseek(fd, 0, SEEK_SET);
    len = write(fd, &pid, sizeof(pid_t));
    if(len != sizeof(pid_t)){
        lck.l_type = F_UNLCK;
        fcntl(fd, F_SETLK, &lck);
        close(fd);
        return -1;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
pushq $-0x1
popq %r14
testq %rdi, %rdi
je 0x4eee
movq %rdi, %rbx
cmpb $0x0, (%rdi)
je 0x4eee
leaq -0x140(%rbp), %r14
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
xorl %esi, %esi
callq 0x21a0
leaq 0x244d(%rip), %rdx      # 0x7250
movl $0xff, %esi
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2170
pushq $0x49
popq %rdi
callq 0x2240
movq %r14, %rdi
movl $0x101042, %esi         # imm = 0x101042
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x22f0
testl %eax, %eax
js 0x4ea9
movl %eax, %ebx
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movw $0x1, (%rdx)
movq $0x4, 0x8(%rdx)
orl $-0x1, -0x1c(%rbp)
xorl %r14d, %r14d
pushq $0x6
popq %rsi
movl %eax, %edi
xorl %eax, %eax
callq 0x20e0
testl %eax, %eax
js 0x4eaf
callq 0x2100
leaq -0x1c(%rbp), %r15
movl %eax, (%r15)
movl %ebx, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2180
pushq $0x4
popq %rdx
movl %ebx, %edi
movq %r15, %rsi
callq 0x20f0
cmpl $0x4, %eax
je 0x4eee
leaq -0x40(%rbp), %rdx
movw $0x2, (%rdx)
pushq $0x6
popq %rsi
movl %ebx, %edi
xorl %eax, %eax
callq 0x20e0
jmp 0x4ee3
pushq $-0x1
popq %r14
jmp 0x4eee
leaq -0x1c(%rbp), %rsi
pushq $0x4
popq %rdx
movl %ebx, %edi
callq 0x21e0
cmpl $0x4, %eax
jne 0x4ec6
pushq $0x1
jmp 0x4ee5
callq 0x2060
movl (%rax), %edi
callq 0x2370
leaq 0x2387(%rip), %rdi      # 0x7260
movq %rax, %rsi
xorl %eax, %eax
callq 0x2160
pushq $-0x1
popq %r14
movl %ebx, %edi
callq 0x21c0
movl %r14d, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: runas
int runas(const char* user)
{
    struct passwd* passwd = getpwuid(getuid());

    if(strcmp(passwd->pw_name, user) == 0) {
        return 0;
    }

    passwd = getpwnam(user);
    if(passwd == NULL) {
        return -1;
    }

/*    struct group* group = getgrnam(grp);
    if(group == NULL) {
        return -1;
    }*/

    if(setuid(passwd->pw_uid) != 0) {
        fprintf(stderr, "setuid failed,: %s\n", strerror(errno));
        return -1;
    }
/*    if(setgid(group->gr_gid) != 0){
        fprintf(stderr, "setgid failed: %s\n", strerror(errno));
        return -1;
    }*/

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %r14
callq 0x2140
movl %eax, %edi
callq 0x2120
movq (%rax), %rdi
movq %r14, %rsi
callq 0x2200
xorl %ebx, %ebx
testl %eax, %eax
je 0x4f70
movq %r14, %rdi
callq 0x2210
pushq $-0x1
popq %r14
testq %rax, %rax
je 0x4f6d
movl 0x10(%rax), %edi
callq 0x2360
testl %eax, %eax
je 0x4f70
movq 0x60ae(%rip), %rax      # 0xaff8
movq (%rax), %rbx
callq 0x2060
movl (%rax), %edi
callq 0x2370
leaq 0x231c(%rip), %rsi      # 0x727c
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2220
movl %r14d, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: write_pid_file
int write_pid_file(const char* file)
{
    FILE* fp = fopen(file, "w");
    if(fp == NULL){
        return -1;
    }

    fprintf(fp, "%d", getpid());

    fclose(fp);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
leaq 0x230b(%rip), %rsi      # 0x7290
callq 0x2300
testq %rax, %rax
je 0x4fb7
movq %rax, %rbx
callq 0x2100
leaq 0x22ac(%rip), %rsi      # 0x724a
xorl %r14d, %r14d
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x2220
movq %rbx, %rdi
callq 0x2110
jmp 0x4fbb
pushq $-0x1
popq %r14
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: read_pid_file
int read_pid_file(pid_t* pid, const char* file)
{
    FILE* fp = fopen(file, "r");
    if(fp == NULL){
        return -1;
    }

    fscanf(fp, "%d", pid);

    fclose(fp);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x2180(%rip), %rsi      # 0x715a
movq %rax, %rdi
callq 0x2300
testq %rax, %rax
je 0x500b
movq %rax, %r15
leaq 0x2259(%rip), %rsi      # 0x724a
xorl %r14d, %r14d
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x20a0
movq %r15, %rdi
callq 0x2110
jmp 0x500f
pushq $-0x1
popq %r14
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: get_1970_sec_0_am
time_t get_1970_sec_0_am()
{
    time_t now = get_1970_sec();
    struct tm now_tm = {0};

    localtime_r(&now, &now_tm);

    now_tm.tm_hour = 0;
    now_tm.tm_min = 0;
    now_tm.tm_sec = 0;

    return mktime(&now_tm) + SEC_1900_1970;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x48, %rsp
callq 0x501d
leaq -0x10(%rbp), %rdi
movq %rax, (%rdi)
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rbx
movaps %xmm0, 0x20(%rbx)
movaps %xmm0, 0x10(%rbx)
movaps %xmm0, (%rbx)
andq $0x0, 0x30(%rbx)
movq %rbx, %rsi
callq 0x2080
andl $0x0, 0x8(%rbx)
andq $0x0, (%rbx)
movq %rbx, %rdi
callq 0x22d0
movl $0x83aa7e80, %ecx       # imm = 0x83AA7E80
addq %rcx, %rax
addq $0x48, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: sec_1970_to_datetime
int sec_1970_to_datetime(time_t sec, const char* fmt, char* datetime, int len)
{
    if(datetime == NULL)
        return -1;

    memset(datetime, 0, len);

    struct tm rst;
    localtime_r(&sec, &rst);
    snprintf(datetime, len, fmt, rst.tm_year + 1900, rst.tm_mon + 1,
            rst.tm_mday, rst.tm_hour, rst.tm_min, rst.tm_sec);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, -0x30(%rbp)
testq %rdx, %rdx
je 0x51c2
movq %rdx, %r15
movq %rsi, %r14
movslq %ecx, %r12
xorl %ebx, %ebx
movq %rdx, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x21a0
leaq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %r13
movq %r13, %rsi
callq 0x2080
movl $0x76c, %ecx            # imm = 0x76C
addl 0x14(%r13), %ecx
movl 0x10(%r13), %r8d
incl %r8d
movl 0xc(%r13), %r9d
movl 0x8(%r13), %r10d
movl (%r13), %r11d
movl 0x4(%r13), %r13d
subq $0x8, %rsp
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
pushq %r11
pushq %r13
pushq %r10
callq 0x2170
addq $0x20, %rsp
jmp 0x51c5
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: sec_1970_to_date
int sec_1970_to_date(time_t sec, const char* fmt, char* time, int len)
{
    if(time == NULL) return -1;

    memset(time, 0, len);

    struct tm rst;
    localtime_r(&sec, &rst);
    snprintf(time, len, fmt,  rst.tm_year + 1900, rst.tm_mon + 1,
            rst.tm_mday);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, -0x30(%rbp)
testq %rdx, %rdx
je 0x523e
movq %rdx, %r15
movq %rsi, %r14
movslq %ecx, %r12
xorl %ebx, %ebx
movq %rdx, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x21a0
leaq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %r13
movq %r13, %rsi
callq 0x2080
movl $0x76c, %ecx            # imm = 0x76C
addl 0x14(%r13), %ecx
movl 0xc(%r13), %r9d
movl 0x10(%r13), %r8d
incl %r8d
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2170
jmp 0x5241
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: sec_1970_to_time
int sec_1970_to_time(time_t sec, const char* fmt, char* time, int len)
{
    if(time == NULL) return -1;

    memset(time, 0, len);

    struct tm rst;
    localtime_r(&sec, &rst);
    snprintf(time, len, fmt,  rst.tm_hour, rst.tm_min, rst.tm_sec);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, -0x30(%rbp)
testq %rdx, %rdx
je 0x52b2
movq %rdx, %r15
movq %rsi, %r14
movslq %ecx, %r12
xorl %ebx, %ebx
movq %rdx, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x21a0
leaq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %r13
movq %r13, %rsi
callq 0x2080
movl 0x8(%r13), %ecx
movl (%r13), %r9d
movl 0x4(%r13), %r8d
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2170
jmp 0x52b5
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: sec_1970_to_numeric
int sec_1970_to_numeric(time_t s,
        int* year, int* mon, int* day,
        int* hour, int* min, int* sec)
{
    if(!year || !mon || !day ||
            !hour || !min || !sec){
        return -1;
    }

    struct tm rst;
    localtime_r(&s, &rst);
    *year = rst.tm_year + 1900;
    *mon = rst.tm_mon + 1;
    *day = rst.tm_mday;

    *hour = rst.tm_hour;
    *min = rst.tm_min;
    *sec = rst.tm_sec;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r15
movq %rdx, %r12
movq %rdi, -0x38(%rbp)
testq %rsi, %rsi
sete %al
testq %rdx, %rdx
sete %cl
orb %al, %cl
testq %r15, %r15
sete %al
testq %r8, %r8
sete %dl
orb %al, %dl
orb %cl, %dl
testq %r9, %r9
sete %al
orb %dl, %al
cmpq $0x0, 0x10(%rbp)
sete %cl
orb %al, %cl
jne 0x5363
movq %r8, %r14
movq %rsi, %r13
leaq -0x38(%rbp), %rdi
leaq -0x70(%rbp), %rbx
movq %rbx, %rsi
movq %r9, -0x30(%rbp)
callq 0x2080
movl $0x76c, %eax            # imm = 0x76C
addl 0x14(%rbx), %eax
movl %eax, (%r13)
movl 0x10(%rbx), %eax
incl %eax
movl %eax, (%r12)
movl 0xc(%rbx), %eax
movl %eax, (%r15)
movl 0x8(%rbx), %eax
movl %eax, (%r14)
movl 0x4(%rbx), %eax
movq -0x30(%rbp), %rcx
movl %eax, (%rcx)
movl (%rbx), %eax
movq 0x10(%rbp), %rcx
movl %eax, (%rcx)
xorl %eax, %eax
jmp 0x5366
pushq $-0x1
popq %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: split
int split(const char* text, char needle, char** dest, int size, int num)
{
    if (!text || text[0] == 0 || !dest || size <= 0 || num <= 0) {
        return -1;
    }
    const char* orig = text;
    const char* tmp = text;

    int cur_num = 0;
    while ((tmp = strchr(tmp, needle)) != NULL) {
        int len = tmp - orig;

        if (len >= size) {
            return -1;
        }
        if (cur_num >= num) {
            return -1;
        }

        memcpy((char*)dest + size*cur_num, orig, len);
        *((char*)dest + size*cur_num + len) = 0;

        cur_num++;
        tmp++;
        orig = tmp;
    }
    if(orig != NULL){
        strcpy((char*)dest + size*cur_num, orig);
        cur_num ++ ;
    }
    if(cur_num == 0){
        strcpy((char*)dest, text);
        cur_num++;
    }
    return cur_num;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, -0x2c(%rbp)
movq %rdx, -0x38(%rbp)
pushq $-0x1
popq %rax
testq %rdi, %rdi
je 0x554d
testl %r8d, %r8d
jle 0x554d
cmpl $0x0, -0x2c(%rbp)
jle 0x554d
cmpq $0x0, -0x38(%rbp)
je 0x554d
movq %rdi, %rbx
cmpb $0x0, (%rdi)
je 0x554d
movsbl %sil, %eax
movl %eax, -0x3c(%rbp)
movl -0x2c(%rbp), %eax
movq %rax, -0x48(%rbp)
movl %r8d, %eax
movq %rax, -0x50(%rbp)
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %rbx, %rdi
movl -0x3c(%rbp), %esi
callq 0x2150
testq %rax, %rax
je 0x5530
movq %rax, %r12
subq %rbx, %rax
cmpl -0x2c(%rbp), %eax
jge 0x554a
cmpq -0x50(%rbp), %r13
jae 0x554a
movq -0x38(%rbp), %rcx
leaq (%rcx,%r15), %r14
movq %rbx, %rsi
movq %r15, %rbx
movslq %eax, %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x2250
movb $0x0, (%r15,%r14)
movq %rbx, %r15
incq %r13
incq %r12
addq -0x48(%rbp), %r15
movq %r12, %rbx
jmp 0x54dc
movl %r15d, %eax
movq -0x38(%rbp), %rdi
addq %rax, %rdi
movq %rbx, %rsi
callq 0x2090
incl %r13d
movl %r13d, %eax
jmp 0x554d
pushq $-0x1
popq %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: trim_left
const char* trim_left(const char* text, const char* needle, char* dest, int size)
{
    if(!text || text[0] == 0 ||
            !needle || needle[0] == 0 ||
            !dest || size <= 0){
        return NULL;
    }

    memset(dest, 0, size);

    int count = 0;
    int match = 0;
    while (*(text + count) != 0) {
        if (NULL != strchr(needle, *(text + count))) {
            ++match;
        } else {
            break;
        }
        ++count;
    }
    count = strlen(text + match);
    if (count >= size) {
        return NULL;
    }
    strncpy(dest, text + match, size);

    return dest;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x55f8
movq %rsi, %r12
testq %rsi, %rsi
je 0x55f8
movq %rdi, %r14
cmpb $0x0, (%rdi)
je 0x55f8
movl %ecx, %r15d
testl %ecx, %ecx
jle 0x55f8
movq %rdx, %rbx
testq %rdx, %rdx
je 0x55f8
cmpb $0x0, (%r12)
je 0x55f8
movl %r15d, %edx
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %esi, %esi
movq %rdx, -0x30(%rbp)
callq 0x21a0
movsbl (%r14,%r13), %esi
testl %esi, %esi
je 0x55c8
movq %r12, %rdi
callq 0x2150
testq %rax, %rax
je 0x55c8
incq %r13
jmp 0x55ad
movl %r13d, %eax
addq %rax, %r14
movq %r14, %rdi
callq 0x2130
cmpl %r15d, %eax
jge 0x55f8
movq %rbx, %rdi
movq %r14, %rsi
movq -0x30(%rbp), %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2070
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: trim_right
const char* trim_right(const char* text, const char* needle, char* dest, int size)
{
    if(!text || text[0] == 0 ||
            !needle || needle[0] == 0 ||
            !dest || size <= 0){
        return NULL;
    }

    memset(dest, 0, size);

    int len = strlen(text);

    const char *p = text + len - 1;

    while (p >= text) {
        if (strchr(needle, *p) != NULL) {
            --p;
            --len;
        } else {
            break;
        }

    }
    if(len >= size) {
        return NULL;
    }
    strncpy(dest, text, len);

    return dest;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x56a6
movq %rsi, %r12
testq %rsi, %rsi
je 0x56a6
movq %rdi, %r14
cmpb $0x0, (%rdi)
je 0x56a6
movl %ecx, %r15d
testl %ecx, %ecx
jle 0x56a6
movq %rdx, %rax
testq %rdx, %rdx
je 0x56a6
cmpb $0x0, (%r12)
je 0x56a6
movl %r15d, %edx
movq %rax, -0x30(%rbp)
movq %rax, %rdi
xorl %esi, %esi
callq 0x21a0
movq %r14, %rdi
callq 0x2130
movslq %eax, %r13
leaq -0x1(%r14), %rbx
leaq (%rbx,%r13), %rax
cmpq %r14, %rax
jb 0x5684
movsbl (%rax), %esi
movq %r12, %rdi
callq 0x2150
testq %rax, %rax
je 0x5684
decq %r13
jmp 0x5666
cmpl %r15d, %r13d
movq -0x30(%rbp), %rdi
jge 0x56a6
movq %r14, %rsi
movq %r13, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2070
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/util.c
// Function: trim
const char* trim(const char* text, const char* needle, char* dest, int size)
{
    char tmp[size];
    memset(tmp, 0, size);

    if(trim_left(text, needle, tmp, size) == NULL) {
        return NULL;
    }

    if(trim_right(tmp, needle, dest, size) == NULL) {
        return NULL;
    }
    return dest;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r14d
movq %rdx, -0x38(%rbp)
movq %rsi, %rbx
movq %rdi, -0x30(%rbp)
movl %ecx, %eax
movq %rsp, %r12
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movslq %ecx, %r15
xorl %r13d, %r13d
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x21a0
movq -0x30(%rbp), %rdi
movq %rbx, -0x30(%rbp)
movq %rbx, %rsi
movq %r12, %rdx
movl %r15d, %ecx
callq 0x555c
testq %rax, %rax
je 0x5734
movq %r12, %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %r13
movq %r13, %rdx
movl %r14d, %ecx
callq 0x5609
testq %rax, %rax
cmoveq %rax, %r13
movq %r13, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/mysch.c
// Function: reg_sign
int reg_sign()
{
    REGISTER_SIGNAL(SIGTERM, sigterm, 0);//Kill信号
    REGISTER_SIGNAL(SIGINT, sigterm, 0);//终端CTRL-C信号
    REGISTER_SIGNAL(SIGUSR1, sigusr1, 0);//SIGUSR1信号
    REGISTER_SIGNAL(SIGUSR2, sigusr2, 0);//SIGUSR2信号
    REGISTER_SIGNAL(SIGHUP, SIG_IGN, 0);//忽略SIGHUP信号
    REGISTER_SIGNAL(SIGCHLD, sigchild, 0);//子进程退出
    REGISTER_SIGNAL(SIGPIPE, SIG_IGN, 0);//忽略SIGPIPE信号
    REGISTER_SIGNAL(SIGALRM, SIG_IGN, 0);//忽略SIGALRM信号

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
leaq 0xeb(%rip), %rsi        # 0x5841
pushq $0xf
popq %rbx
movl %ebx, %edi
xorl %edx, %edx
callq 0x4d08
cmpq $-0x1, %rax
je 0x5816
leaq 0xce(%rip), %rsi        # 0x5841
pushq $0x2
popq %rbx
movl %ebx, %edi
xorl %edx, %edx
callq 0x4d08
cmpq $-0x1, %rax
je 0x5816
leaq 0xbe(%rip), %rsi        # 0x584e
pushq $0xa
popq %rbx
movl %ebx, %edi
xorl %edx, %edx
callq 0x4d08
cmpq $-0x1, %rax
je 0x5816
leaq 0xb2(%rip), %rsi        # 0x585b
pushq $0xc
popq %rbx
movl %ebx, %edi
xorl %edx, %edx
callq 0x4d08
cmpq $-0x1, %rax
je 0x5816
pushq $0x1
popq %rbx
pushq $0x1
popq %rsi
movl %ebx, %edi
xorl %edx, %edx
callq 0x4d08
cmpq $-0x1, %rax
je 0x5816
leaq 0x91(%rip), %rsi        # 0x5868
pushq $0x11
popq %rbx
movl %ebx, %edi
xorl %edx, %edx
callq 0x4d08
cmpq $-0x1, %rax
je 0x5816
pushq $0xd
popq %rbx
pushq $0x1
popq %rsi
xorl %r14d, %r14d
movl %ebx, %edi
xorl %edx, %edx
callq 0x4d08
cmpq $-0x1, %rax
je 0x5816
pushq $0xe
popq %rbx
pushq $0x1
popq %rsi
movl %ebx, %edi
xorl %edx, %edx
callq 0x4d08
cmpq $-0x1, %rax
jne 0x5839
callq 0x2060
movl (%rax), %edi
callq 0x2370
leaq 0x1a69(%rip), %rdi      # 0x7292
movl %ebx, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2160
pushq $-0x1
popq %r14
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/mysch.c
// Function: uninit_context
void uninit_context(sch_info_t* info)
{
    if(info->progq) {
        list_iter* it = list_get_iterator(info->progq, AL_START_HEAD);
        list_node* n = NULL;
        while((n = list_next(it)) != NULL) {
            prog_t* p = list_node_value(n);
            if(p->cond) {
                list_release(p->cond, AL_FREE);
            }
        }

        list_release_iterator(it);
        list_release(info->progq, AL_FREE);
    }
    if(info->waitq) {
        dict_release(info->waitq);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x248(%rdi), %rdi
testq %rdi, %rdi
je 0x58fd
xorl %esi, %esi
callq 0x32e5
movq %rax, %r14
movq %r14, %rdi
callq 0x3342
testq %rax, %rax
je 0x58e7
movq 0x10(%rax), %rax
movq 0xa58(%rax), %rdi
testq %rdi, %rdi
je 0x58c1
xorl %esi, %esi
callq 0x310a
jmp 0x58c1
movq %r14, %rdi
callq 0x3314
movq 0x248(%rbx), %rdi
xorl %esi, %esi
callq 0x310a
movq 0x250(%rbx), %rdi
testq %rdi, %rdi
je 0x5912
popq %rbx
popq %r14
popq %rbp
jmp 0x2c35
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/mysch.c
// Function: usage
void usage()
{
    printf("./myshc [-c config] [-h]\n");
    printf("--simple program scheduler\n\n");
    printf("  -c config    load configuration file.\n");
    printf("  -e           don't run as daemon process.\n");
    printf("  -t           test configuration file.\n");
    printf("  -h           show this help message.\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x12ad(%rip), %rdi      # 0x780d
callq 0x20b0
leaq 0x12ba(%rip), %rdi      # 0x7826
callq 0x20b0
leaq 0x12ca(%rip), %rdi      # 0x7842
callq 0x20b0
leaq 0x12e6(%rip), %rdi      # 0x786a
callq 0x20b0
leaq 0x1306(%rip), %rdi      # 0x7896
callq 0x20b0
leaq 0x1322(%rip), %rdi      # 0x78be
popq %rbp
jmp 0x20b0
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/mysch.c
// Function: judge_condition
int judge_condition(prog_t* prog)
{
    if(prog->flag <= 0 || !prog->cond) {
        return 1;
    }

    struct timeval tv = {0};
    gettimeofday(&tv, NULL);
    struct tm* tm = localtime(&tv.tv_sec);

    int wday = tm->tm_wday;
    if(wday == 0) {
        wday = 7; // 星期天
    }
    int sec = tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec;

    list_iter* it = list_get_iterator(prog->cond, AL_START_HEAD);
    list_node* node = NULL;
    while((node = list_next(it)) != NULL) {
        cond_t* c = list_node_value(node);

        if(c->day[wday] == 1) {
        	if(prog->flag == FORK_PERIOD) {
        		int diff = time(NULL) - prog->time;
        		if(diff > c->start) {
        			list_release_iterator(it);
        			return 1;
        		}
        	}
            if(sec >= c->start && sec <= c->end) {
                list_release_iterator(it);
                return 1;
            }
        }
    }

    list_release_iterator(it);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
pushq $0x1
popq %rbx
cmpl $0x0, 0xa50(%rdi)
jle 0x668a
movq %rdi, %r14
cmpq $0x0, 0xa58(%rdi)
je 0x668a
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %r15
movaps %xmm0, (%r15)
movq %r15, %rdi
xorl %esi, %esi
callq 0x2190
movq %r15, %rdi
callq 0x2050
movl 0x18(%rax), %ecx
testl %ecx, %ecx
pushq $0x7
popq %rbx
cmovnel %ecx, %ebx
movslq 0x8(%rax), %rcx
imulq $0xe10, %rcx, %rcx      # imm = 0xE10
movslq 0x4(%rax), %rdx
imulq $0x3c, %rdx, %rdx
addq %rcx, %rdx
movslq (%rax), %r12
addq %rdx, %r12
movq 0xa58(%r14), %rdi
xorl %esi, %esi
callq 0x32e5
movq %rax, %r15
movslq %ebx, %r13
movq %r15, %rdi
callq 0x3342
testq %rax, %rax
je 0x6680
movq 0x10(%rax), %rbx
cmpb $0x1, (%rbx,%r13)
jne 0x662c
cmpl $0x2, 0xa50(%r14)
jne 0x666a
xorl %edi, %edi
callq 0x2270
subl 0xa68(%r14), %eax
movslq %eax, %rcx
movq 0x8(%rbx), %rax
cmpq %rax, %rcx
jle 0x666e
jmp 0x6679
movq 0x8(%rbx), %rax
cmpq %r12, %rax
jg 0x662c
cmpq %r12, 0x10(%rbx)
jl 0x662c
pushq $0x1
popq %rax
movl %eax, %ebx
jmp 0x6682
xorl %ebx, %ebx
movq %r15, %rdi
callq 0x3314
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/mysch.c
// Function: handle_sigchild
void handle_sigchild()
{
    pid_t pid;
    int status = 0;
    while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
        prog_t** pp = (prog_t**)dict_fetch_value(g_info.waitq,
                &pid, sizeof(pid));
        prog_t* p = *pp;

        p->status = status;
        p->time = time(NULL);

        if(dict_delete(g_info.waitq, &pid, sizeof(pid))!= DICT_OK) {
            LOG_ERROR("dict_delete failed. pid = %d\n", pid);
        }
    }
    g_chld = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq -0x30(%rbp), %rbx
andl $0x0, (%rbx)
pushq $0x1
popq %r15
leaq -0x2c(%rbp), %r12
pushq $0x4
popq %r13
pushq $-0x1
popq %rdi
movq %rbx, %rsi
movl %r15d, %edx
callq 0x22e0
movl %eax, -0x2c(%rbp)
testl %eax, %eax
jle 0x6727
movq 0x50e0(%rip), %rdi      # 0xb7b8
movq %r12, %rsi
movl %r13d, %edx
callq 0x2c5e
movq (%rax), %r14
movl -0x30(%rbp), %eax
movl %eax, 0xa60(%r14)
xorl %edi, %edi
callq 0x2270
movq %rax, 0xa68(%r14)
movq 0x50b3(%rip), %rdi      # 0xb7b8
movq %r12, %rsi
movl %r13d, %edx
callq 0x2a8d
testl %eax, %eax
je 0x66bc
movl -0x2c(%rbp), %esi
leaq 0xe57(%rip), %rdi       # 0x7575
xorl %eax, %eax
callq 0x43ba
jmp 0x66bc
movb $0x0, 0x5092(%rip)      # 0xb7c0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/mysch.c
// Function: handle_sigusr1
void handle_sigusr1()
{
    int ret = 0;

    ret = load_conf(&g_info, LOAD_CONF_RELOAD);
    if(ret != 0) {
        LOG_ERROR("reload config failed. exiting...\n");
    }else{
        LOG_INFO("prepare for restart program. killing...\n");
    }

    clean_proccess(1);

    g_usr1 = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x4e20(%rip), %rdi      # 0xb568
pushq $0x1
popq %rsi
callq 0x5917
testl %eax, %eax
je 0x6764
leaq 0xe38(%rip), %rdi       # 0x7593
xorl %eax, %eax
callq 0x43ba
jmp 0x6772
leaq 0xe4a(%rip), %rdi       # 0x75b5
xorl %eax, %eax
callq 0x4266
pushq $0x1
popq %rdi
callq 0x6783
movb $0x0, 0x5043(%rip)      # 0xb7c4
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/mysch.c
// Function: clean_proccess
void clean_proccess(int killflag)
{
    dict_iterator* it = dict_get_iterator(g_info.waitq);
    dict_entry* de = NULL;
    while((de = dict_next(it)) != NULL) {
        pid_t* p = (pid_t*) dict_get_entry_key(de);
        if (killflag) {
            LOG_INFO("killing %d\n", *p);
            kill(*p, SIGTERM);
            waitpid(*p, NULL, 0);
            LOG_INFO("%d killed\n", *p);
        }else{
            prog_t* prog = *(prog_t**)dict_get_entry_val(de);
            LOG_INFO("program %s continue running even i die, pid: %d\n",
                    prog->cmd, *p);
        }

        dict_delete(g_info.waitq, p, sizeof(*p));
    }

    dict_release_iterator(it);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
movq 0x501e(%rip), %rdi      # 0xb7b8
callq 0x2c76
movq %rax, %r14
pushq $0x4
popq %r12
leaq 0xe3d(%rip), %r13       # 0x75ea
movq %r14, %rdi
callq 0x2cbc
testq %rax, %rax
je 0x682d
movq 0x8(%rax), %r15
testl %ebx, %ebx
je 0x67f9
movl (%r15), %esi
leaq 0xe12(%rip), %rdi       # 0x75de
xorl %eax, %eax
callq 0x4266
movl (%r15), %edi
pushq $0xf
popq %rsi
callq 0x2260
movl (%r15), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x22e0
movl (%r15), %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x4266
jmp 0x6819
movq 0x10(%rax), %rax
movq (%rax), %rsi
movl $0x10c, %eax            # imm = 0x10C
addq %rax, %rsi
movl (%r15), %edx
leaq 0xde3(%rip), %rdi       # 0x75f5
xorl %eax, %eax
callq 0x4266
movq 0x4f98(%rip), %rdi      # 0xb7b8
movq %r15, %rsi
movl %r12d, %edx
callq 0x2a8d
jmp 0x67ad
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2d45
// File: /workspace/github_c_makefile_star2_O2/buf1024[P]mysch/mysch.c
// Function: update_pid
int update_pid(prog_t* prog)
{
    int ret = 0;
    if(!prog->update_pid && prog->has_pid_file) {
        if (prog->pid_file[0] != 0) {
            pid_t pid;
            if (read_pid_file(&pid, prog->pid_file) == 0) {
                if (kill(pid, 0) == 0) {
                    LOG_INFO("update pid from %d to %d\n", prog->pid, pid);

                    prog->pid = pid;
                    prog->update_pid = 1;

                    // 新进程信息

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

                    *dp = pid;
                    *dpp = prog;

                    dict_add(g_info.waitq, dp, sizeof(*dp), dpp, sizeof(*dpp));
                }
            } else {
                LOG_WARN("read_pid_file failed, pidfile = %s, error  = %s\n",
                        prog->pid_file, strerror(errno));
                ret = -1;
            }
        }
    }
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %ebx, %ebx
cmpl $0x0, 0x4(%rdi)
je 0x6a48
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %r14
cmpl $0x0, 0x8(%rdi)
je 0x6a37
cmpb $0x0, 0xc(%r14)
je 0x6a37
leaq 0xc(%r14), %rbx
leaq -0x2c(%rbp), %rdi
movq %rbx, %rsi
callq 0x4fc3
testl %eax, %eax
je 0x6a91
callq 0x2060
movl (%rax), %edi
callq 0x2370
leaq 0xc2f(%rip), %rdi       # 0x76ae
movq %rbx, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4310
pushq $-0x1
popq %rbx
jmp 0x6a37
movl -0x2c(%rbp), %edi
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x2260
testl %eax, %eax
jne 0x6a37
movl (%r14), %esi
movl -0x2c(%rbp), %edx
leaq 0xbe6(%rip), %rdi       # 0x7694
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4266
movl -0x2c(%rbp), %r13d
movl %r13d, (%r14)
movl $0x1, 0x4(%r14)
pushq $0x8
popq %r15
movq %r15, %rdi
callq 0x22a0
movq %rax, %r12
movq %r15, %rdi
callq 0x22a0
movl %r13d, (%r12)
movq %r14, (%rax)
movq 0x4ccd(%rip), %rdi      # 0xb7b8
pushq $0x4
popq %rdx
pushq $0x8
popq %r8
movq %r12, %rsi
movq %rax, %rcx
callq 0x27ec
jmp 0x6a37
// File: /workspace/github_c_makefile_star2_O2/mflatt[P]gc-demo/common/tree.c
// Function: main
int main(int argc, char **argv)
{
  /* create one tree without intermediate garbage: */
  struct node *init_n = make_tree(10);
  PUSH_STACK_POINTER(init_n);

  /* create a larger tree with lots of intermediate garbage: */
  create_garbage = 1;
  struct node *n = NULL;
  PUSH_STACK_POINTER(n);
  SET_NODE(n, make_tree(16));

  /* check the trees: */
  printf("%d\n", count(n) + count(init_n));
  
  destroy_tree(n);
  destroy_tree(init_n);

  UNSET_NODE(n);
  UNSET_NODE(init_n);

  POP_STACK_POINTER(n);
  POP_STACK_POINTER(init_n);

  printf("Peak memory use: %ld\n", peak_mem_use);

  return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
pushq $0xa
popq %rdi
callq 0x11d0
movq %rax, %rbx
movb $0x1, 0x2ed2(%rip)      # 0x4044
pushq $0x10
popq %rdi
callq 0x11d0
movq %rax, %r14
movq %rax, %rdi
callq 0x1221
movl %eax, %ebp
movq %rbx, %rdi
callq 0x1221
addl %eax, %ebp
leaq 0xe6c(%rip), %rdi       # 0x2004
movl %ebp, %esi
xorl %eax, %eax
callq 0x1040
movq %r14, %rdi
callq 0x124b
movq %rbx, %rdi
callq 0x124b
leaq 0x2e98(%rip), %rax      # 0x4050
movq (%rax), %rsi
leaq 0xe46(%rip), %rdi       # 0x2008
xorl %eax, %eax
callq 0x1040
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mflatt[P]gc-demo/common/tree.c
// Function: destroy_tree
static void destroy_tree(struct node *n)
{
#if MANUAL_DEALLOCATE
  if (n != NULL) {
    destroy_tree(n->left);
    destroy_tree(n->right);
    deallocate(n);
  }
#endif
}

// Assembly:
testq %rdi, %rdi
je 0x126e
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x124b
movq 0x8(%rbx), %rdi
callq 0x124b
movq %rbx, %rdi
popq %rbx
jmp 0x12b0
retq
nop
// File: /workspace/github_c_makefile_star2_O2/mflatt[P]gc-demo/common/mem.c
// Function: raw_malloc
void *raw_malloc(size_t s)
{
  mem_use += s;
  if (mem_use > peak_mem_use)
    peak_mem_use = mem_use;
  return malloc(s);
}

// Assembly:
movq 0x2dd1(%rip), %rax      # 0x4048
addq %rdi, %rax
movq %rax, 0x2dc7(%rip)      # 0x4048
cmpq 0x2dc8(%rip), %rax      # 0x4050
jbe 0x1050
movq %rax, 0x2dbb(%rip)      # 0x4050
jmp 0x1050
// File: /workspace/github_c_makefile_star2_O2/mincebert[P]maketzx/maketzx.c
// Function: itoa
int itoa (int n, char *buff, int base)
{ int i,l;   // this only works with base <= 10, but who cares...
  l=sizeof(buff);
  for(i=0;i<l;i++)
     { buff[l-1-i]='0'+n%base;
       n/=base;
     }
  return 0;
}

// Assembly:
movl %edx, %ecx
movl %edi, %eax
pushq $0x8
popq %rdi
movq %rdi, %r8
subq $0x1, %r8
jb 0x129b
cltd
idivl %ecx
addb $0x30, %dl
movb %dl, -0x1(%rsi,%rdi)
movq %r8, %rdi
jmp 0x1286
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/mincebert[P]maketzx/maketzx.c
// Function: strupr
char *strupr(char *s)
{ int i,l;
  l=strlen(s);
  for(i=0;i<l;i++) if((s[i]>='a')&&(s[i]<='z')) s[i]-=32;
  return s;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x10a0
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x12ca
movb (%rbx,%rcx), %dl
leal -0x61(%rdx), %esi
cmpb $0x19, %sil
ja 0x12c5
addb $-0x20, %dl
movb %dl, (%rbx,%rcx)
incq %rcx
jmp 0x12ae
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/mincebert[P]maketzx/maketzx.c
// Function: strlwr
char *strlwr(char *s)
{ int i,l;
  l=strlen(s);
  for(i=0;i<l;i++) if((s[i]>='A')&&(s[i]<='Z')) s[i]+=32;
  return s;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x10a0
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x12fb
movb (%rbx,%rcx), %dl
leal -0x41(%rdx), %esi
cmpb $0x19, %sil
ja 0x12f6
orb $0x20, %dl
movb %dl, (%rbx,%rcx)
incq %rcx
jmp 0x12df
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/mincebert[P]maketzx/maketzx.c
// Function: strnset
char *strnset(char *s, int ch, int n)
{ int i;
  if(n>strlen(s)) n=strlen(s);
  for(i=0;i<n;i++) s[i]=ch;
  return s;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
movslq %edx, %r14
callq 0x10a0
cmpq %r14, %rax
cmovbl %eax, %r14d
xorl %eax, %eax
testl %r14d, %r14d
cmovlel %eax, %r14d
cmpq %rax, %r14
je 0x132f
movb %bpl, (%rbx,%rax)
incq %rax
jmp 0x1321
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mincebert[P]maketzx/maketzx.c
// Function: strrev
char *strrev(char *s)
{ int i;
  char c;
  for(i=0;i<(strlen(s)+1)/2;i++)
     { c=s[i];
       s[i]=s[strlen(s)-1-i];
       s[strlen(s)-1-i]=c;
     }
  return s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
leaq -0x1(%rdi), %r14
xorl %r15d, %r15d
movq %rdi, %r12
movq %rbx, %rdi
callq 0x10a0
leaq 0x1(%rax), %rcx
shrq %rcx
cmpq %r15, %rcx
jbe 0x1383
movb (%r12), %bpl
movb (%r14,%rax), %al
movb %al, (%r12)
movq %rbx, %rdi
callq 0x10a0
movb %bpl, (%r14,%rax)
incq %r15
incq %r12
decq %r14
jmp 0x134c
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mincebert[P]maketzx/maketzx.c
// Function: eof
int eof(int h)
{ long l,m;
  l=lseek(h,0,SEEK_CUR);
  m=lseek(h,0,SEEK_END);
  lseek(h,l,SEEK_SET);
  return (l==m);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edi, %ebx
pushq $0x1
popq %rdx
xorl %esi, %esi
callq 0x10d0
movq %rax, %r14
pushq $0x2
popq %rdx
movl %ebx, %edi
xorl %esi, %esi
callq 0x10d0
movq %rax, %r15
movl %ebx, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x10d0
xorl %eax, %eax
cmpq %r15, %r14
sete %al
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/mincebert[P]maketzx/maketzx.c
// Function: CreateFile
byte CreateFile(char* filename)
{
  int handle;
  handle=open(filename,O_CREAT | O_TRUNC | O_RDWR,0666);
  if (handle==-1) { Error(2); }
  return handle;
}

// Assembly:
pushq %rax
movl $0x242, %esi            # imm = 0x242
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x1120
cmpl $-0x1, %eax
je 0x13e5
popq %rcx
retq
pushq $0x2
popq %rdi
callq 0x13ed
// File: /workspace/github_c_makefile_star2_O2/mincebert[P]maketzx/maketzx.c
// Function: OpenFile
byte OpenFile(char* filename)
{
  int handle;
  handle=open(filename,O_RDONLY);
  if (handle==-1) Error(1);
  return handle;
}

// Assembly:
pushq %rax
xorl %esi, %esi
xorl %eax, %eax
callq 0x1120
cmpl $-0x1, %eax
je 0x158f
popq %rcx
retq
pushq $0x1
popq %rdi
callq 0x13ed
// File: /workspace/github_c_makefile_star2_O2/mincebert[P]maketzx/maketzx.c
// Function: CloseFiles
void CloseFiles(void)
{
  close(inpfile.handle);
  if (outfile.bufpoint) Flush(&outfile);
  close(outfile.handle);
  fclose(logfile);
}

// Assembly:
pushq %rax
movzbl 0xdcd1(%rip), %edi      # 0xf270
callq 0x10e0
cmpl $0x0, 0x11edd(%rip)     # 0x13488
je 0x15b9
leaq 0x11dd4(%rip), %rdi     # 0x13388
callq 0x15d2
movzbl 0x11dc8(%rip), %edi     # 0x13388
callq 0x10e0
movq 0x15ed4(%rip), %rdi     # 0x174a0
popq %rax
jmp 0x1090
// File: /workspace/github_c_makefile_star2_O2/mincebert[P]maketzx/maketzx.c
// Function: PushFilePointers
void PushFilePointers(void)
{
  stackitem *pointer;
  byte item=stack1.busy+stack2.busy+stack3.busy+stack4.busy+stack5.busy+1;
  if (item>5) item=5;
  switch (item)
	 {
	   case 1 : pointer=&stack1; break;
	   case 2 : pointer=&stack2; break;
	   case 3 : pointer=&stack3; break;
	   case 4 : pointer=&stack4; break;
	   case 5 : pointer=&stack5; break;
	 }
  (*pointer).busy=1;
  (*pointer).savedir=direction;
  (*pointer).saverev=revsamples;
  (*pointer).savelast=lastsample;
  (*pointer).savebtype=blocktype;
  (*pointer).savepos=filepos;
  (*pointer).savetotal=totalread;
  (*pointer).saveprocess=processed;
  (*pointer).saveblocklen=blocklength;
}

// Assembly:
movb 0x19fa2(%rip), %al      # 0x1b5c0
addb 0x19fcc(%rip), %al      # 0x1b5f0
addb 0x19ff6(%rip), %al      # 0x1b620
addb 0x1a020(%rip), %al      # 0x1b650
addb 0x1a04a(%rip), %al      # 0x1b680
incb %al
movzbl %al, %ecx
cmpb $0x5, %cl
pushq $0x5
popq %rax
cmovbl %ecx, %eax
addb $-0x2, %al
cmpb $0x3, %al
ja 0x165a
movzbl %al, %eax
leaq 0xd784(%rip), %rcx      # 0xedd8
movq (%rcx,%rax,8), %rax
jmp 0x1661
leaq 0x19f5f(%rip), %rax     # 0x1b5c0
movb $0x1, (%rax)
movb 0xda77(%rip), %cl       # 0xf0e1
movb %cl, 0x1(%rax)
movq 0xdb84(%rip), %rcx      # 0xf1f8
movq %rcx, 0x8(%rax)
movb 0x1a032(%rip), %cl      # 0x1b6b0
movb %cl, 0x3(%rax)
movb 0x1a02a(%rip), %cl      # 0x1b6b1
movb %cl, 0x2(%rax)
movq 0xdb47(%rip), %rcx      # 0xf1d8
movq %rcx, 0x10(%rax)
movq 0xdb24(%rip), %rcx      # 0xf1c0
movq %rcx, 0x18(%rax)
movq 0xdb11(%rip), %rcx      # 0xf1b8
movq %rcx, 0x20(%rax)
movq 0xdafe(%rip), %rcx      # 0xf1b0
movq %rcx, 0x28(%rax)
retq
// File: /workspace/github_c_makefile_star2_O2/mincebert[P]maketzx/maketzx.c
// Function: PopFilePointers
void PopFilePointers(void)
{
  stackitem *pointer;
  byte item=stack1.busy+stack2.busy+stack3.busy+stack4.busy+stack5.busy;
  switch (item)
	 {
	   case 0 :
	   case 1 : pointer=&stack1; break;
	   case 2 : pointer=&stack2; break;
	   case 3 : pointer=&stack3; break;
	   case 4 : pointer=&stack4; break;
	   case 5 : pointer=&stack5; break;
	 }
  (*pointer).busy=0;
  direction=(*pointer).savedir;
  revsamples=(*pointer).saverev;
  lastsample=(*pointer).savelast;
  blocktype=(*pointer).savebtype;
  filepos=(*pointer).savepos;
  totalread=(*pointer).savetotal;
  processed=(*pointer).saveprocess;
  blocklength=(*pointer).saveblocklen;
}

// Assembly:
movb 0x19f33(%rip), %al      # 0x1b5f0
addb 0x19efd(%rip), %al      # 0x1b5c0
addb 0x19f57(%rip), %al      # 0x1b620
addb 0x19f81(%rip), %al      # 0x1b650
addb 0x19fab(%rip), %al      # 0x1b680
addb $-0x2, %al
cmpb $0x3, %al
ja 0x16eb
movzbl %al, %eax
leaq 0xd6f3(%rip), %rcx      # 0xedd8
movq (%rcx,%rax,8), %rax
jmp 0x16f2
leaq 0x19ece(%rip), %rax     # 0x1b5c0
movb $0x0, (%rax)
movb 0x1(%rax), %cl
movb %cl, 0xd9e3(%rip)       # 0xf0e1
movq 0x8(%rax), %rcx
movq %rcx, 0xdaef(%rip)      # 0xf1f8
movb 0x3(%rax), %cl
movb %cl, 0x19f9e(%rip)      # 0x1b6b0
movb 0x2(%rax), %cl
movb %cl, 0x19f96(%rip)      # 0x1b6b1
movq 0x10(%rax), %rcx
movq %rcx, 0xdab2(%rip)      # 0xf1d8
movq 0x18(%rax), %rcx
movq %rcx, 0xda8f(%rip)      # 0xf1c0
movq 0x20(%rax), %rcx
movq %rcx, 0xda7c(%rip)      # 0xf1b8
movq 0x28(%rax), %rax
movq %rax, 0xda69(%rip)      # 0xf1b0
retq