// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %rsp
leaq 0x102685(%rip), %rdi    # 0x139ff7
callq 0x26850
movq %rax, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
movl $0x0, -0xd4(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x379b2
movl $0x3, %edi
leaq 0x102666(%rip), %rsi    # 0x13a005
movb $0x0, %al
callq 0x2fc60
movl $0x0, -0x4(%rbp)
jmp 0x37b62
movq -0x10(%rbp), %rax
movsbl (%rax), %esi
leaq 0x102680(%rip), %rdi    # 0x13a040
callq 0x267f0
cmpq $0x0, %rax
je 0x379da
movq -0x10(%rbp), %rdi
callq 0x264f0
cmpq $0x2, %rax
jae 0x379e6
movl $0x0, -0x4(%rbp)
jmp 0x37b62
movl $0x2, %edi
leaq 0x102651(%rip), %rsi    # 0x13a043
movb $0x0, %al
callq 0x2fc60
movl $0x1, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x26800
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
jne 0x37a35
movq -0x10(%rbp), %rdx
movl $0x3, %edi
leaq 0x10264e(%rip), %rsi    # 0x13a070
movb $0x0, %al
callq 0x2fc60
movl $0x0, -0x4(%rbp)
jmp 0x37b62
leaq -0x82(%rbp), %rdi
xorl %esi, %esi
movl $0x6e, %edx
callq 0x26110
movw $0x1, -0x82(%rbp)
leaq -0x82(%rbp), %rdi
addq $0x2, %rdi
movq -0x10(%rbp), %rsi
movl $0x6b, %edx
callq 0x26a40
movb $0x0, -0x15(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x40, %eax
jne 0x37a7e
movb $0x0, -0x80(%rbp)
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x26110
leaq 0x1025fb(%rip), %rax    # 0x13a093
movq %rax, -0x98(%rbp)
movq $0x7, -0x90(%rbp)
leaq -0xd0(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x26110
leaq -0x82(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x264f0
addq $0x2, %rax
movl %eax, -0xc8(%rbp)
leaq -0x98(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq $0x1, -0xb8(%rbp)
leaq 0x1024f9(%rip), %rdi    # 0x139ff7
callq 0x26a80
movl -0xd4(%rbp), %eax
orl $0x4000, %eax           # imm = 0x4000
movl %eax, -0xd4(%rbp)
movl -0x14(%rbp), %edi
movl -0xd4(%rbp), %edx
leaq -0xd0(%rbp), %rsi
callq 0x26640
cmpq $0x0, %rax
jge 0x37b53
movl $0x3, %edi
leaq 0x102560(%rip), %rsi    # 0x13a09b
movb $0x0, %al
callq 0x2fc60
movl -0x14(%rbp), %edi
callq 0x26180
movl $0x0, -0x4(%rbp)
jmp 0x37b62
movl -0x14(%rbp), %edi
callq 0x26180
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nop