// File: /workspace/github_cpp_makefile_star2_O1/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)
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
movq $0x0, -0x70(%rbp)
cmpq $0x0, 0x8(%rsi)
je 0x575b
leaq -0x10c0(%rbp), %rdi
movl $0x8, %edx
callq 0x35d0
leaq -0x50(%rbp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
leaq -0x10c0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3480
movq -0x60(%rbp), %rsi
leaq 0x2b1c(%rip), %rdi      # 0x81f0
xorl %eax, %eax
callq 0x3050
movq -0x60(%rbp), %r15
callq 0x3040
movq %rax, %r14
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movl $0x0, (%r14)
leaq -0xc0(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x34d0
cmpq %r15, (%r12)
je 0x591c
movq %rax, %rbx
movslq %ebx, %rax
cmpq %rbx, %rax
jne 0x5928
movl (%r14), %eax
cmpl $0x22, %eax
je 0x5928
testl %eax, %eax
jne 0x5739
movl -0x34(%rbp), %eax
movl %eax, (%r14)
movq -0x60(%rbp), %rdi
cmpq %r13, %rdi
je 0x5747
callq 0x3370
leaq -0x10c0(%rbp), %rdi
callq 0x3090
testl %ebx, %ebx
jne 0x58fa
leaq -0xa0(%rbp), %rdi
callq 0x54ac
movq -0xa0(%rbp), %rbx
movq -0x98(%rbp), %r14
cmpq %r14, %rbx
je 0x58d9
leaq -0x10c0(%rbp), %r15
leaq -0xc0(%rbp), %r13
movl (%rbx), %ecx
movl %ecx, -0x2c(%rbp)
movl $0x40, %esi
movq %r15, %rdi
leaq 0x2d3a(%rip), %rdx      # 0x84da
xorl %eax, %eax
callq 0x35c0
movq %r15, %rdi
leaq 0x2a16(%rip), %rsi      # 0x81c7
callq 0x3440
movl $0x0, %r12d
testq %rax, %rax
je 0x57e5
movq %rax, %rdi
leaq 0x2d1d(%rip), %rsi      # 0x84e8
movq %r13, %rdx
leaq -0x60(%rbp), %rcx
leaq -0x2d(%rbp), %r8
leaq -0x64(%rbp), %r9
xorl %eax, %eax
callq 0x3690
movl -0x64(%rbp), %r12d
callq 0x3550
cmpl %eax, %r12d
jne 0x58cc
movl -0x2c(%rbp), %ecx
movl $0x1b, %esi
movq %r13, %rdi
leaq 0x2cef(%rip), %rdx      # 0x84f4
xorl %eax, %eax
callq 0x35c0
movl $0xfff, %edx            # imm = 0xFFF
movq %r13, %rdi
movq %r15, %rsi
callq 0x33f0
testq %rax, %rax
jle 0x5842
leaq -0x50(%rbp), %rcx
movq %rcx, -0x60(%rbp)
leaq (%rax,%rbp), %rdx
addq $-0x10c0, %rdx          # imm = 0xEF40
leaq -0x60(%rbp), %rdi
movq %r15, %rsi
callq 0x6db8
jmp 0x5856
leaq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movb $0x0, -0x50(%rbp)
movq -0x58(%rbp), %rdx
movq -0x88(%rbp), %rax
cmpq 0x8(%rax), %rdx
jne 0x5887
testq %rdx, %rdx
je 0x588c
movq -0x88(%rbp), %rax
movq (%rax), %rsi
movq -0x60(%rbp), %rdi
callq 0x33d0
testl %eax, %eax
sete %r12b
jmp 0x588f
xorl %r12d, %r12d
jmp 0x588f
movb $0x1, %r12b
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x58a1
callq 0x3370
testb %r12b, %r12b
je 0x58cc
movq -0x78(%rbp), %rsi
cmpq -0x70(%rbp), %rsi
je 0x58bf
movl -0x2c(%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x78(%rbp)
jmp 0x58cc
leaq -0x80(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x7172
addq $0x4, %rbx
cmpq %r14, %rbx
jne 0x578c
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x58ea
callq 0x3370
movq -0x80(%rbp), %rax
cmpq -0x78(%rbp), %rax
je 0x58f8
movl (%rax), %ebx
jmp 0x58fa
xorl %ebx, %ebx
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x5908
callq 0x3370
movl %ebx, %eax
addq $0x1098, %rsp           # imm = 0x1098
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2bb2(%rip), %rdi      # 0x84d5
callq 0x31f0
leaq 0x2ba6(%rip), %rdi      # 0x84d5
callq 0x3530
jmp 0x593b
movq %rax, %rbx
jmp 0x594f
movq %rax, %rbx
jmp 0x5981
movq %rax, %rbx
cmpl $0x0, (%r14)
jne 0x594f
movl -0x34(%rbp), %eax
movl %eax, (%r14)
movq -0x60(%rbp), %rdi
cmpq %r13, %rdi
je 0x595d
callq 0x3370
leaq -0x10c0(%rbp), %rdi
callq 0x3090
jmp 0x5981
jmp 0x596d
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x5981
callq 0x3370
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x598f
callq 0x3370
movq %rbx, %rdi
callq 0x3630
nop