// File: /workspace/github_cpp_makefile_star2_O2/merelin[P]mediasmartserverd/src/update_monitor.cpp
// Function: UpdateMonitor::GetUpdateStatus(int*, int*)
bool UpdateMonitor::GetUpdateStatus(int* update_count, int* security_update_count)
{
	//For some reason stderr has the result not stdout so we redirect it to stdout.
	FILE* apt_check = popen("/usr/lib/update-notifier/apt-check 2>&1", "r");
	if (apt_check == NULL)
	{
		if (verbose > 1)
		{
			std::cout << "apt-check does not exist or can't be read.\n";
		}
		return false;
	}
	char* line = NULL;
	size_t len = 0;
	int res = getline(&line, &len, apt_check);
	pclose(apt_check);
	if (res == -1 || len < 3)
	{
		if (verbose > 1)
		{
			std::cout << "Couldn't read line. res = " << res << "; len = " << len
				<< "; line = \"" << line << "\"\n";
		}
		return false;
	}
	std::string str_line(line);
	int pos_delim = str_line.find(";");
	if (pos_delim > (int)str_line.length())
	{
		if (verbose > 1)
		{
			std::cout << "Couldn't find seperator ; in apt-check string: \""
				<< line << "\"\n";
		}
		return false;
	}
	*update_count = atoi(str_line.substr(0, pos_delim).c_str());
	*security_update_count = atoi(str_line.substr(pos_delim+1).c_str());
	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x44c0(%rip), %rdi      # 0xa510
leaq 0x464a(%rip), %rsi      # 0xa6a1
callq 0x40c0
testq %rax, %rax
je 0x6148
movq %rax, %r12
movq %rsp, %rdi
andq $0x0, (%rdi)
leaq 0x8(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdx
callq 0x4400
movq %rax, %rbx
movq %r12, %rdi
callq 0x4460
cmpl $-0x1, %ebx
je 0x6164
cmpq $0x2, 0x8(%rsp)
jbe 0x6164
movq (%rsp), %rsi
leaq 0x30(%rsp), %rbx
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x5694
leaq 0x44d6(%rip), %rsi      # 0xa593
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4620
movq %rax, %r12
cmpl 0x8(%rbx), %r12d
setle %bl
jg 0x61d7
movslq %r12d, %rcx
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
xorl %edx, %edx
callq 0x4310
shlq $0x20, %r12
leaq 0x10(%rsp), %r13
movq (%r13), %rdi
callq 0x44d0
movl %eax, (%r15)
movq %r13, %rdi
callq 0x4150
movabsq $0x100000000, %rdx      # imm = 0x100000000
addq %r12, %rdx
sarq $0x20, %rdx
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
pushq $-0x1
popq %rcx
callq 0x4310
leaq 0x10(%rsp), %r15
movq (%r15), %rdi
callq 0x44d0
movl %eax, (%r14)
movq %r15, %rdi
callq 0x4150
jmp 0x6211
leaq 0xa215(%rip), %rax      # 0x10364
cmpl $0x2, (%rax)
jl 0x61d3
movq 0x9e55(%rip), %rdi      # 0xffb0
leaq 0x43d6(%rip), %rsi      # 0xa538
jmp 0x61ce
leaq 0xa1f9(%rip), %rax      # 0x10364
cmpl $0x2, (%rax)
jl 0x61d3
movq 0x9e39(%rip), %rdi      # 0xffb0
leaq 0x43e6(%rip), %rsi      # 0xa564
callq 0x42d0
movq %rax, %rdi
movl %ebx, %esi
callq 0x4540
leaq 0x43eb(%rip), %rsi      # 0xa57f
movq %rax, %rdi
callq 0x42d0
movq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x41e0
leaq 0x43d8(%rip), %rsi      # 0xa588
movq %rax, %rdi
callq 0x42d0
movq (%rsp), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x4527(%rip), %rsi      # 0xa6f2
movq %rax, %rdi
callq 0x42d0
xorl %ebx, %ebx
jmp 0x621b
leaq 0xa186(%rip), %rax      # 0x10364
cmpl $0x2, (%rax)
jl 0x6211
movq 0x9dc6(%rip), %rdi      # 0xffb0
leaq 0x43a4(%rip), %rsi      # 0xa595
callq 0x42d0
movq (%rsp), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x44e9(%rip), %rsi      # 0xa6f2
movq %rax, %rdi
callq 0x42d0
leaq 0x30(%rsp), %rdi
callq 0x4150
movl %ebx, %eax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x622f
jmp 0x622f
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4150
movq %rbx, %rdi
callq 0x4550