#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*/ peer;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ A(int);
int /*<<< orphan*/ AF_UNIX;
int SOCK_NONBLOCK;
int SOCK_STREAM;
int /*<<< orphan*/ T(int /*<<< orphan*/);
scalar_t__ accept(int, struct sockaddr *, size_t *);
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int socket(int /*<<< orphan*/, int, int /*<<< orphan*/);
int main(void) {
  int sfd;
  struct sockaddr_un addr = {.sun_family = AF_UNIX,
                             .sun_path = "\0x-accept-nonblock"};
  struct sockaddr peer;
  size_t plen = sizeof(peer);
  sfd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0);
  A(sfd > 0);
  T(bind(sfd, (struct sockaddr *)&addr, sizeof(addr)));
  A(accept(sfd, &peer, &plen) < 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
movq   $0x4,-0x28(%rbp)
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
mov    0x2e41(%rip),%rax
or     (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <A@plt>
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x10,%edx
call   1050 <bind@plt>
mov    %eax,%edi
call   1030 <T@plt>
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <accept@plt>
cmp    $0x0,%rax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <A@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xea4(%rip),%rax
mov    %rax,0x10(%rsp)
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    %edi,0x18(%rsp)
movq   $0x4,(%rsp)
mov    0x2e53(%rip),%rax
mov    0x2e54(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,%ebx
xor    %edi,%edi
test   %eax,%eax
setg   %dil
call   1040 <A@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x10,%edx
call   1050 <bind@plt>
mov    %eax,%edi
call   1030 <T@plt>
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
mov    %ebx,%edi
call   1060 <accept@plt>
shr    $0x3f,%rax
mov    %eax,%edi
call   1040 <A@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@.str = [19 x i8] c"\00x-accept-nonblock\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@SOCK_NONBLOCK = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.sockaddr_un
%4 = alloca %struct.sockaddr
%5 = alloca i64
store i32 0, i32* %1
%6 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i32 0, i32 0
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i32 0, i32 1
%8 = load i32, i32* @AF_UNIX
store i32 %8, i32* %7
store i64 4, i64* %5
%9 = load i32, i32* @AF_UNIX
%10 = load i32, i32* @SOCK_STREAM
%11 = load i32, i32* @SOCK_NONBLOCK
%12 = or i32 %10, %11
%13 = call i32 @socket(i32 %9, i32 %12, i32 0)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @A(i32 %16)
%18 = load i32, i32* %2
%19 = bitcast %struct.sockaddr_un* %3 to %struct.sockaddr*
%20 = call i32 @bind(i32 %18, %struct.sockaddr* %19, i32 16)
%21 = call i32 @T(i32 %20)
%22 = load i32, i32* %2
%23 = call i64 @accept(i32 %22, %struct.sockaddr* %4, i64* %5)
%24 = icmp slt i64 %23, 0
%25 = zext i1 %24 to i32
%26 = call i32 @A(i32 %25)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@.str = [19 x i8] c"\00x-accept-nonblock\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@SOCK_NONBLOCK = global i32 0
define i32 @main() {
%1 = alloca %struct.sockaddr_un
%2 = alloca %struct.sockaddr
%3 = alloca i64
%4 = bitcast %struct.sockaddr_un* %1 to i8*
%5 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %1, i64 0, i32 0
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %1, i64 0, i32 1
%7 = load i32, i32* @AF_UNIX
store i32 %7, i32* %6
%8 = bitcast %struct.sockaddr* %2 to i8*
%9 = bitcast i64* %3 to i8*
store i64 4, i64* %3
%10 = load i32, i32* @SOCK_STREAM
%11 = load i32, i32* @SOCK_NONBLOCK
%12 = or i32 %11, %10
%13 = tail call i32 @socket(i32 %7, i32 %12, i32 0)
%14 = icmp sgt i32 %13, 0
%15 = zext i1 %14 to i32
%16 = tail call i32 @A(i32 %15)
%17 = bitcast %struct.sockaddr_un* %1 to %struct.sockaddr*
%18 = call i32 @bind(i32 %13, %struct.sockaddr* %17, i32 16)
%19 = call i32 @T(i32 %18)
%20 = call i64 @accept(i32 %13, %struct.sockaddr* %2, i64* %3)
%21 = lshr i64 %20, 63
%22 = trunc i64 %21 to i32
%23 = call i32 @A(i32 %22)
ret i32 0
}