// File: davmac314[P]dinit/src/load-service.cc
// Function: check_settings_for_reload(service_record*, dinit_load::service_settings_wrapper<prelim_dep>&)
static bool check_settings_for_reload(service_record *service,
        dinit_load::service_settings_wrapper<prelim_dep> &settings)
{
    using namespace dinit_load;

    const std::string &name = service->get_name();

    // To begin, assume a new record is needed
    bool create_new_record = true;

    if (service->get_state() != service_state_t::STOPPED) {
        // Can not change type of a running service.
        if (settings.service_type != service->get_type()) {
            throw service_load_exc(name, "cannot change type of non-stopped service.");
        }
        // Can not alter a starting/stopping service, at least for now.
        if (service->get_state() != service_state_t::STARTED) {
            throw service_load_exc(name,
                    "cannot alter settings for service which is currently starting/stopping.");
        }

        // Check validity of dependencies (if started, regular deps must be started)
        for (auto &new_dep : settings.depends) {
            if (new_dep.dep_type == dependency_type::REGULAR) {
                if (new_dep.to->get_state() != service_state_t::STARTED) {
                    throw service_load_exc(name,
                            std::string("cannot add non-started dependency '")
                                + new_dep.to->get_name() + "'.");
                }
            }
        }

        // Cannot change certain flags
        auto current_flags = service->get_flags();
        if (current_flags.starts_on_console != settings.onstart_flags.starts_on_console
                || current_flags.shares_console != settings.onstart_flags.shares_console) {
            throw service_load_exc(name, "cannot change starts_on_console/"
                    "shares_console flags for a running service.");
        }

        // Cannot change pid file
        if (service->get_type() == service_type_t::BGPROCESS) {
            auto *bgp_service = static_cast<bgproc_service *>(service);
            if (bgp_service->get_pid_file() != settings.pid_file) {
                throw service_load_exc(name, "cannot change pid_file for running service.");
            }
        }

        // Cannot change inittab_id/inittab_line
        #if USE_UTMPX
            if (service->get_type() == service_type_t::PROCESS) {
                auto *proc_service = static_cast<process_service *>(service);
                auto *svc_utmp_id = proc_service->get_utmp_id();
                auto *svc_utmp_ln = proc_service->get_utmp_line();
                if (strncmp(svc_utmp_id, settings.inittab_id, proc_service->get_utmp_id_size()) != 0
                        || strncmp(svc_utmp_ln, settings.inittab_line,
                                proc_service->get_utmp_line_size()) != 0) {
                    throw service_load_exc(name, "cannot change inittab-id or inittab-line "
                            "settings for running service.");
                }
            }
        #endif

        // Cannot change log type
        if (value(service->get_type()).is_in(service_type_t::PROCESS, service_type_t::BGPROCESS,
                service_type_t::SCRIPTED)) {
            base_process_service *bps = static_cast<base_process_service *>(service);
            if (bps->get_log_mode() != settings.log_type) {
                throw service_load_exc(name, "cannot change log-type for running service.");
            }
        }

        // Already started; we must replace settings on existing service record
        create_new_record = false;
    }
    else if (settings.service_type == service->get_type()) {
        // No need to create a new record if the type hasn't changed
        create_new_record = false;
    }

    return create_new_record;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2d420
movq %rax, -0x18(%rbp)
movb $0x1, -0x19(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2f0d0
cmpb $0x0, %al
je 0x234dc
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %eax
movl %eax, -0x1e8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2d5a0
movl %eax, %ecx
movl -0x1e8(%rbp), %eax
cmpl %ecx, %eax
je 0x22c58
movb $0x1, -0x55(%rbp)
movl $0x40, %edi
callq 0xa320
movq %rax, -0x200(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x1f8(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0xace0
movq -0x1f0(%rbp), %rdx
leaq 0x54e46(%rip), %rsi     # 0x77a12
leaq -0x40(%rbp), %rdi
callq 0x16e00
jmp 0x22bd7
movq -0x1f8(%rbp), %rsi
movq -0x200(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0x17210
jmp 0x22bf0
movq -0x200(%rbp), %rdi
movb $0x0, -0x55(%rbp)
leaq 0x83d1e(%rip), %rsi     # 0xa6920
leaq -0xb9b9(%rip), %rdx     # 0x17250
callq 0xac90
jmp 0x2351e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x22c36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xade8
leaq -0x41(%rbp), %rdi
callq 0xa790
testb $0x1, -0x55(%rbp)
jne 0x22c47
jmp 0x22c53
movq -0x200(%rbp), %rdi
callq 0xa510
jmp 0x23515
movq -0x8(%rbp), %rdi
callq 0x2f0d0
cmpb $0x2, %al
je 0x22d33
movb $0x1, -0x7a(%rbp)
movl $0x40, %edi
callq 0xa320
movq %rax, -0x218(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0xace0
movq -0x208(%rbp), %rdx
leaq 0x54d96(%rip), %rsi     # 0x77a3d
leaq -0x78(%rbp), %rdi
callq 0x16e00
jmp 0x22cb2
movq -0x210(%rbp), %rsi
movq -0x218(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x17210
jmp 0x22ccb
movq -0x218(%rbp), %rdi
movb $0x0, -0x7a(%rbp)
leaq 0x83c43(%rip), %rsi     # 0xa6920
leaq -0xba94(%rip), %rdx     # 0x17250
callq 0xac90
jmp 0x2351e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x22d11
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xade8
leaq -0x79(%rbp), %rdi
callq 0xa790
testb $0x1, -0x7a(%rbp)
jne 0x22d22
jmp 0x22d2e
movq -0x218(%rbp), %rdi
callq 0xa510
jmp 0x23515
movq -0x10(%rbp), %rax
addq $0xb8, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x3c750
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rdi
callq 0x3c780
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x3c7b0
testb $0x1, %al
jne 0x22d86
jmp 0x22f2f
leaq -0x90(%rbp), %rdi
callq 0x3c7e0
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x22f1c
movq -0xa0(%rbp), %rax
movq (%rax), %rdi
callq 0x2f0d0
cmpb $0x2, %al
je 0x22f1a
movb $0x1, -0x102(%rbp)
movl $0x40, %edi
callq 0xa320
movq %rax, -0x230(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x228(%rbp)
leaq -0x101(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0xace0
movq -0x220(%rbp), %rdx
leaq 0x54c80(%rip), %rsi     # 0x77a85
leaq -0x100(%rbp), %rdi
callq 0x16e00
jmp 0x22e13
movq -0xa0(%rbp), %rax
movq (%rax), %rdi
callq 0x2d420
movq %rax, %rdx
leaq -0xe0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x3c810
jmp 0x22e3a
leaq 0x54c68(%rip), %rdx     # 0x77aa9
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x2eaa0
jmp 0x22e56
movq -0x228(%rbp), %rsi
movq -0x230(%rbp), %rdi
leaq -0xc0(%rbp), %rdx
callq 0x17210
jmp 0x22e72
movq -0x230(%rbp), %rdi
movb $0x0, -0x102(%rbp)
leaq 0x83a99(%rip), %rsi     # 0xa6920
leaq -0xbc3e(%rip), %rdx     # 0x17250
callq 0xac90
jmp 0x2351e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x22ef2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x22ee6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x22eda
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xade8
leaq -0xe0(%rbp), %rdi
callq 0xade8
leaq -0x100(%rbp), %rdi
callq 0xade8
leaq -0x101(%rbp), %rdi
callq 0xa790
testb $0x1, -0x102(%rbp)
jne 0x22f09
jmp 0x22f15
movq -0x230(%rbp), %rdi
callq 0xa510
jmp 0x23515
jmp 0x22f1c
jmp 0x22f1e
leaq -0x90(%rbp), %rdi
callq 0x3c860
jmp 0x22d6a
movq -0x8(%rbp), %rdi
callq 0x3c880
movw %ax, -0x104(%rbp)
movw -0x104(%rbp), %ax
shrw $0x3, %ax
andw $0x1, %ax
andb $0x1, %al
movzbl %al, %eax
movq -0x10(%rbp), %rcx
movw 0x13c(%rcx), %cx
shrw $0x3, %cx
andw $0x1, %cx
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x22fa5
movw -0x104(%rbp), %ax
shrw $0x4, %ax
andw $0x1, %ax
andb $0x1, %al
movzbl %al, %eax
movq -0x10(%rbp), %rcx
movw 0x13c(%rcx), %cx
shrw $0x4, %cx
andw $0x1, %cx
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x23087
movb $0x1, -0x12a(%rbp)
movl $0x40, %edi
callq 0xa320
movq %rax, -0x248(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x240(%rbp)
leaq -0x129(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0xace0
movq -0x238(%rbp), %rdx
leaq 0x54ac3(%rip), %rsi     # 0x77aac
leaq -0x128(%rbp), %rdi
callq 0x16e00
jmp 0x22ff7
movq -0x240(%rbp), %rsi
movq -0x248(%rbp), %rdi
leaq -0x128(%rbp), %rdx
callq 0x17210
jmp 0x23013
movq -0x248(%rbp), %rdi
movb $0x0, -0x12a(%rbp)
leaq 0x838f8(%rip), %rsi     # 0xa6920
leaq -0xbddf(%rip), %rdx     # 0x17250
callq 0xac90
jmp 0x2351e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2305f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x128(%rbp), %rdi
callq 0xade8
leaq -0x129(%rbp), %rdi
callq 0xa790
testb $0x1, -0x12a(%rbp)
jne 0x23076
jmp 0x23082
movq -0x248(%rbp), %rdi
callq 0xa510
jmp 0x23515
movq -0x8(%rbp), %rdi
callq 0x2d5a0
cmpl $0x2, %eax
jne 0x231ad
movq -0x8(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rdi
callq 0x3c8d0
movq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x70, %rsi
callq 0x3c8a0
testb $0x1, %al
jne 0x230c9
jmp 0x231ab
movb $0x1, -0x15a(%rbp)
movl $0x40, %edi
callq 0xa320
movq %rax, -0x260(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x258(%rbp)
leaq -0x159(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0xace0
movq -0x250(%rbp), %rdx
leaq 0x549eb(%rip), %rsi     # 0x77af8
leaq -0x158(%rbp), %rdi
callq 0x16e00
jmp 0x2311b
movq -0x258(%rbp), %rsi
movq -0x260(%rbp), %rdi
leaq -0x158(%rbp), %rdx
callq 0x17210
jmp 0x23137
movq -0x260(%rbp), %rdi
movb $0x0, -0x15a(%rbp)
leaq 0x837d4(%rip), %rsi     # 0xa6920
leaq -0xbf03(%rip), %rdx     # 0x17250
callq 0xac90
jmp 0x2351e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x23183
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x158(%rbp), %rdi
callq 0xade8
leaq -0x159(%rbp), %rdi
callq 0xa790
testb $0x1, -0x15a(%rbp)
jne 0x2319a
jmp 0x231a6
movq -0x260(%rbp), %rdi
callq 0xa510
jmp 0x23515
jmp 0x231ad
movq -0x8(%rbp), %rdi
callq 0x2d5a0
cmpl $0x1, %eax
jne 0x23364
movq -0x8(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rdi
callq 0x3c8f0
movq %rax, -0x170(%rbp)
movq -0x168(%rbp), %rdi
callq 0x3c910
movq %rax, -0x178(%rbp)
movq -0x170(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x10(%rbp), %rax
addq $0x284, %rax            # imm = 0x284
movq %rax, -0x268(%rbp)
movq -0x168(%rbp), %rdi
callq 0x3c930
movq -0x270(%rbp), %rdi
movq -0x268(%rbp), %rsi
movq %rax, %rdx
callq 0xa2d0
cmpl $0x0, %eax
jne 0x23280
movq -0x178(%rbp), %rax
movq %rax, -0x280(%rbp)
movq -0x10(%rbp), %rax
addq $0x288, %rax            # imm = 0x288
movq %rax, -0x278(%rbp)
movq -0x168(%rbp), %rdi
callq 0x3c940
movq -0x280(%rbp), %rdi
movq -0x278(%rbp), %rsi
movq %rax, %rdx
callq 0xa2d0
cmpl $0x0, %eax
je 0x23362
movb $0x1, -0x19a(%rbp)
movl $0x40, %edi
callq 0xa320
movq %rax, -0x298(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x290(%rbp)
leaq -0x199(%rbp), %rdi
movq %rdi, -0x288(%rbp)
callq 0xace0
movq -0x288(%rbp), %rdx
leaq 0x54860(%rip), %rsi     # 0x77b24
leaq -0x198(%rbp), %rdi
callq 0x16e00
jmp 0x232d2
movq -0x290(%rbp), %rsi
movq -0x298(%rbp), %rdi
leaq -0x198(%rbp), %rdx
callq 0x17210
jmp 0x232ee
movq -0x298(%rbp), %rdi
movb $0x0, -0x19a(%rbp)
leaq 0x8361d(%rip), %rsi     # 0xa6920
leaq -0xc0ba(%rip), %rdx     # 0x17250
callq 0xac90
jmp 0x2351e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2333a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x198(%rbp), %rdi
callq 0xade8
leaq -0x199(%rbp), %rdi
callq 0xa790
testb $0x1, -0x19a(%rbp)
jne 0x23351
jmp 0x2335d
movq -0x298(%rbp), %rdi
callq 0xa510
jmp 0x23515
jmp 0x23364
movq -0x8(%rbp), %rdi
callq 0x2d5a0
movl %eax, -0x1ac(%rbp)
leaq -0x1ac(%rbp), %rdi
callq 0x2f040
movq %rax, -0x1a8(%rbp)
movl $0x1, -0x1b0(%rbp)
movl $0x2, -0x1b4(%rbp)
movl $0x3, -0x1b8(%rbp)
leaq -0x1a8(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
leaq -0x1b4(%rbp), %rdx
leaq -0x1b8(%rbp), %rcx
callq 0x2f070
testb $0x1, %al
jne 0x233ce
jmp 0x234d6
movq -0x8(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rdi
callq 0x2f280
movq -0x10(%rbp), %rcx
cmpl 0x100(%rcx), %eax
je 0x234d4
movb $0x1, -0x1e2(%rbp)
movl $0x40, %edi
callq 0xa320
movq %rax, -0x2b0(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x2a8(%rbp)
leaq -0x1e1(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0xace0
movq -0x2a0(%rbp), %rdx
leaq 0x54732(%rip), %rsi     # 0x77b6b
leaq -0x1e0(%rbp), %rdi
callq 0x16e00
jmp 0x23447
movq -0x2a8(%rbp), %rsi
movq -0x2b0(%rbp), %rdi
leaq -0x1e0(%rbp), %rdx
callq 0x17210
jmp 0x23463
movq -0x2b0(%rbp), %rdi
movb $0x0, -0x1e2(%rbp)
leaq 0x834a8(%rip), %rsi     # 0xa6920
leaq -0xc22f(%rip), %rdx     # 0x17250
callq 0xac90
jmp 0x2351e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x234af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0xade8
leaq -0x1e1(%rbp), %rdi
callq 0xa790
testb $0x1, -0x1e2(%rbp)
jne 0x234c6
jmp 0x234d2
movq -0x2b0(%rbp), %rdi
callq 0xa510
jmp 0x23515
jmp 0x234d6
movb $0x0, -0x19(%rbp)
jmp 0x23507
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %eax
movl %eax, -0x2b4(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2d5a0
movl %eax, %ecx
movl -0x2b4(%rbp), %eax
cmpl %ecx, %eax
jne 0x23505
movb $0x0, -0x19(%rbp)
jmp 0x23507
movb -0x19(%rbp), %al
andb $0x1, %al
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0xacc0
nop