// File: /workspace/github_c_makefile_star2_O2/jech[P]shncpd/local.c
// Function: run_local_script
int
run_local_script(int up)
{
    pid_t pid;
    if(local_script == NULL || local_script[0] == '\0')
        return 0;

    debugf("Calling local configuration script (%d).\n", up);

    pid = fork();
    if(pid < 0)
        return pid;

    if(pid == 0) {
        char buf[20];
        snprintf(buf, 20, "%d", debug_level);
        setenv("HNCP_DEBUG_LEVEL", buf, 1);
        if(up) {
            struct prefix_list *pl;
            pl = all_dhcp_data(0, 1, 0);
            set_config_var("HNCP_IPv4_NAMESERVERS", pl, 1);
            destroy_prefix_list(pl);
            pl = all_dhcp_data(0, 0, 1);
            set_config_var("HNCP_IPv6_NAMESERVERS", pl, 0);
            destroy_prefix_list(pl);
            pl = all_dhcp_data(1, 1, 0);
            set_config_var("HNCP_IPv4_NTP_SERVERS", pl, 1);
            destroy_prefix_list(pl);
            pl = all_dhcp_data(1, 0, 1);
            set_config_var("HNCP_IPv6_NTP_SERVERS", pl, 0);
            destroy_prefix_list(pl);
        }
        execl(local_script, local_script, up ? "up" : "down" , NULL);
        perror("exec(local_script)");
        exit(42);
    } else {
        int status;
    again:
        pid = waitpid(pid, &status, 0);
        if(pid < 0) {
            if(errno == EINTR)
                goto again;
            perror("wait");
            return -1;
        } else if(!WIFEXITED(status)) {
            fprintf(stderr, "Configuration script died violently (%d)\n",
                    status);
            return 0;
        } else if(WEXITSTATUS(status) != 0) {
            fprintf(stderr, "Configuration script erred out %d\n",
                    WEXITSTATUS(status));
            return 0;
        }
        return 1;
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq 0xb4e1(%rip), %rax      # 0x15498
xorl %ebx, %ebx
testq %rax, %rax
je 0xa028
cmpb $0x0, (%rax)
je 0xa028
movl %edi, %ebp
leaq 0x728c(%rip), %r14      # 0x11258
cmpl $0x2, (%r14)
jge 0xa033
callq 0x2390
movl %eax, %ebx
testl %eax, %eax
js 0xa028
je 0xa077
movq %rsp, %r14
movl %ebx, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x22d0
testl %eax, %eax
jns 0xa012
movl %eax, %ebx
callq 0x2060
cmpl $0x4, (%rax)
je 0x9fe6
leaq 0x321e(%rip), %rdi      # 0xd227
callq 0x22f0
pushq $-0x1
jmp 0xa027
movl (%rsp), %edx
testb $0x7f, %dl
jne 0xa048
shrl $0x8, %edx
andl $0xff, %edx
jne 0xa05b
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x313f(%rip), %rsi      # 0xd179
pushq $0x2
popq %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x23c0
jmp 0x9fd2
movq 0x6fa9(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x31d3(%rip), %rsi      # 0xd22c
jmp 0xa06c
movq 0x6f96(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x31ea(%rip), %rsi      # 0xd256
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x21e0
jmp 0xa028
movl (%r14), %ecx
leaq 0x2918(%rip), %rdx      # 0xc999
movq %rsp, %rbx
pushq $0x14
popq %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x310b(%rip), %rdi      # 0xd1a3
pushq $0x1
popq %rdx
movq %rbx, %rsi
callq 0x20d0
testl %ebp, %ebp
jne 0xa0b3
leaq 0x3161(%rip), %rdx      # 0xd20f
jmp 0xa159
pushq $0x1
popq %rbx
xorl %edi, %edi
movl %ebx, %esi
xorl %edx, %edx
callq 0x42f7
movq %rax, %r14
leaq 0x30e9(%rip), %rdi      # 0xd1b4
movq %rax, %rsi
movl %ebx, %edx
callq 0xa180
movq %r14, %rdi
callq 0x8624
xorl %edi, %edi
xorl %esi, %esi
movl %ebx, %edx
callq 0x42f7
movq %rax, %r14
leaq 0x30d8(%rip), %rdi      # 0xd1ca
movq %rax, %rsi
xorl %edx, %edx
callq 0xa180
movq %r14, %rdi
callq 0x8624
movl %ebx, %edi
movl %ebx, %esi
xorl %edx, %edx
callq 0x42f7
movq %rax, %r14
leaq 0x30c7(%rip), %rdi      # 0xd1e0
movq %rax, %rsi
movl %ebx, %edx
callq 0xa180
movq %r14, %rdi
callq 0x8624
movl %ebx, %edi
xorl %esi, %esi
movl %ebx, %edx
callq 0x42f7
movq %rax, %rbx
leaq 0x30b6(%rip), %rdi      # 0xd1f6
movq %rax, %rsi
xorl %edx, %edx
callq 0xa180
movq %rbx, %rdi
callq 0x8624
leaq 0x30b3(%rip), %rdx      # 0xd20c
movq 0xb338(%rip), %rdi      # 0x15498
movq %rdi, %rsi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x2370
leaq 0x30a1(%rip), %rdi      # 0xd214
callq 0x22f0
pushq $0x2a
popq %rdi
callq 0x2330