// File: /workspace/github_cpp_makefile_star2_O3/davmac314[P]dinit/src/dinitctl.cc
// Function: find_service_desc(char const*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
static std::pair<int,int> find_service_desc(const char *svc_name, const std::vector<std::string> &paths,
        std::string &service_file_path)
{
    using std::cout;
    using std::cerr;

    // We use this to store a copy of the service name without argument, if needed
    std::string svc_name_store;

    // Check for service argument which must be stripped
    auto at_ptr = svc_name;
    while (*at_ptr != '\0' && *at_ptr != '@') ++at_ptr;
    if (*at_ptr == '@') {
        svc_name_store = std::string(svc_name, at_ptr - svc_name);
        svc_name = svc_name_store.c_str();
    }

    for (std::string path : paths) {
        std::string test_path = combine_paths(path, ::string_view(svc_name, at_ptr - svc_name));

        auto sdf_fds = open_with_dir(path.c_str(), svc_name);
        if (sdf_fds.first != -1 || sdf_fds.second != ENOENT) {
            service_file_path = test_path;
            return sdf_fds;
        }
    }

    return {-1, ENOENT};
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, %r15
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rdi, %r14
movq %rdi, %rdx
movq %rbp, 0x60(%rsp)
movzbl (%rdx), %eax
testl %eax, %eax
je 0xe31a
cmpl $0x40, %eax
je 0xe2dc
incq %rdx
incq %r14
jmp 0xe2c8
leaq 0x10(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rsp, %rdi
movq %r15, %rsi
callq 0xec34
leaq 0x40(%rsp), %rdi
movq %rsp, %rbx
movq %rbx, %rsi
callq 0x4390
movq (%rbx), %rdi
cmpq %r13, %rdi
je 0xe315
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42f0
movq 0x40(%rsp), %r15
movabsq $0x200000000, %rbx      # imm = 0x200000000
movq (%r12), %r13
movq 0x8(%r12), %rbp
cmpq %rbp, %r13
je 0xe3e1
leaq 0x10(%rsp), %rbx
subq %r15, %r14
movq %rbx, (%rsp)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x11358
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x20(%rsp), %rdi
movq %r15, %rcx
movq %r14, %r8
callq 0x10c49
movq (%rsp), %rdi
movq %r15, %rsi
movl $0xffffff9c, %edx       # imm = 0xFFFFFF9C
callq 0xfc7c
movq %rax, %r12
movabsq $0x2ffffffff, %rax      # imm = 0x2FFFFFFFF
cmpq %rax, %r12
jne 0xe3ee
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xe3ad
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42f0
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0xe3c3
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42f0
addq $0x20, %r13
cmpq %rbp, %r13
jne 0xe33e
leaq 0x50(%rsp), %r14
movabsq $0x200000000, %rbx      # imm = 0x200000000
jmp 0xe3e6
leaq 0x50(%rsp), %r14
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0xe447
leaq 0x20(%rsp), %rsi
movq 0x60(%rsp), %rdi
callq 0x41d0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
leaq 0x50(%rsp), %r14
je 0xe41e
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42f0
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0xe434
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42f0
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %r12, %rbx
andq %rax, %rbx
movl %r12d, %r15d
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0xe45e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x42f0
orq %r15, %rbx
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xe49e
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42f0
jmp 0xe49e
jmp 0xe496
movq %rax, %r14
jmp 0xe4b4
movq %rax, %r14
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0xe4b4
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42f0
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0xe4d0
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x42f0
movq %r14, %rdi
callq 0x44f0