// File: /workspace/github_cpp_makefile_star2_O1/rellla[P]E3DC-Rscp/RscpMain.cpp
// Function: handleResponseEMSGetIdlePeriods(RscpProtocol*, SRscpValue*, idle_period_t*)
int
handleResponseEMSGetIdlePeriods(RscpProtocol * protocol,
				SRscpValue * emsData,
				idle_period_t *periods)
{
    // check each idle periods sub tag
    switch (emsData->tag) {
    case TAG_EMS_IDLE_PERIOD:{
	    std::vector < SRscpValue > idleData =
		protocol->getValueAsContainer(emsData);
	    // check each idle period sub tag
	    for (size_t j = 0; j < idleData.size(); ++j) {
		if (idleData[j].dataType == RSCP::eTypeError) {
		    // handle error for example access denied errors
		    uint32_t uiErrorCode =
			protocol->getValueAsUInt32(&idleData[j]);
		    printf("Tag 0x%08X received error code %u.\n",
			   idleData[j].tag, uiErrorCode);
		    return -1;
		}
		switch (idleData[j].tag) {
		case TAG_EMS_IDLE_PERIOD_TYPE:{
			periods->type = protocol->getValueAsUChar8(&idleData[j]);
			break;
		    }
		case TAG_EMS_IDLE_PERIOD_DAY:{
			periods->day = protocol->getValueAsUChar8(&idleData[j]);
			break;
		    }
		case TAG_EMS_IDLE_PERIOD_ACTIVE:{
			periods->active = protocol->getValueAsUChar8(&idleData[j]);
			break;
		    }
		case TAG_EMS_IDLE_PERIOD_START:{
			std::vector < SRscpValue >
			    periodData =
			    protocol->getValueAsContainer(&idleData[j]);
			// check each idle period start sub tag
			for (size_t k = 0; k < periodData.size(); ++k) {
			    if (periodData[k].dataType == RSCP::eTypeError) {
				// handle error for example access denied errors
				uint32_t
				    uiErrorCode =
				    protocol->getValueAsUInt32(&periodData
							       [k]);
				printf
				    ("Tag 0x%08X received error code %u.\n",
				     periodData[k].tag, uiErrorCode);
				return -1;
			    }
			    switch (periodData[k].tag) {
			    case TAG_EMS_IDLE_PERIOD_HOUR:{
				    periods->start.hour =
					protocol->getValueAsUChar8
					(&periodData[k]);
				    break;
				}
			    case TAG_EMS_IDLE_PERIOD_MINUTE:{
				    periods->start.minute =
					protocol->getValueAsUChar8
					(&periodData[k]);
				    break;
				}
			    default:
				// default behaviour
				uint8_t unknown =
				    protocol->getValueAsUChar8(&periodData
							       [k]);
				printf("Unknown period tag %08X -> %i.\n",
				       periodData[k].tag, unknown);
				break;
			    }
			}
			break;
		    }
		case TAG_EMS_IDLE_PERIOD_END:{
			std::vector < SRscpValue >
			    periodData =
			    protocol->getValueAsContainer(&idleData[j]);
			// check each idle period stop sub tag
			for (size_t k = 0; k < periodData.size(); ++k) {
			    if (periodData[k].dataType == RSCP::eTypeError) {
				// handle error for example access denied errors
				uint32_t
				    uiErrorCode =
				    protocol->getValueAsUInt32(&periodData
							       [k]);
				printf
				    ("Tag 0x%08X received error code %u.\n",
				     periodData[k].tag, uiErrorCode);
				return -1;
			    }
			    switch (periodData[k].tag) {
			    case TAG_EMS_IDLE_PERIOD_HOUR:{
				    periods->stop.hour =
					protocol->getValueAsUChar8
					(&periodData[k]);
				    break;
				}
			    case TAG_EMS_IDLE_PERIOD_MINUTE:{
				    periods->stop.minute =
					protocol->getValueAsUChar8
					(&periodData[k]);
				    break;
				}
			    default:
				// default behaviour
				uint8_t unknown =
				    protocol->getValueAsUChar8(&periodData
							       [k]);
				printf("Unknown period tag %08X -> %i.\n",
				       periodData[k].tag, unknown);
				break;
			    }
			}
			break;
		    }
		}
	    }
	    // print idle periods summary
	    if (periods->day == MONDAY)
		printf("Monday:     \t");
	    else if (periods->day == TUESDAY)
		printf("Tuesday:    \t");
	    else if (periods->day == WEDNESDAY)
		printf("Wednesday:  \t");
	    else if (periods->day == THURSDAY)
		printf("Thursday:   \t");
	    else if (periods->day == FRIDAY)
		printf("Friday:     \t");
	    else if (periods->day == SATURDAY)
		printf("Saturday:   \t");
	    else if (periods->day == SUNDAY)
		printf("Sunday:     \t");
	    else
		printf("Unknown day:\t");

	    if (periods->type == LOAD)
		printf("Ladesperre ");
	    else if (periods->type == UNLOAD)
		printf("Entladesperre ");
	    else
		printf("Unknown type!");

	    if (periods->active == ACTIVE)
		printf
		    ("aktiv von %02i:%02i - %02i:%02i",
		     periods->start.hour, periods->start.minute, periods->stop.hour, periods->stop.minute);
	    else if (periods->active == INACTIVE)
		printf
		    ("inaktiv (%02i:%02i - %02i:%02i)",
		     periods->start.hour, periods->start.minute, periods->stop.hour, periods->stop.minute);
	    else
		printf("Activity unknown! ");
	    printf("\n");
	    break;
	}
    default:
	// default behaviour
	uint8_t unknown = protocol->getValueAsUChar8(emsData);
	printf("Unknown ems tag %08X -> %i.\n", emsData->tag, unknown);
	break;
    }
    protocol->destroyValueData(emsData);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rax
movl (%rsi), %ebx
cmpl $0x1000082, %ebx        # imm = 0x1000082
movq %rdi, 0x20(%rsp)
movq %rsi, 0x28(%rsp)
jne 0x32f7
movq %rdx, %r15
movq %rdi, %r13
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x4940
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0x31a1
movl $0xfeffff7d, %r12d      # imm = 0xFEFFFF7D
xorl %r14d, %r14d
leaq (%r14,%r14,4), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx), %rbx
cmpb $-0x1, 0x4(%rax,%rcx)
je 0x31ab
movl (%rbx), %eax
addl %r12d, %eax
cmpl $0x6, %eax
ja 0x317a
leaq 0xd22b(%rip), %rcx      # 0x10004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x7(%rbx), %rsi
testq %rsi, %rsi
je 0x30da
movzwl 0x5(%rbx), %edx
testq %rdx, %rdx
je 0x30e6
movb (%rsi), %al
jmp 0x30f9
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x4940
movq 0x8(%rsp), %rbp
movl $0x6, 0x4(%rsp)
cmpq %rbp, 0x10(%rsp)
setne %bl
je 0x315b
cmpb $-0x1, 0x4(%rbp)
je 0x30a1
xorl %r13d, %r13d
xorl %r12d, %r12d
movl (%rbp), %ebx
movq 0x7(%rbp), %rsi
cmpl $0x1000088, %ebx        # imm = 0x1000088
je 0x2e67
cmpl $0x1000087, %ebx        # imm = 0x1000087
jne 0x2e79
testq %rsi, %rsi
je 0x2e8b
movzwl 0x5(%rbp), %edx
testq %rdx, %rdx
je 0x2e97
movb (%rsi), %al
jmp 0x2ea6
testq %rsi, %rsi
je 0x2e8f
movzwl 0x5(%rbp), %edx
testq %rdx, %rdx
je 0x2eac
movb (%rsi), %al
jmp 0x2ebb
testq %rsi, %rsi
je 0x2e93
movzwl 0x5(%rbp), %edx
testq %rdx, %rdx
je 0x2ec1
movb (%rsi), %al
jmp 0x2ed0
xorl %eax, %eax
jmp 0x2ea6
xorl %eax, %eax
jmp 0x2ebb
xorl %eax, %eax
jmp 0x2ed0
movb $0x0, (%rsp)
movq %rsp, %rdi
callq 0x20f0
movb (%rsp), %al
movb %al, 0x3(%r15)
jmp 0x2ee3
movb $0x0, (%rsp)
movq %rsp, %rdi
callq 0x20f0
movb (%rsp), %al
movb %al, 0x4(%r15)
jmp 0x2ee3
movb $0x0, (%rsp)
movq %rsp, %rdi
callq 0x20f0
movb (%rsp), %al
movzbl %al, %edx
leaq 0xd1fa(%rip), %rdi      # 0x100d4
movl %ebx, %esi
xorl %eax, %eax
callq 0x2040
incq %r12
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
subq %rax, %rcx
movabsq $-0x1111111111111111, %rdx # imm = 0xEEEEEEEEEEEEEEEF
imulq %rdx, %rcx
cmpq %rcx, %r12
setb %bl
jae 0x30ca
leaq 0xf(%r13), %rcx
leaq (%r12,%r12,4), %rdx
leaq (%rdx,%rdx,2), %rbp
addq %rax, %rbp
cmpb $-0x1, 0x13(%rax,%r13)
movq %rcx, %r13
jne 0x2e3e
jmp 0x3075
movq 0x7(%rbx), %rsi
testq %rsi, %rsi
je 0x30de
movzwl 0x5(%rbx), %edx
testq %rdx, %rdx
je 0x30fe
movb (%rsi), %al
jmp 0x3111
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x4940
movq 0x8(%rsp), %rbp
movl $0x6, 0x4(%rsp)
cmpq %rbp, 0x10(%rsp)
setne %bl
je 0x315b
cmpb $-0x1, 0x4(%rbp)
je 0x30a1
xorl %r13d, %r13d
xorl %r12d, %r12d
movl (%rbp), %ebx
movq 0x7(%rbp), %rsi
cmpl $0x1000088, %ebx        # imm = 0x1000088
je 0x2fb5
cmpl $0x1000087, %ebx        # imm = 0x1000087
jne 0x2fc7
testq %rsi, %rsi
je 0x2fd9
movzwl 0x5(%rbp), %edx
testq %rdx, %rdx
je 0x2fe5
movb (%rsi), %al
jmp 0x2ff4
testq %rsi, %rsi
je 0x2fdd
movzwl 0x5(%rbp), %edx
testq %rdx, %rdx
je 0x2ffa
movb (%rsi), %al
jmp 0x3009
testq %rsi, %rsi
je 0x2fe1
movzwl 0x5(%rbp), %edx
testq %rdx, %rdx
je 0x300f
movb (%rsi), %al
jmp 0x301e
xorl %eax, %eax
jmp 0x2ff4
xorl %eax, %eax
jmp 0x3009
xorl %eax, %eax
jmp 0x301e
movb $0x0, (%rsp)
movq %rsp, %rdi
callq 0x20f0
movb (%rsp), %al
movb %al, 0x5(%r15)
jmp 0x3031
movb $0x0, (%rsp)
movq %rsp, %rdi
callq 0x20f0
movb (%rsp), %al
movb %al, 0x6(%r15)
jmp 0x3031
movb $0x0, (%rsp)
movq %rsp, %rdi
callq 0x20f0
movb (%rsp), %al
movzbl %al, %edx
leaq 0xd0ac(%rip), %rdi      # 0x100d4
movl %ebx, %esi
xorl %eax, %eax
callq 0x2040
incq %r12
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
subq %rax, %rcx
movabsq $-0x1111111111111111, %rdx # imm = 0xEEEEEEEEEEEEEEEF
imulq %rdx, %rcx
cmpq %rcx, %r12
setb %bl
jae 0x30ca
leaq 0xf(%r13), %rcx
leaq (%r12,%r12,4), %rdx
leaq (%rdx,%rdx,2), %rbp
addq %rax, %rbp
cmpb $-0x1, 0x13(%rax,%r13)
movq %rcx, %r13
jne 0x2f8c
addq %rax, %rcx
movq %rcx, %rbp
movq 0x20(%rsp), %r13
movl $0xfeffff7d, %r12d      # imm = 0xFEFFFF7D
jmp 0x30a4
movq 0x7(%rbx), %rsi
testq %rsi, %rsi
je 0x30e2
movzwl 0x5(%rbx), %edx
testq %rdx, %rdx
je 0x3117
movb (%rsi), %al
jmp 0x312a
movq %rbp, %rax
xorl %edx, %edx
testq %rax, %rax
je 0x3142
movq 0x7(%rbp), %rsi
testq %rsi, %rsi
je 0x3142
movzwl 0x5(%rbp), %edx
cmpq $0x4, %rdx
jb 0x3130
movl (%rsi), %edx
jmp 0x3142
movq 0x20(%rsp), %r13
movl $0xfeffff7d, %r12d      # imm = 0xFEFFFF7D
jmp 0x315b
xorl %eax, %eax
jmp 0x30f9
xorl %eax, %eax
jmp 0x3111
xorl %eax, %eax
jmp 0x312a
movb $0x0, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x20f0
movb 0x8(%rsp), %al
movb %al, (%r15)
jmp 0x317a
movb $0x0, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x20f0
movb 0x8(%rsp), %al
movb %al, 0x1(%r15)
jmp 0x317a
movb $0x0, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x20f0
movb 0x8(%rsp), %al
movb %al, 0x2(%r15)
jmp 0x317a
movl $0x0, (%rsp)
movq %rsp, %rdi
callq 0x20f0
movl (%rsp), %edx
movl (%rbp), %esi
leaq 0xcf64(%rip), %rdi      # 0x100b0
xorl %eax, %eax
callq 0x2040
movl $0x1, 0x4(%rsp)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3172
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
testb %bl, %bl
jne 0x31fa
incq %r14
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
movabsq $-0x1111111111111111, %rdx # imm = 0xEEEEEEEEEEEEEEEF
imulq %rdx, %rcx
cmpq %rcx, %r14
jb 0x2dad
movl $0x3, 0x4(%rsp)
jmp 0x31fa
xorl %edx, %edx
testq %rax, %rax
je 0x31e2
movq 0x7(%rbx), %rsi
testq %rsi, %rsi
je 0x31e2
movzwl 0x5(%rbx), %edx
cmpq $0x4, %rdx
jb 0x31c9
movl (%rsi), %edx
jmp 0x31e2
leaq 0x8(%rsp), %r12
movl $0x0, (%r12)
movq %r12, %rdi
callq 0x20f0
movl (%r12), %edx
movl (%rbx), %esi
leaq 0xcec5(%rip), %rdi      # 0x100b0
xorl %eax, %eax
callq 0x2040
movl $0x1, 0x4(%rsp)
movl 0x4(%rsp), %ebx
cmpl $0x3, %ebx
jne 0x32c7
movzbl 0x1(%r15), %eax
cmpq $0x6, %rax
ja 0x3222
leaq 0xce63(%rip), %rcx      # 0x1007c
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
jmp 0x3229
leaq 0xcf2d(%rip), %rdi      # 0x10156
xorl %eax, %eax
callq 0x2040
movb (%r15), %al
cmpb $0x1, %al
leaq 0xcf34(%rip), %rcx      # 0x10170
leaq 0xcf3c(%rip), %rdx      # 0x1017f
cmoveq %rcx, %rdx
testb %al, %al
leaq 0xcf14(%rip), %rdi      # 0x10164
cmovneq %rdx, %rdi
xorl %eax, %eax
callq 0x2040
movzbl 0x2(%r15), %eax
testl %eax, %eax
je 0x3286
cmpl $0x1, %eax
jne 0x32aa
movzbl 0x3(%r15), %esi
movzbl 0x4(%r15), %edx
movzbl 0x5(%r15), %ecx
movzbl 0x6(%r15), %r8d
leaq 0xcf09(%rip), %rdi      # 0x1018d
jmp 0x32a1
movzbl 0x3(%r15), %esi
movzbl 0x4(%r15), %edx
movzbl 0x5(%r15), %ecx
movzbl 0x6(%r15), %r8d
leaq 0xcf0c(%rip), %rdi      # 0x101ad
xorl %eax, %eax
callq 0x2040
jmp 0x32b8
leaq 0xcf1c(%rip), %rdi      # 0x101cd
xorl %eax, %eax
callq 0x2040
movl $0xa, %edi
callq 0x21b0
movl $0x2, %ebx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x32de
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
cmpl $0x1, %ebx
jne 0x3342
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7(%rax), %rsi
testq %rsi, %rsi
je 0x3312
movq 0x28(%rsp), %rax
movzwl 0x5(%rax), %edx
testq %rdx, %rdx
je 0x3316
movb (%rsi), %al
jmp 0x332a
xorl %eax, %eax
jmp 0x332a
leaq 0x30(%rsp), %r15
movb $0x0, (%r15)
movq %r15, %rdi
callq 0x20f0
movb (%r15), %al
movzbl %al, %edx
leaq 0xceac(%rip), %rdi      # 0x101e0
movl %ebx, %esi
xorl %eax, %eax
callq 0x2040
movq 0x20(%rsp), %r13
movq %r13, %rdi
movq 0x28(%rsp), %rsi
callq 0x5b04
jmp 0x3351
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x336b
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
movq %rbx, %rdi
callq 0x2240