#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;
};

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int sendto(int, unsigned char *, int, int /*<<< orphan*/, struct sockaddr *,
           int);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int ux_sendto(int sock, char *topath, unsigned char *data, int len) {
  struct sockaddr_un name;
  name.sun_family = AF_UNIX;
  strcpy(name.sun_path, topath);
  return sendto(sock, data, len, 0, (struct sockaddr *)&name,
                sizeof(struct sockaddr_un));
}


x86 assembly (clang, -O0):
<ux_sendto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    -0x28(%rbp),%r8
xor    %ecx,%ecx
mov    $0x8,%r9d
call   1040 <sendto@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ux_sendto>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %edi,%ebp
mov    0x2eb1(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
call   1030 <strcpy@plt>
lea    0x8(%rsp),%r8
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
xor    %ecx,%ecx
mov    $0x8,%r9d
call   1040 <sendto@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
define i32 @ux_sendto(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca %struct.sockaddr_un
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = load i32, i32* @AF_UNIX
%11 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %9, i32 0, i32 1
store i32 %10, i32* %11
%12 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %9, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load i8*, i8** %6
%15 = call i32 @strcpy(i32 %13, i8* %14)
%16 = load i32, i32* %5
%17 = load i8*, i8** %7
%18 = load i32, i32* %8
%19 = bitcast %struct.sockaddr_un* %9 to %struct.sockaddr*
%20 = call i32 @sendto(i32 %16, i8* %17, i32 %18, i32 0, %struct.sockaddr* %19, i32 8)
ret i32 %20
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
define i32 @ux_sendto(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca %struct.sockaddr_un
%6 = bitcast %struct.sockaddr_un* %5 to i8*
%7 = load i32, i32* @AF_UNIX
%8 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %5, i64 0, i32 1
store i32 %7, i32* %8
%9 = tail call i32 @strcpy(i32 undef, i8* %1)
%10 = bitcast %struct.sockaddr_un* %5 to %struct.sockaddr*
%11 = call i32 @sendto(i32 %0, i8* %2, i32 %3, i32 0, %struct.sockaddr* %10, i32 8)
ret i32 %11
}