#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 {
  char *sun_path;
  int /*<<< orphan*/ sun_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ PF_UNIX;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SUN_LEN(struct sockaddr_un *);
scalar_t__ bind(int, struct sockaddr *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ memset(struct sockaddr_un *, char, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
char *strerror(int /*<<< orphan*/);
int main() {
  int listen_fd;
  struct sockaddr_un addr;
  listen_fd = socket(PF_UNIX, SOCK_STREAM, 0);
  if (listen_fd < 0) {
    fprintf(stderr, "socket() failed: %s\n", strerror(errno));
    exit(1);
  }
  memset(&addr, '\0', sizeof(addr));
  addr.sun_family = AF_UNIX;
  strcpy(addr.sun_path, "X/tmp/dbus-fake-socket-path-used-in-configure-test");
  addr.sun_path[0] = '\0';
  if (bind(listen_fd, (struct sockaddr *)&addr, SUN_LEN(&addr)) < 0) {
    fprintf(stderr, "Abstract socket namespace bind() failed: %s\n",
            strerror(errno));
    exit(1);
  } else
    exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    0x2e29(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11eb <main+0x6b>
mov    0x2e14(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe24(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe03(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x18(%rbp),%rdi
call   1090 <SUN_LEN@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1060 <bind@plt>
cmp    $0x0,%rax
jge    1283 <main+0x103>
mov    0x2d7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x30(%rbp),%edi
mov    %rax,%rdx
lea    0xdd4(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <socket@plt>
test   %eax,%eax
jns    11c4 <main+0x44>
mov    0x2e25(%rip),%rax
mov    (%rax),%ebx
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe3e(%rip),%rsi
jmp    1237 <main+0xb7>
mov    %eax,%ebx
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    0x8(%rsp),%rdi
lea    0xe22(%rip),%rsi
call   1030 <strcpy@plt>
mov    0x8(%rsp),%rax
movb   $0x0,(%rax)
mov    %r14,%rdi
call   1090 <SUN_LEN@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <bind@plt>
test   %rax,%rax
jns    124b <main+0xcb>
mov    0x2db0(%rip),%rax
mov    (%rax),%ebx
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe11(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@PF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [21 x i8] c"socket() failed: %s\0A\00"
@errno = global i32 0
@AF_UNIX = global i32 0
@.str.1 = [51 x i8] c"X/tmp/dbus-fake-socket-path-used-in-configure-test\00"
@.str.2 = [45 x i8] c"Abstract socket namespace bind() failed: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.sockaddr_un
store i32 0, i32* %1
%4 = load i32, i32* @PF_UNIX
%5 = load i32, i32* @SOCK_STREAM
%6 = call i32 @socket(i32 %4, i32 %5, i32 0)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = load i32, i32* @errno
%12 = call i8* @strerror(i32 %11)
%13 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = call i32 @memset(%struct.sockaddr_un* %3, i8 signext 0, i32 16)
%17 = load i32, i32* @AF_UNIX
%18 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i32 0, i32 1
store i32 %17, i32* %18
%19 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i32 0, i32 0
%20 = load i8*, i8** %19
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%22 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i32 0, i32 0
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8, i8* %23, i64 0
store i8 0, i8* %24
%25 = load i32, i32* %2
%26 = bitcast %struct.sockaddr_un* %3 to %struct.sockaddr*
%27 = call i32 @SUN_LEN(%struct.sockaddr_un* %3)
%28 = call i64 @bind(i32 %25, %struct.sockaddr* %26, i32 %27)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %15
%31 = load i32, i32* @stderr
%32 = load i32, i32* @errno
%33 = call i8* @strerror(i32 %32)
%34 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %15
%37 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@PF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [21 x i8] c"socket() failed: %s\0A\00"
@errno = global i32 0
@AF_UNIX = global i32 0
@.str.1 = [51 x i8] c"X/tmp/dbus-fake-socket-path-used-in-configure-test\00"
@.str.2 = [45 x i8] c"Abstract socket namespace bind() failed: %s\0A\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_un
%2 = bitcast %struct.sockaddr_un* %1 to i8*
%3 = load i32, i32* @PF_UNIX
%4 = load i32, i32* @SOCK_STREAM
%5 = tail call i32 @socket(i32 %3, i32 %4, i32 0)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = tail call i8* @strerror(i32 %9)
%11 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %0
%14 = call i32 @memset(%struct.sockaddr_un* %1, i8 signext 0, i32 16)
%15 = load i32, i32* @AF_UNIX
%16 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %1, i64 0, i32 1
store i32 %15, i32* %16
%17 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %1, i64 0, i32 0
%18 = load i8*, i8** %17
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%20 = load i8*, i8** %17
store i8 0, i8* %20
%21 = bitcast %struct.sockaddr_un* %1 to %struct.sockaddr*
%22 = call i32 @SUN_LEN(%struct.sockaddr_un* %1)
%23 = call i64 @bind(i32 %5, %struct.sockaddr* %21, i32 %22)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %13
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %13
%32 = call i32 @exit(i32 0)
unreachable
}