// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/watchdog.cpp
// Function: PidTracker::findMainPID(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
int PidTracker::findMainPID(const std::string& mainPidFileHint) 
{
	  std::vector<int> candidates;

	  if (!mainPidFileHint.empty()) 
	  {
		std::ifstream ifs(mainPidFileHint);
		std::string pids;
		ifs >> pids;
		printf("PidTracker: main-PID hint: %s\n", pids.c_str());
		int pid = std::stoi(pids);
		if (pid != 0) 
		{
		  return pid;
		}
	  }

	  for (int pid : collectAll()) 
	  {
		if (getppid(pid) == getpid()) 
		{
		  if (getExe(pid) == mainExe_) 
		  {
			candidates.push_back(pid);
		  }
		}
	  }

	  return !candidates.empty() ? candidates.front() : 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1098, %rsp           # imm = 0x1098
movq %rdi, -0x88(%rbp)
andq $0x0, -0x70(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
cmpq $0x0, 0x8(%rsi)
je 0x501c
leaq -0x10c0(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x35a0
leaq -0x50(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x10c0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3450
leaq -0x60(%rbp), %rbx
movq (%rbx), %rsi
leaq 0x2213(%rip), %rdi      # 0x71fc
xorl %eax, %eax
callq 0x3040
pushq $0xa
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5c0c
movl %eax, %ebx
leaq -0x60(%rbp), %rdi
callq 0x3160
leaq -0x10c0(%rbp), %rdi
callq 0x30a0
testl %ebx, %ebx
jne 0x515e
leaq -0xa0(%rbp), %rdi
callq 0x4e76
movq -0xa0(%rbp), %r13
movq -0x98(%rbp), %rbx
leaq -0x10c0(%rbp), %r15
leaq -0x60(%rbp), %r14
cmpq %rbx, %r13
je 0x5142
movl (%r13), %ecx
movl %ecx, -0x30(%rbp)
xorl %r12d, %r12d
movq %r15, %rdi
pushq $0x40
popq %rsi
leaq 0x2485(%rip), %rdx      # 0x74e6
xorl %eax, %eax
callq 0x3590
movq %r15, %rdi
leaq 0x2161(%rip), %rsi      # 0x71d3
callq 0x3410
testq %rax, %rax
je 0x50a3
movq %rax, %rdi
leaq 0x246e(%rip), %rsi      # 0x74f4
leaq -0xc0(%rbp), %rdx
movq %r14, %rcx
leaq -0x29(%rbp), %r8
leaq -0x34(%rbp), %r9
xorl %eax, %eax
callq 0x3660
movl -0x34(%rbp), %r12d
callq 0x3520
cmpl %eax, %r12d
jne 0x5139
movl -0x30(%rbp), %ecx
leaq -0xc0(%rbp), %r12
movq %r12, %rdi
pushq $0x1b
popq %rsi
leaq 0x2438(%rip), %rdx      # 0x7500
xorl %eax, %eax
callq 0x3590
movl $0xfff, %edx            # imm = 0xFFF
movq %r12, %rdi
movq %r15, %rsi
callq 0x33d0
leaq -0x50(%rbp), %rcx
movq %rcx, -0x60(%rbp)
testq %rax, %rax
jle 0x5104
leaq (%rax,%rbp), %rdx
addq $-0x10c0, %rdx          # imm = 0xEF40
movq %r14, %rdi
movq %r15, %rsi
callq 0x6416
jmp 0x510d
andq $0x0, -0x58(%rbp)
movb $0x0, -0x50(%rbp)
movq %r14, %rdi
movq -0x88(%rbp), %rsi
callq 0x5c2d
movl %eax, %r12d
movq %r14, %rdi
callq 0x3160
testb %r12b, %r12b
je 0x5139
leaq -0x80(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x5c50
addq $0x4, %r13
jmp 0x5041
leaq -0xa0(%rbp), %rdi
callq 0x64c2
movq -0x80(%rbp), %rax
cmpq -0x78(%rbp), %rax
je 0x515c
movl (%rax), %ebx
jmp 0x515e
xorl %ebx, %ebx
leaq -0x80(%rbp), %rdi
callq 0x64c2
movl %ebx, %eax
addq $0x1098, %rsp           # imm = 0x1098
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5199
jmp 0x517f
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x3160
leaq -0x10c0(%rbp), %rdi
callq 0x30a0
jmp 0x51af
movq %rax, %rbx
jmp 0x51af
jmp 0x51a0
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x64c2
leaq -0x80(%rbp), %rdi
callq 0x64c2
movq %rbx, %rdi
callq 0x3600