// File: /workspace/github_c_makefile_star2_O0/buf1024[P]mysch/mysch.c
// Function: build_condition
int build_condition(prog_t* prog, const char* cond)
{
    char daytimes[128][64] = { { 0 } };
    int num = 0;

    LOG_DEBUG("condition: %s\n", cond);
    num = split(cond, '|', (char **) daytimes, 64, 128);
    if (num <= 0) {
        LOG_ERROR("split %s failed.\n", cond);
        return -1;
    }

    prog->cond = list_create();

    int fail = 0;
    int i = 0;
    for (i = 0; i < num; i++) {
        char daytime[2][64] = { { 0 } };
        int dtnum = 0;

        dtnum = split(daytimes[i], ',', (char**)daytime, 64, 2);
        if(dtnum != 2) {
            LOG_ERROR("split %s failed.\n", daytimes[i]);
            fail = 1;
            break;
        }

        if(strlen(daytime[0]) != 3 || daytime[0][1] != '-') {
            LOG_ERROR("day time format not ritht: day = %s\n", daytime[0]);
            fail = 1;
            break;
        }
        int d_start = atoi(daytime[0]);
        int d_end = atoi(daytime[0] + 2);

        if(d_start > d_end || d_start <= 0 || d_end <= 0 ||
                d_start > 7 || d_end > 7) {
            LOG_ERROR("day format not ritht: day = %s\n", daytime[0]);
            fail = 1;
            break;
        }

        int t_start, t_end;
		if (prog->flag != FORK_PERIOD) {
			char times[2][64] = { { 0 } };
			int tnum = 0;
			tnum = split(daytime[1], '-', (char**) times, 64, 2);
			if (tnum != 2) {
				LOG_ERROR("split %s failed.\n", daytimes[i]);
				fail = 1;
				break;
			}
			if (strlen(times[0]) != 5 || times[0][2] != ':'
					|| strlen(times[1]) != 5 || times[1][2] != ':') {
				LOG_ERROR("time split format not ritht. time1=%s, times2=%s\n",
						times[0], times[1]);
				fail = 1;
				break;
			}

			t_start = atoi(times[0]) * 3600 + atoi(times[0] + 3) * 60;
			t_end = atoi(times[1]) * 3600 + atoi(times[1] + 3) * 60;

			if (t_start >= t_end || t_start < 0 || t_end < 0 || t_start > 86400
					|| t_end > 86400) {
				LOG_ERROR(
						"time data format not ritht. time1=%s, times2=%s, start=%d, end=%d\n",
						times[0], times[1], t_start, t_end);
				fail = 1;
				break;
			}

		}else{
			t_start = atoi(daytime[1]) * 60;
			t_end = t_start;
		}

        LOG_DEBUG("condition: daystart=%d, dayend=%d, timestart=%d, timeend=%d\n",
                d_start, d_end, t_start, t_end);

        cond_t* c = (cond_t*)malloc(sizeof(*c));
        memset(c, 0, sizeof(*c));

        int i = 0;
        for(i=d_start; i<=d_end; i++) {
            c->day[i] = 1;
        }
        c->start = t_start;
        c->end = t_end;

        list_add_node_tail(prog->cond, c);
    }

    if(fail) {
        list_release(prog->cond, AL_FREE);
        return -1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2170, %rsp           # imm = 0x2170
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x2020(%rbp), %rdi
xorl %esi, %esi
movl $0x2000, %edx           # imm = 0x2000
callq 0x2190
movl $0x0, -0x2024(%rbp)
movq -0x18(%rbp), %rsi
leaq 0x1ef8(%rip), %rdi      # 0xa663
movb $0x0, %al
callq 0x5520
movq -0x18(%rbp), %rdi
leaq -0x2020(%rbp), %rdx
movl $0x7c, %esi
movl $0x40, %ecx
movl $0x80, %r8d
callq 0x7110
movl %eax, -0x2024(%rbp)
cmpl $0x0, -0x2024(%rbp)
jg 0x87c1
jmp 0x87a3
movq -0x18(%rbp), %rsi
leaq 0x1cbc(%rip), %rdi      # 0xa46a
movb $0x0, %al
callq 0x58a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8c8b
callq 0x3cb0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa58(%rax)
movl $0x0, -0x2028(%rbp)
movl $0x0, -0x202c(%rbp)
movl $0x0, -0x202c(%rbp)
movl -0x202c(%rbp), %eax
cmpl -0x2024(%rbp), %eax
jge 0x8c60
leaq -0x20b0(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x2190
movl $0x0, -0x20b4(%rbp)
movslq -0x202c(%rbp), %rax
leaq -0x2020(%rbp), %rdi
shlq $0x6, %rax
addq %rax, %rdi
leaq -0x20b0(%rbp), %rdx
movl $0x2c, %esi
movl $0x40, %ecx
movl $0x2, %r8d
callq 0x7110
movl %eax, -0x20b4(%rbp)
cmpl $0x2, -0x20b4(%rbp)
je 0x8895
jmp 0x8863
movslq -0x202c(%rbp), %rax
leaq -0x2020(%rbp), %rsi
shlq $0x6, %rax
addq %rax, %rsi
leaq 0x1beb(%rip), %rdi      # 0xa46a
movb $0x0, %al
callq 0x58a0
movl $0x1, -0x2028(%rbp)
jmp 0x8c60
leaq -0x20b0(%rbp), %rdi
callq 0x2120
cmpq $0x3, %rax
jne 0x88b3
movsbl -0x20af(%rbp), %eax
cmpl $0x2d, %eax
je 0x88d9
jmp 0x88b5
leaq -0x20b0(%rbp), %rsi
leaq 0x1daf(%rip), %rdi      # 0xa672
movb $0x0, %al
callq 0x58a0
movl $0x1, -0x2028(%rbp)
jmp 0x8c60
leaq -0x20b0(%rbp), %rdi
callq 0x2330
movl %eax, -0x20b8(%rbp)
leaq -0x20b0(%rbp), %rdi
addq $0x2, %rdi
callq 0x2330
movl %eax, -0x20bc(%rbp)
movl -0x20b8(%rbp), %eax
cmpl -0x20bc(%rbp), %eax
jg 0x8933
cmpl $0x0, -0x20b8(%rbp)
jle 0x8933
cmpl $0x0, -0x20bc(%rbp)
jle 0x8933
cmpl $0x7, -0x20b8(%rbp)
jg 0x8933
cmpl $0x7, -0x20bc(%rbp)
jle 0x8959
jmp 0x8935
leaq -0x20b0(%rbp), %rsi
leaq 0x1d54(%rip), %rdi      # 0xa697
movb $0x0, %al
callq 0x58a0
movl $0x1, -0x2028(%rbp)
jmp 0x8c60
movq -0x10(%rbp), %rax
cmpl $0x2, 0xa50(%rax)
je 0x8b58
leaq -0x2150(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x2190
movl $0x0, -0x2154(%rbp)
leaq -0x20b0(%rbp), %rdi
addq $0x40, %rdi
leaq -0x2150(%rbp), %rdx
movl $0x2d, %esi
movl $0x40, %ecx
movl $0x2, %r8d
callq 0x7110
movl %eax, -0x2154(%rbp)
cmpl $0x2, -0x2154(%rbp)
je 0x89f1
jmp 0x89bf
movslq -0x202c(%rbp), %rax
leaq -0x2020(%rbp), %rsi
shlq $0x6, %rax
addq %rax, %rsi
leaq 0x1a8f(%rip), %rdi      # 0xa46a
movb $0x0, %al
callq 0x58a0
movl $0x1, -0x2028(%rbp)
jmp 0x8c60
leaq -0x2150(%rbp), %rdi
callq 0x2120
cmpq $0x5, %rax
jne 0x8a31
movsbl -0x214e(%rbp), %eax
cmpl $0x3a, %eax
jne 0x8a31
leaq -0x2150(%rbp), %rdi
addq $0x40, %rdi
callq 0x2120
cmpq $0x5, %rax
jne 0x8a31
movsbl -0x210e(%rbp), %eax
cmpl $0x3a, %eax
je 0x8a62
jmp 0x8a33
leaq -0x2150(%rbp), %rsi
leaq -0x2150(%rbp), %rdx
addq $0x40, %rdx
leaq 0x1c6b(%rip), %rdi      # 0xa6b7
movb $0x0, %al
callq 0x58a0
movl $0x1, -0x2028(%rbp)
jmp 0x8c60
leaq -0x2150(%rbp), %rdi
callq 0x2330
imull $0xe10, %eax, %eax      # imm = 0xE10
movl %eax, -0x216c(%rbp)
leaq -0x2150(%rbp), %rdi
addq $0x3, %rdi
callq 0x2330
movl %eax, %ecx
movl -0x216c(%rbp), %eax
imull $0x3c, %ecx, %ecx
addl %ecx, %eax
movl %eax, -0x20c0(%rbp)
leaq -0x2150(%rbp), %rdi
addq $0x40, %rdi
callq 0x2330
imull $0xe10, %eax, %eax      # imm = 0xE10
movl %eax, -0x2168(%rbp)
leaq -0x2150(%rbp), %rdi
addq $0x40, %rdi
addq $0x3, %rdi
callq 0x2330
movl %eax, %ecx
movl -0x2168(%rbp), %eax
imull $0x3c, %ecx, %ecx
addl %ecx, %eax
movl %eax, -0x20c4(%rbp)
movl -0x20c0(%rbp), %eax
cmpl -0x20c4(%rbp), %eax
jge 0x8b18
cmpl $0x0, -0x20c0(%rbp)
jl 0x8b18
cmpl $0x0, -0x20c4(%rbp)
jl 0x8b18
cmpl $0x15180, -0x20c0(%rbp) # imm = 0x15180
jg 0x8b18
cmpl $0x15180, -0x20c4(%rbp) # imm = 0x15180
jle 0x8b56
jmp 0x8b1a
leaq -0x2150(%rbp), %rsi
leaq -0x2150(%rbp), %rdx
addq $0x40, %rdx
movl -0x20c0(%rbp), %ecx
movl -0x20c4(%rbp), %r8d
leaq 0x1ba9(%rip), %rdi      # 0xa6e9
movb $0x0, %al
callq 0x58a0
movl $0x1, -0x2028(%rbp)
jmp 0x8c60
jmp 0x8b7d
leaq -0x20b0(%rbp), %rdi
addq $0x40, %rdi
callq 0x2330
imull $0x3c, %eax, %eax
movl %eax, -0x20c0(%rbp)
movl -0x20c0(%rbp), %eax
movl %eax, -0x20c4(%rbp)
jmp 0x8b7f
movl -0x20b8(%rbp), %esi
movl -0x20bc(%rbp), %edx
movl -0x20c0(%rbp), %ecx
movl -0x20c4(%rbp), %r8d
leaq 0x1b8d(%rip), %rdi      # 0xa72c
movb $0x0, %al
callq 0x5520
movl $0x18, %edi
callq 0x22b0
movq %rax, -0x2160(%rbp)
movq -0x2160(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2190
movl $0x0, -0x2164(%rbp)
movl -0x20b8(%rbp), %eax
movl %eax, -0x2164(%rbp)
movl -0x2164(%rbp), %eax
cmpl -0x20bc(%rbp), %eax
jg 0x8c11
movq -0x2160(%rbp), %rax
movslq -0x2164(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movl -0x2164(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2164(%rbp)
jmp 0x8be0
movslq -0x20c0(%rbp), %rcx
movq -0x2160(%rbp), %rax
movq %rcx, 0x8(%rax)
movslq -0x20c4(%rbp), %rcx
movq -0x2160(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0xa58(%rax), %rdi
movq -0x2160(%rbp), %rsi
callq 0x3e60
movl -0x202c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x202c(%rbp)
jmp 0x87f2
cmpl $0x0, -0x2028(%rbp)
je 0x8c84
movq -0x10(%rbp), %rax
movq 0xa58(%rax), %rdi
xorl %esi, %esi
callq 0x3d10
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8c8b
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2170, %rsp           # imm = 0x2170
popq %rbp
retq
nopw (%rax,%rax)