// File: /workspace/github_cpp_makefile_star2_O3/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 $0x10a8, %rsp           # imm = 0x10A8
movq %rdi, -0x68(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x90(%rbp)
movq $0x0, -0x80(%rbp)
cmpq $0x0, 0x8(%rsi)
je 0x5759
leaq -0x10d0(%rbp), %rdi
movl $0x8, %edx
callq 0x35d0
leaq -0x50(%rbp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
leaq -0x10d0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3480
movq -0x60(%rbp), %rsi
leaq 0x2b26(%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 -0xd0(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x34d0
cmpq %r15, (%r12)
je 0x5939
movq %rax, %rbx
movslq %ebx, %rax
cmpq %rbx, %rax
jne 0x5945
movl (%r14), %eax
cmpl $0x22, %eax
je 0x5945
testl %eax, %eax
jne 0x572f
movl -0x34(%rbp), %eax
movl %eax, (%r14)
movq -0x60(%rbp), %rdi
cmpq %r13, %rdi
je 0x573d
callq 0x3370
leaq -0x10d0(%rbp), %rdi
callq 0x3090
testl %ebx, %ebx
je 0x5759
movq -0x90(%rbp), %rdi
jmp 0x591b
leaq -0xa8(%rbp), %rdi
callq 0x54ac
movq -0xa8(%rbp), %r14
movq -0xa0(%rbp), %r13
cmpq %r13, %r14
je 0x58f8
leaq 0x2d57(%rip), %r15      # 0x84da
leaq -0x10d0(%rbp), %r12
movl (%r14), %ecx
movl %ecx, -0x2c(%rbp)
movl $0x40, %esi
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x35c0
movq %r12, %rdi
leaq 0x2a1b(%rip), %rsi      # 0x81c7
callq 0x3440
movl $0x0, %ebx
testq %rax, %rax
je 0x57e2
movq %rax, %rdi
leaq 0x2d23(%rip), %rsi      # 0x84e8
leaq -0xd0(%rbp), %rdx
leaq -0x60(%rbp), %rcx
leaq -0x2d(%rbp), %r8
leaq -0x6c(%rbp), %r9
xorl %eax, %eax
callq 0x3690
movl -0x6c(%rbp), %ebx
callq 0x3550
cmpl %eax, %ebx
jne 0x58e4
movl -0x2c(%rbp), %ecx
movl $0x1b, %esi
leaq -0xd0(%rbp), %rbx
movq %rbx, %rdi
leaq 0x2cec(%rip), %rdx      # 0x84f4
xorl %eax, %eax
callq 0x35c0
movl $0xfff, %edx            # imm = 0xFFF
movq %rbx, %rdi
movq %r12, %rsi
callq 0x33f0
leaq -0x50(%rbp), %rcx
movq %rcx, -0x60(%rbp)
testq %rax, %rax
jle 0x5870
leaq (%rax,%rbp), %rdx
addq $-0x10d0, %rdx          # imm = 0xEF30
leaq -0x60(%rbp), %rdi
movq %r12, %rsi
callq 0x6d44
movq -0x58(%rbp), %rdx
movq -0x68(%rbp), %rax
cmpq 0x8(%rax), %rdx
jne 0x5887
movq -0x60(%rbp), %r15
testq %rdx, %rdx
je 0x5897
movq -0x68(%rbp), %rax
movq (%rax), %rsi
movq %r15, %rdi
callq 0x33d0
testl %eax, %eax
sete %bl
jmp 0x5899
movq $0x0, -0x58(%rbp)
movb $0x0, -0x50(%rbp)
movq -0x68(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x588f
movq -0x60(%rbp), %r15
xorl %ebx, %ebx
jmp 0x5899
movb $0x1, %bl
movq -0x60(%rbp), %r15
jmp 0x5899
movb $0x1, %bl
leaq -0x50(%rbp), %rax
cmpq %rax, %r15
je 0x58aa
movq %r15, %rdi
callq 0x3370
testb %bl, %bl
leaq 0x2c27(%rip), %r15      # 0x84da
je 0x58e4
movq -0x88(%rbp), %rsi
cmpq -0x80(%rbp), %rsi
je 0x58d4
movl -0x2c(%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x88(%rbp)
jmp 0x58e4
leaq -0x90(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x7116
addq $0x4, %r14
cmpq %r13, %r14
jne 0x578a
movq -0xa8(%rbp), %r14
testq %r14, %r14
je 0x5905
movq %r14, %rdi
callq 0x3370
movq -0x90(%rbp), %rdi
cmpq -0x88(%rbp), %rdi
je 0x5919
movl (%rdi), %ebx
jmp 0x5920
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x5925
callq 0x3370
movl %ebx, %eax
addq $0x10a8, %rsp           # imm = 0x10A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2b95(%rip), %rdi      # 0x84d5
callq 0x31f0
leaq 0x2b89(%rip), %rdi      # 0x84d5
callq 0x3530
jmp 0x5958
movq %rax, %rbx
jmp 0x596c
movq %rax, %rbx
jmp 0x599e
movq %rax, %rbx
cmpl $0x0, (%r14)
jne 0x596c
movl -0x34(%rbp), %eax
movl %eax, (%r14)
movq -0x60(%rbp), %rdi
cmpq %r13, %rdi
je 0x597a
callq 0x3370
leaq -0x10d0(%rbp), %rdi
callq 0x3090
jmp 0x599e
jmp 0x598a
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x599e
callq 0x3370
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x59af
callq 0x3370
movq %rbx, %rdi
callq 0x3630
nop