// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rdi, %r14
movl (%rsi), %esi
cmpl $0x1000082, %esi        # imm = 0x1000082
movq %rax, 0x40(%rsp)
jne 0x3266
movq %rdx, %r15
leaq 0x28(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x4774
movq (%r12), %rax
cmpq %rax, 0x8(%r12)
je 0x3127
movl $0xfeffff7d, %edx       # imm = 0xFEFFFF7D
movabsq $-0x1111111111111111, %rbx # imm = 0xEEEEEEEEEEEEEEEF
leaq 0xd1dd(%rip), %rsi      # 0x10004
xorl %r12d, %r12d
movq %r14, 0x8(%rsp)
leaq (%r12,%r12,4), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx), %r13
cmpb $-0x1, 0x4(%rax,%rcx)
je 0x31a6
movl (%r13), %eax
addl %edx, %eax
cmpl $0x6, %eax
ja 0x310a
movslq (%rsi,%rax,4), %rax
addq %rsi, %rax
jmpq *%rax
movq 0x7(%r13), %rax
testq %rax, %rax
je 0x308b
cmpw $0x0, 0x5(%r13)
je 0x308b
movb (%rax), %al
jmp 0x308d
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x4774
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rax
movl $0x6, 0x4(%rsp)
cmpq %r13, %rax
je 0x3068
movl $0x7, %ebp
xorl %r14d, %r14d
cmpb $-0x1, -0x3(%r13,%rbp)
je 0x306c
movl -0x7(%r13,%rbp), %esi
movq (%r13,%rbp), %rcx
cmpl $0x1000088, %esi        # imm = 0x1000088
je 0x2ee9
cmpl $0x1000087, %esi        # imm = 0x1000087
jne 0x2efb
testq %rcx, %rcx
je 0x2f28
cmpw $0x0, -0x2(%r13,%rbp)
je 0x2f28
movb (%rcx), %cl
jmp 0x2f2a
testq %rcx, %rcx
je 0x2f30
cmpw $0x0, -0x2(%r13,%rbp)
je 0x2f30
movb (%rcx), %cl
jmp 0x2f32
xorl %edx, %edx
testq %rcx, %rcx
je 0x2f0e
cmpw $0x0, -0x2(%r13,%rbp)
je 0x2f0e
movzbl (%rcx), %edx
leaq 0xd1bf(%rip), %rdi      # 0x100d4
xorl %eax, %eax
callq 0x2040
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rax
jmp 0x2f36
xorl %ecx, %ecx
movb %cl, 0x3(%r15)
jmp 0x2f36
xorl %ecx, %ecx
movb %cl, 0x4(%r15)
incq %r14
movq %rax, %rcx
subq %r13, %rcx
imulq %rbx, %rcx
addq $0xf, %rbp
cmpq %rcx, %r14
jb 0x2eb1
jmp 0x3047
movq 0x7(%r13), %rax
testq %rax, %rax
je 0x3092
cmpw $0x0, 0x5(%r13)
je 0x3092
movb (%rax), %al
jmp 0x3094
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x4774
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rax
movl $0x6, 0x4(%rsp)
cmpq %r13, %rax
je 0x3068
movl $0x7, %ebp
xorl %r14d, %r14d
cmpb $-0x1, -0x3(%r13,%rbp)
je 0x306c
movl -0x7(%r13,%rbp), %esi
movq (%r13,%rbp), %rcx
cmpl $0x1000088, %esi        # imm = 0x1000088
je 0x2fe0
cmpl $0x1000087, %esi        # imm = 0x1000087
jne 0x2ff2
testq %rcx, %rcx
je 0x301f
cmpw $0x0, -0x2(%r13,%rbp)
je 0x301f
movb (%rcx), %cl
jmp 0x3021
testq %rcx, %rcx
je 0x3027
cmpw $0x0, -0x2(%r13,%rbp)
je 0x3027
movb (%rcx), %cl
jmp 0x3029
xorl %edx, %edx
testq %rcx, %rcx
je 0x3005
cmpw $0x0, -0x2(%r13,%rbp)
je 0x3005
movzbl (%rcx), %edx
leaq 0xd0c8(%rip), %rdi      # 0x100d4
xorl %eax, %eax
callq 0x2040
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rax
jmp 0x302d
xorl %ecx, %ecx
movb %cl, 0x5(%r15)
jmp 0x302d
xorl %ecx, %ecx
movb %cl, 0x6(%r15)
incq %r14
movq %rax, %rcx
subq %r13, %rcx
imulq %rbx, %rcx
addq $0xf, %rbp
cmpq %rcx, %r14
jb 0x2fa8
xorl %ebp, %ebp
movq 0x8(%rsp), %r14
jmp 0x30e0
movq 0x7(%r13), %rax
testq %rax, %rax
je 0x309a
cmpw $0x0, 0x5(%r13)
je 0x309a
movb (%rax), %al
jmp 0x309c
xorl %ebp, %ebp
jmp 0x30e0
movq (%r13,%rbp), %rsi
testq %rsi, %rsi
je 0x30a2
movzwl -0x2(%r13,%rbp), %edx
cmpq $0x4, %rdx
movq 0x8(%rsp), %r14
jb 0x30ab
movl (%rsi), %edx
jmp 0x30bd
xorl %eax, %eax
movb %al, (%r15)
jmp 0x310a
xorl %eax, %eax
movb %al, 0x1(%r15)
jmp 0x310a
xorl %eax, %eax
movb %al, 0x2(%r15)
jmp 0x310a
xorl %edx, %edx
movq 0x8(%rsp), %r14
jmp 0x30bd
movl $0x0, (%rsp)
movq %rsp, %rdi
callq 0x20f0
movl (%rsp), %edx
movl -0x7(%r13,%rbp), %esi
leaq 0xcfe7(%rip), %rdi      # 0x100b0
xorl %eax, %eax
callq 0x2040
movl $0x1, 0x4(%rsp)
movb $0x1, %bpl
movq 0x10(%rsp), %r13
testq %r13, %r13
je 0x30f5
movq 0x20(%rsp), %rsi
subq %r13, %rsi
movq %r13, %rdi
callq 0x2160
testb %bpl, %bpl
movl $0xfeffff7d, %edx       # imm = 0xFEFFFF7D
leaq 0xcf00(%rip), %rsi      # 0x10004
jne 0x3202
incq %r12
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
subq %rax, %rcx
imulq %rbx, %rcx
cmpq %rcx, %r12
jb 0x2e2f
movzbl 0x1(%r15), %eax
cmpq $0x6, %rax
ja 0x3142
leaq 0xcf43(%rip), %rcx      # 0x1007c
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
jmp 0x3149
leaq 0xd00d(%rip), %rdi      # 0x10156
xorl %eax, %eax
callq 0x2040
movb (%r15), %al
cmpb $0x1, %al
leaq 0xd014(%rip), %rcx      # 0x10170
leaq 0xd01c(%rip), %rdx      # 0x1017f
cmoveq %rcx, %rdx
testb %al, %al
leaq 0xcff4(%rip), %rdi      # 0x10164
cmovneq %rdx, %rdi
xorl %eax, %eax
callq 0x2040
movzbl 0x2(%r15), %eax
testl %eax, %eax
je 0x31be
cmpl $0x1, %eax
jne 0x31e2
movzbl 0x3(%r15), %esi
movzbl 0x4(%r15), %edx
movzbl 0x5(%r15), %ecx
movzbl 0x6(%r15), %r8d
leaq 0xcfe9(%rip), %rdi      # 0x1018d
jmp 0x31d9
movq 0x7(%r13), %rsi
testq %rsi, %rsi
je 0x31fe
movzwl 0x5(%r13), %edx
cmpq $0x4, %rdx
jb 0x320c
movl (%rsi), %edx
jmp 0x3223
movzbl 0x3(%r15), %esi
movzbl 0x4(%r15), %edx
movzbl 0x5(%r15), %ecx
movzbl 0x6(%r15), %r8d
leaq 0xcfd4(%rip), %rdi      # 0x101ad
xorl %eax, %eax
callq 0x2040
jmp 0x31f0
leaq 0xcfe4(%rip), %rdi      # 0x101cd
xorl %eax, %eax
callq 0x2040
movl $0xa, %edi
callq 0x21b0
xorl %ebx, %ebx
jmp 0x3237
xorl %edx, %edx
jmp 0x3223
cmpl $0x1, 0x4(%rsp)
sete %bl
jmp 0x3237
leaq 0x10(%rsp), %r15
movl $0x0, (%r15)
movq %r15, %rdi
callq 0x20f0
movl (%r15), %edx
movl (%r13), %esi
leaq 0xce82(%rip), %rdi      # 0x100b0
xorl %eax, %eax
callq 0x2040
movb $0x1, %bl
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x324e
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
testb %bl, %bl
je 0x326e
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdi
callq 0x22a0
movq %r14, %rdi
movq 0x40(%rsp), %rsi
callq 0x588e
jmp 0x327d
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x3297
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
movq %rbx, %rdi
callq 0x2240