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

/* Variables and functions */
int /*<<< orphan*/ PF_UNIX;
int /*<<< orphan*/ SOCK_STREAM;
scalar_t__ bind(int, struct sockaddr_un *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
scalar_t__ listen(int, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ test_msg(char *, char *, int, int /*<<< orphan*/,
                            int /*<<< orphan*/, ...);
int bind_and_listen(struct sockaddr_un *addr) {
  int sk;
  sk = socket(PF_UNIX, SOCK_STREAM, 0);
  if (sk < 0) {
    test_msg("FAIL: %s:%d: "
             "socket"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/KKoukiou/criu-remote/refs/heads/master/"
             "test/zdtm/static/del_standalone_un.c",
             39, errno, strerror(errno));
    return -1;
  }
  if (bind(sk, addr, sizeof(*addr))) {
    test_msg("FAIL: %s:%d: "
             "bind %s"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/KKoukiou/criu-remote/refs/heads/master/"
             "test/zdtm/static/del_standalone_un.c",
             44, addr->sun_path, errno, strerror(errno));
    close(sk);
    return -1;
  }
  if (listen(sk, 1)) {
    test_msg("FAIL: %s:%d: "
             "listen"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/KKoukiou/criu-remote/refs/heads/master/"
             "test/zdtm/static/del_standalone_un.c",
             50, errno, strerror(errno));
    close(sk);
    return -1;
  }
  return sk;
}


x86 assembly (clang, -O0):
<bind_and_listen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11d8 <bind_and_listen+0x78>
mov    0x2e37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x18(%rbp),%ecx
mov    %eax,%r8d
lea    0xe47(%rip),%rdi
lea    0xe67(%rip),%rsi
mov    $0x27,%edx
mov    $0x0,%al
call   1040 <test_msg@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b9 <bind_and_listen+0x159>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1060 <bind@plt>
cmp    $0x0,%rax
je     124e <bind_and_listen+0xee>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    %eax,%r9d
lea    0xea6(%rip),%rdi
lea    0xdf9(%rip),%rsi
mov    $0x2c,%edx
mov    $0x0,%al
call   1040 <test_msg@plt>
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b9 <bind_and_listen+0x159>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1050 <listen@plt>
cmp    $0x0,%rax
je     12b3 <bind_and_listen+0x153>
mov    0x2d64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x24(%rbp),%ecx
mov    %eax,%r8d
lea    0xe69(%rip),%rdi
lea    0xd94(%rip),%rsi
mov    $0x32,%edx
mov    $0x0,%al
call   1040 <test_msg@plt>
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b9 <bind_and_listen+0x159>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bind_and_listen>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <socket@plt>
test   %eax,%eax
js     11d2 <bind_and_listen+0x72>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1060 <bind@plt>
test   %rax,%rax
je     1203 <bind_and_listen+0xa3>
mov    (%r14),%r14d
mov    0x2e2c(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1070 <strerror@plt>
lea    0xf19(%rip),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x2c,%edx
mov    %r14d,%ecx
mov    %ebp,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1040 <test_msg@plt>
jmp    1243 <bind_and_listen+0xe3>
mov    0x2df7(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1070 <strerror@plt>
lea    0xe17(%rip),%rdi
lea    0xe37(%rip),%rsi
mov    $0x27,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <test_msg@plt>
jmp    124a <bind_and_listen+0xea>
mov    %ebx,%edi
mov    $0x1,%esi
call   1050 <listen@plt>
test   %rax,%rax
je     124f <bind_and_listen+0xef>
mov    0x2db5(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1070 <strerror@plt>
lea    0xeca(%rip),%rdi
lea    0xdf5(%rip),%rsi
mov    $0x32,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <test_msg@plt>
mov    %ebx,%edi
call   1030 <close@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i32 }
@PF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [39 x i8] c"FAIL: %s:%d: socket (errno = %d (%s))\0A\00"
@.str.1 = [166 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/KKoukiou/criu-remote/refs/heads/master/test/zdtm/static/del_standalone_un.c\00"
@errno = global i32 0
@.str.2 = [40 x i8] c"FAIL: %s:%d: bind %s (errno = %d (%s))\0A\00"
@.str.3 = [39 x i8] c"FAIL: %s:%d: listen (errno = %d (%s))\0A\00"
define i32 @bind_and_listen(%struct.sockaddr_un* %0) {
%2 = alloca i32
%3 = alloca %struct.sockaddr_un*
%4 = alloca i32
store %struct.sockaddr_un* %0, %struct.sockaddr_un** %3
%5 = load i32, i32* @PF_UNIX
%6 = load i32, i32* @SOCK_STREAM
%7 = call i32 @socket(i32 %5, i32 %6, i32 0)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i32, i32* @errno
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = call i32 (i8*, i8*, i32, i32, i32, ...) @test_msg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 39, i32 %11, i32 %13)
store i32 -1, i32* %2
br label %43
15: ; preds = %1
%16 = load i32, i32* %4
%17 = load %struct.sockaddr_un*, %struct.sockaddr_un** %3
%18 = call i64 @bind(i32 %16, %struct.sockaddr_un* %17, i32 4)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %15
%21 = load %struct.sockaddr_un*, %struct.sockaddr_un** %3
%22 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = load i32, i32* @errno
%25 = load i32, i32* @errno
%26 = call i32 @strerror(i32 %25)
%27 = call i32 (i8*, i8*, i32, i32, i32, ...) @test_msg(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 44, i32 %23, i32 %24, i32 %26)
%28 = load i32, i32* %4
%29 = call i32 @close(i32 %28)
store i32 -1, i32* %2
br label %43
30: ; preds = %15
%31 = load i32, i32* %4
%32 = call i64 @listen(i32 %31, i32 1)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %30
%35 = load i32, i32* @errno
%36 = load i32, i32* @errno
%37 = call i32 @strerror(i32 %36)
%38 = call i32 (i8*, i8*, i32, i32, i32, ...) @test_msg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 50, i32 %35, i32 %37)
%39 = load i32, i32* %4
%40 = call i32 @close(i32 %39)
store i32 -1, i32* %2
br label %43
41: ; preds = %30
%42 = load i32, i32* %4
store i32 %42, i32* %2
br label %43
43: ; preds = %41, %34, %20, %10
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32 }
@PF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [39 x i8] c"FAIL: %s:%d: socket (errno = %d (%s))\0A\00"
@.str.1 = [166 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/KKoukiou/criu-remote/refs/heads/master/test/zdtm/static/del_standalone_un.c\00"
@errno = global i32 0
@.str.2 = [40 x i8] c"FAIL: %s:%d: bind %s (errno = %d (%s))\0A\00"
@.str.3 = [39 x i8] c"FAIL: %s:%d: listen (errno = %d (%s))\0A\00"
define i32 @bind_and_listen(%struct.sockaddr_un* %0) {
%2 = load i32, i32* @PF_UNIX
%3 = load i32, i32* @SOCK_STREAM
%4 = tail call i32 @socket(i32 %2, i32 %3, i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* @errno
%8 = tail call i32 @strerror(i32 %7)
%9 = tail call i32 (i8*, i8*, i32, i32, i32, ...) @test_msg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 39, i32 %7, i32 %8)
br label %28
10: ; preds = %1
%11 = tail call i64 @bind(i32 %4, %struct.sockaddr_un* %0, i32 4)
%12 = icmp eq i64 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %10
%14 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %0, i64 0, i32 0
%15 = load i32, i32* %14
%16 = load i32, i32* @errno
%17 = tail call i32 @strerror(i32 %16)
%18 = tail call i32 (i8*, i8*, i32, i32, i32, ...) @test_msg(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 44, i32 %15, i32 %16, i32 %17)
%19 = tail call i32 @close(i32 %4)
br label %28
20: ; preds = %10
%21 = tail call i64 @listen(i32 %4, i32 1)
%22 = icmp eq i64 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %20
%24 = load i32, i32* @errno
%25 = tail call i32 @strerror(i32 %24)
%26 = tail call i32 (i8*, i8*, i32, i32, i32, ...) @test_msg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 50, i32 %24, i32 %25)
%27 = tail call i32 @close(i32 %4)
br label %28
28: ; preds = %20, %23, %13, %6
%29 = phi i32 [ -1, %6 ], [ -1, %13 ], [ -1, %23 ], [ %4, %20 ]
ret i32 %29
}