#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct sockaddr_un {
  int /*<<< orphan*/ sun_path;
  int /*<<< orphan*/ sun_family;
};
struct sockaddr {
  int dummy;
};
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ PF_UNIX;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ memmove(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ memset(struct sockaddr_un *, int /*<<< orphan*/, int);
int sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int socket_fd = socket(PF_UNIX, SOCK_DGRAM, 0);
  if (socket_fd == -1)
    err(1, "Creating socket");
  struct sockaddr_un addr;
  memset(&addr, 0, sizeof addr);
  addr.sun_family = AF_UNIX;
  memmove(addr.sun_path, "notify.sock", sizeof "notify.sock");
  char c = '\0';
  ssize_t res =
      sendto(socket_fd, &c, sizeof c, 0, (struct sockaddr *)&addr, sizeof addr);
  if (res == -1)
    err(1, "Sending to notify.sock");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    119d <main+0x4d>
mov    $0x1,%edi
lea    0xe68(%rip),%rsi
call   1050 <err@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
lea    0xe58(%rip),%rsi
mov    $0xc,%edx
call   1060 <memmove@plt>
movb   $0x0,-0x21(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%r8
lea    -0x21(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    $0x8,%r9d
call   1040 <sendto@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    120c <main+0xbc>
mov    $0x1,%edi
lea    0xe09(%rip),%rsi
call   1050 <err@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1188 <main+0x38>
lea    0xe82(%rip),%rsi
mov    $0x1,%edi
call   1050 <err@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    0x10(%rsp),%edi
lea    0xe67(%rip),%rsi
mov    $0xc,%edx
call   1060 <memmove@plt>
movb   $0x0,0xf(%rsp)
lea    0xf(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    $0x8,%r9d
call   1040 <sendto@plt>
cmp    $0xffffffff,%eax
jne    11f5 <main+0xa5>
lea    0xe25(%rip),%rsi
mov    $0x1,%edi
call   1050 <err@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@PF_UNIX = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [16 x i8] c"Creating socket\00"
@AF_UNIX = global i32 0
@.str.1 = [12 x i8] c"notify.sock\00"
@.str.2 = [23 x i8] c"Sending to notify.sock\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_un
%8 = alloca i8
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @PF_UNIX
%11 = load i32, i32* @SOCK_DGRAM
%12 = call i32 @socket(i32 %10, i32 %11, i32 0)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @err(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %2
%18 = call i32 @memset(%struct.sockaddr_un* %7, i32 0, i32 8)
%19 = load i32, i32* @AF_UNIX
%20 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 1
store i32 %19, i32* %20
%21 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 0
%22 = load i32, i32* %21
%23 = call i32 @memmove(i32 %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 12)
store i8 0, i8* %8
%24 = load i32, i32* %6
%25 = bitcast %struct.sockaddr_un* %7 to %struct.sockaddr*
%26 = call i32 @sendto(i32 %24, i8* %8, i32 1, i32 0, %struct.sockaddr* %25, i32 8)
store i32 %26, i32* %9
%27 = load i32, i32* %9
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %17
%30 = call i32 @err(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %17
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@PF_UNIX = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [16 x i8] c"Creating socket\00"
@AF_UNIX = global i32 0
@.str.1 = [12 x i8] c"notify.sock\00"
@.str.2 = [23 x i8] c"Sending to notify.sock\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_un
%4 = alloca i8
%5 = load i32, i32* @PF_UNIX
%6 = load i32, i32* @SOCK_DGRAM
%7 = tail call i32 @socket(i32 %5, i32 %6, i32 0)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = bitcast %struct.sockaddr_un* %3 to i8*
%13 = call i32 @memset(%struct.sockaddr_un* %3, i32 0, i32 8)
%14 = load i32, i32* @AF_UNIX
%15 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i64 0, i32 1
store i32 %14, i32* %15
%16 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i64 0, i32 0
%17 = load i32, i32* %16
%18 = call i32 @memmove(i32 %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 12)
store i8 0, i8* %4
%19 = bitcast %struct.sockaddr_un* %3 to %struct.sockaddr*
%20 = call i32 @sendto(i32 %7, i8* %4, i32 1, i32 0, %struct.sockaddr* %19, i32 8)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %24
22: ; preds = %11
%23 = call i32 @err(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %11
ret i32 0
}