#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 /*<<< orphan*/ name;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ PF_UNIX;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
main() {
  int s = socket(PF_UNIX, SOCK_STREAM, 0);
  struct sockaddr_un name;
  name.sun_family = AF_UNIX;
  strcpy(name.sun_path, "socketfile");
  bind(s, (struct sockaddr *)&name, sizeof(name));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%edi
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <socket@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%edi
lea    0xe96(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   1040 <bind@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2ebc(%rip),%rax
mov    (%rax),%edi
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <socket@plt>
mov    %eax,%ebx
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
lea    0xe9c(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   1040 <bind@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@PF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@AF_UNIX = global i32 0
@.str = [11 x i8] c"socketfile\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sockaddr_un
%3 = load i32, i32* @PF_UNIX
%4 = load i32, i32* @SOCK_STREAM
%5 = call i32 @socket(i32 %3, i32 %4, i32 0)
store i32 %5, i32* %1
%6 = load i32, i32* @AF_UNIX
%7 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %2, i32 0, i32 1
store i32 %6, i32* %7
%8 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %2, i32 0, i32 0
%9 = load i32, i32* %8
%10 = call i32 @strcpy(i32 %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = bitcast %struct.sockaddr_un* %2 to %struct.sockaddr*
%13 = call i32 @bind(i32 %11, %struct.sockaddr* %12, i32 8)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@PF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@AF_UNIX = global i32 0
@.str = [11 x i8] c"socketfile\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_un
%2 = load i32, i32* @PF_UNIX
%3 = load i32, i32* @SOCK_STREAM
%4 = tail call i32 @socket(i32 %2, i32 %3, i32 0)
%5 = bitcast %struct.sockaddr_un* %1 to i8*
%6 = load i32, i32* @AF_UNIX
%7 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %1, i64 0, i32 1
store i32 %6, i32* %7
%8 = tail call i32 @strcpy(i32 undef, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%9 = bitcast %struct.sockaddr_un* %1 to %struct.sockaddr*
%10 = call i32 @bind(i32 %4, %struct.sockaddr* %9, i32 8)
ret i32 0
}