// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/src/server.c
// Function: redisSupervisedSystemd
int redisSupervisedSystemd(void) {
    const char *notify_socket = getenv("NOTIFY_SOCKET");
    int fd = 1;
    struct sockaddr_un su;
    struct iovec iov;
    struct msghdr hdr;
    int sendto_flags = 0;

    if (!notify_socket) {
        serverLog(LL_WARNING,
                "systemd supervision requested, but NOTIFY_SOCKET not found");
        return 0;
    }

    if ((strchr("@/", notify_socket[0])) == NULL || strlen(notify_socket) < 2) {
        return 0;
    }

    serverLog(LL_NOTICE, "supervised by systemd, will signal readiness");
    if ((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) {
        serverLog(LL_WARNING,
                "Can't connect to systemd socket %s", notify_socket);
        return 0;
    }

    memset(&su, 0, sizeof(su));
    su.sun_family = AF_UNIX;
    strncpy (su.sun_path, notify_socket, sizeof(su.sun_path) -1);
    su.sun_path[sizeof(su.sun_path) - 1] = '\0';

    if (notify_socket[0] == '@')
        su.sun_path[0] = '\0';

    memset(&iov, 0, sizeof(iov));
    iov.iov_base = "READY=1";
    iov.iov_len = strlen("READY=1");

    memset(&hdr, 0, sizeof(hdr));
    hdr.msg_name = &su;
    hdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) +
        strlen(notify_socket);
    hdr.msg_iov = &iov;
    hdr.msg_iovlen = 1;

    unsetenv("NOTIFY_SOCKET");
#ifdef HAVE_MSG_NOSIGNAL
    sendto_flags |= MSG_NOSIGNAL;
#endif
    if (sendmsg(fd, &hdr, sendto_flags) < 0) {
        serverLog(LL_WARNING, "Can't send notification to systemd");
        close(fd);
        return 0;
    }
    close(fd);
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xc0, %rsp
leaq 0x8962f(%rip), %rdi     # 0xbf087
callq 0x26850
testq %rax, %rax
je 0x35b75
movq %rax, %rbx
movzbl (%rax), %eax
xorl %ebp, %ebp
testl %eax, %eax
je 0x35a80
cmpl $0x40, %eax
je 0x35a80
cmpl $0x2f, %eax
jne 0x35b8a
movq %rbx, %rdi
callq 0x26500
cmpq $0x2, %rax
jb 0x35b8a
leaq 0x89637(%rip), %rsi     # 0xbf0d0
xorl %ebp, %ebp
movl $0x2, %edi
xorl %eax, %eax
callq 0x2fdad
movl $0x1, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x26800
cmpl $-0x1, %eax
je 0x35b9c
movl %eax, %r14d
leaq 0x1c(%rsp), %r15
movw $0x1, -0x2(%r15)
movl $0x6b, %edx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x26a40
movb $0x0, 0x6b(%r15)
cmpb $0x40, (%rbx)
jne 0x35aef
movb $0x0, 0x1c(%rsp)
leaq 0x8962a(%rip), %rax     # 0xbf120
leaq 0x8(%rsp), %r12
movq %rax, (%r12)
movq $0x7, 0x8(%r12)
xorps %xmm0, %xmm0
leaq 0x88(%rsp), %r15
movups %xmm0, 0x8(%r15)
movups %xmm0, 0x18(%r15)
movups %xmm0, 0x28(%r15)
leaq 0x1a(%rsp), %rax
movq %rax, (%r15)
movq %rbx, %rdi
callq 0x26500
addl $0x2, %eax
movl %eax, 0x8(%r15)
movq %r12, 0x10(%r15)
movq $0x1, 0x18(%r15)
leaq 0x8953b(%rip), %rdi     # 0xbf087
callq 0x26a80
movl %r14d, %edi
movq %r15, %rsi
movl $0x4000, %edx           # imm = 0x4000
callq 0x26630
testq %rax, %rax
js 0x35bb4
movl %r14d, %edi
callq 0x26180
movl $0x1, %ebp
jmp 0x35b8a
leaq 0x89519(%rip), %rsi     # 0xbf095
xorl %ebp, %ebp
movl $0x3, %edi
xorl %eax, %eax
callq 0x2fdad
movl %ebp, %eax
addq $0xc0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8955a(%rip), %rsi     # 0xbf0fd
movl $0x3, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2fdad
jmp 0x35b8a
leaq 0x8956d(%rip), %rsi     # 0xbf128
xorl %ebp, %ebp
movl $0x3, %edi
xorl %eax, %eax
callq 0x2fdad
movl %r14d, %edi
callq 0x26180
jmp 0x35b8a