#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 SOCK_DGRAM;
int SOCK_NONBLOCK;
scalar_t__ WEXITSTATUS(int);
scalar_t__ bind(int, struct sockaddr *, int);
int client(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int read(int, char *, int);
int socket(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ test_daemon();
int /*<<< orphan*/ test_init(int, char **);
int /*<<< orphan*/ test_msg(char *, ...);
int /*<<< orphan*/ test_waitsig();
int /*<<< orphan*/ unlink(char *);
scalar_t__ wait(int *);
int main(int argc, char **argv) {
  struct sockaddr_un addr;
  int srv, status, ret;
  char buf[1024];
  test_init(argc, argv);
  srv = socket(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0);
  if (srv < 0) {
    test_msg("ERR: %s:%d: "
             "open srv"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/fbocharov/criu/refs/heads/master/test/"
             "zdtm/live/static/socket_close_data01.c",
             55, errno, strerror(errno));
    exit(1);
  }
  addr.sun_family = AF_UNIX;
  strcpy(addr.sun_path, "socket_close_data01.sock");
  if (bind(srv, (struct sockaddr *)&addr, sizeof(struct sockaddr_un))) {
    test_msg("ERR: %s:%d: "
             "bind srv"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/fbocharov/criu/refs/heads/master/test/"
             "zdtm/live/static/socket_close_data01.c",
             63, errno, strerror(errno));
    exit(1);
  }
  if (fork() == 0) {
    close(srv);
    client("(iter1)");
    exit(0);
  }
  test_daemon();
  test_waitsig();
  ret = read(srv, buf, sizeof("hello"));
  buf[ret > 0 ? ret : 0] = 0;
  if (ret != sizeof("hello")) {
    test_msg("FAIL: %s:%d: "
             "%d: %s"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/fbocharov/criu/refs/heads/master/test/"
             "zdtm/live/static/socket_close_data01.c",
             80, ret, buf, errno, strerror(errno));
    ret = 1;
    goto unlink;
  }
  ret = 1;
  if (wait(NULL) == -1) {
    test_msg("FAIL: %s:%d: "
             "wait failed"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/fbocharov/criu/refs/heads/master/test/"
             "zdtm/live/static/socket_close_data01.c",
             87, errno, strerror(errno));
    goto unlink;
  }
  if (fork() == 0) {
    exit(client("(iter2)"));
  }
  if (wait(&status) < 0) {
    test_msg("FAIL: %s:%d: "
             "wait failed"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/fbocharov/criu/refs/heads/master/test/"
             "zdtm/live/static/socket_close_data01.c",
             97, errno, strerror(errno));
    goto unlink;
  }
  if (WEXITSTATUS(status) != 0) {
    test_msg("FAIL: %s:%d: "
             "connect failed"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/fbocharov/criu/refs/heads/master/test/"
             "zdtm/live/static/socket_close_data01.c",
             102, errno, strerror(errno));
    goto unlink;
  }
  ret = 0;
  test_msg("PASS\n");
unlink:
  unlink("socket_close_data01.sock");
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <test_init@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
mov    0x2dab(%rip),%rax
mov    (%rax),%esi
mov    0x2d92(%rip),%rax
or     (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    129e <main+0x9e>
mov    0x2d6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x434(%rbp)
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x434(%rbp),%ecx
mov    %eax,%r8d
lea    0xd7f(%rip),%rdi
lea    0xda0(%rip),%rsi
mov    $0x37,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%edi
lea    0xe1b(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x1c(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x8,%edx
call   10b0 <bind@plt>
cmp    $0x0,%rax
je     131e <main+0x11e>
mov    0x2ced(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x438(%rbp)
mov    0x2cde(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x438(%rbp),%ecx
mov    %eax,%r8d
lea    0xde7(%rip),%rdi
lea    0xd20(%rip),%rsi
mov    $0x3f,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    $0x0,%al
call   1110 <fork@plt>
cmp    $0x0,%rax
jne    134a <main+0x14a>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
lea    0xdd2(%rip),%rdi
call   10d0 <client@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    $0x0,%al
call   1060 <test_daemon@plt>
mov    $0x0,%al
call   10a0 <test_waitsig@plt>
mov    -0x1c(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0x6,%edx
call   1090 <read@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    1387 <main+0x187>
mov    -0x24(%rbp),%eax
mov    %eax,-0x43c(%rbp)
jmp    1394 <main+0x194>
xor    %eax,%eax
mov    %eax,-0x43c(%rbp)
jmp    1394 <main+0x194>
mov    -0x43c(%rbp),%eax
cltq
movb   $0x0,-0x430(%rbp,%rax,1)
movslq -0x24(%rbp),%rax
cmp    $0x6,%rax
je     1423 <main+0x223>
mov    -0x24(%rbp),%eax
mov    %eax,-0x44c(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x448(%rbp)
mov    0x2bf8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x440(%rbp)
mov    0x2be9(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x44c(%rbp),%ecx
mov    -0x448(%rbp),%r8
mov    -0x440(%rbp),%r9d
lea    0xd17(%rip),%rdi
lea    0xc20(%rip),%rsi
mov    $0x50,%edx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1080 <test_msg@plt>
movl   $0x1,-0x24(%rbp)
jmp    156a <main+0x36a>
movl   $0x1,-0x24(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1100 <wait@plt>
cmp    $0xffffffffffffffff,%rax
jne    1482 <main+0x282>
mov    0x2b84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x450(%rbp)
mov    0x2b75(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x450(%rbp),%ecx
mov    %eax,%r8d
lea    0xcd5(%rip),%rdi
lea    0xbb7(%rip),%rsi
mov    $0x57,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
jmp    156a <main+0x36a>
mov    $0x0,%al
call   1110 <fork@plt>
cmp    $0x0,%rax
jne    14a6 <main+0x2a6>
lea    0xcd1(%rip),%rdi
call   10d0 <client@plt>
mov    %eax,%edi
call   10e0 <exit@plt>
lea    -0x20(%rbp),%rdi
call   1100 <wait@plt>
cmp    $0x0,%rax
jge    14fe <main+0x2fe>
mov    0x2b08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x454(%rbp)
mov    0x2af9(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x454(%rbp),%ecx
mov    %eax,%r8d
lea    0xc59(%rip),%rdi
lea    0xb3b(%rip),%rsi
mov    $0x61,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
jmp    156a <main+0x36a>
mov    -0x20(%rbp),%edi
call   10c0 <WEXITSTATUS@plt>
cmp    $0x0,%rax
je     1555 <main+0x355>
mov    0x2ab1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x458(%rbp)
mov    0x2aa2(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x458(%rbp),%ecx
mov    %eax,%r8d
lea    0xc36(%rip),%rdi
lea    0xae4(%rip),%rsi
mov    $0x66,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
jmp    156a <main+0x36a>
movl   $0x0,-0x24(%rbp)
lea    0xc3f(%rip),%rdi
mov    $0x0,%al
call   1080 <test_msg@plt>
lea    0xb5e(%rip),%rdi
call   1030 <unlink@plt>
mov    -0x24(%rbp),%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x428,%rsp
call   1050 <test_init@plt>
mov    0x2dd3(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2dc1(%rip),%rax
mov    0x2daa(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
test   %eax,%eax
js     13d4 <main+0x1d4>
mov    %eax,%ebx
mov    0x0(%rbp),%eax
mov    %eax,0x1c(%rsp)
lea    0xe86(%rip),%rsi
call   1040 <strcpy@plt>
lea    0x18(%rsp),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   10b0 <bind@plt>
test   %rax,%rax
jne    13f9 <main+0x1f9>
xor    %ebp,%ebp
xor    %eax,%eax
call   1110 <fork@plt>
test   %rax,%rax
je     1432 <main+0x232>
xor    %eax,%eax
call   1060 <test_daemon@plt>
xor    %eax,%eax
call   10a0 <test_waitsig@plt>
lea    0x20(%rsp),%rsi
mov    %ebx,%edi
mov    $0x6,%edx
call   1090 <read@plt>
test   %eax,%eax
cmovns %eax,%ebp
movb   $0x0,0x20(%rsp,%rbp,1)
cmp    $0x6,%eax
jne    1316 <main+0x116>
xor    %edi,%edi
call   1100 <wait@plt>
cmp    $0xffffffffffffffff,%rax
je     1351 <main+0x151>
xor    %eax,%eax
call   1110 <fork@plt>
test   %rax,%rax
je     144c <main+0x24c>
lea    0x14(%rsp),%rdi
call   1100 <wait@plt>
test   %rax,%rax
js     1376 <main+0x176>
mov    0x14(%rsp),%edi
call   10c0 <WEXITSTATUS@plt>
test   %rax,%rax
je     13c2 <main+0x1c2>
mov    0x2cd3(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10f0 <strerror@plt>
lea    0xe6e(%rip),%rdi
lea    0xd1c(%rip),%rsi
mov    $0x66,%edx
jmp    1399 <main+0x199>
mov    %eax,%ebx
mov    0x2ca9(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10f0 <strerror@plt>
mov    %eax,(%rsp)
lea    0xde6(%rip),%rdi
lea    0xcef(%rip),%rsi
lea    0x20(%rsp),%r8
mov    $0x50,%edx
mov    %ebx,%ecx
mov    %ebp,%r9d
xor    %eax,%eax
call   1080 <test_msg@plt>
jmp    13a5 <main+0x1a5>
mov    0x2c70(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10f0 <strerror@plt>
lea    0xdd7(%rip),%rdi
lea    0xcb9(%rip),%rsi
mov    $0x57,%edx
jmp    1399 <main+0x199>
mov    0x2c4b(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10f0 <strerror@plt>
lea    0xdb2(%rip),%rdi
lea    0xc94(%rip),%rsi
mov    $0x61,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1080 <test_msg@plt>
mov    $0x1,%ebx
lea    0xd1e(%rip),%rdi
call   1030 <unlink@plt>
mov    %ebx,%eax
add    $0x428,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xdd9(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <test_msg@plt>
jmp    13aa <main+0x1aa>
mov    0x2bed(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10f0 <strerror@plt>
lea    0xc15(%rip),%rdi
lea    0xc36(%rip),%rsi
mov    $0x37,%edx
jmp    141c <main+0x21c>
mov    0x2bc8(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10f0 <strerror@plt>
lea    0xcd8(%rip),%rdi
lea    0xc11(%rip),%rsi
mov    $0x3f,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    %ebx,%edi
call   1070 <close@plt>
lea    0xcd0(%rip),%rdi
call   10d0 <client@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    0xd18(%rip),%rdi
call   10d0 <client@plt>
mov    %eax,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
@SOCK_DGRAM = global i32 0
@SOCK_NONBLOCK = global i32 0
@.str = [40 x i8] c"ERR: %s:%d: open srv (errno = %d (%s))\0A\00"
@.str.1 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fbocharov/criu/refs/heads/master/test/zdtm/live/static/socket_close_data01.c\00"
@errno = global i32 0
@.str.2 = [25 x i8] c"socket_close_data01.sock\00"
@.str.3 = [40 x i8] c"ERR: %s:%d: bind srv (errno = %d (%s))\0A\00"
@.str.4 = [8 x i8] c"(iter1)\00"
@.str.5 = [39 x i8] c"FAIL: %s:%d: %d: %s (errno = %d (%s))\0A\00"
@.str.6 = [44 x i8] c"FAIL: %s:%d: wait failed (errno = %d (%s))\0A\00"
@.str.7 = [8 x i8] c"(iter2)\00"
@.str.8 = [47 x i8] c"FAIL: %s:%d: connect failed (errno = %d (%s))\0A\00"
@.str.9 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_un
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @test_init(i32 %11, i8** %12)
%14 = load i32, i32* @AF_UNIX
%15 = load i32, i32* @SOCK_DGRAM
%16 = load i32, i32* @SOCK_NONBLOCK
%17 = or i32 %15, %16
%18 = call i32 @socket(i32 %14, i32 %17, i32 0)
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %2
%22 = load i32, i32* @errno
%23 = load i32, i32* @errno
%24 = call i32 @strerror(i32 %23)
%25 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 55, i32 %22, i32 %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %2
%28 = load i32, i32* @AF_UNIX
%29 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %6, i32 0, i32 1
store i32 %28, i32* %29
%30 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %6, i32 0, i32 0
%31 = load i32, i32* %30
%32 = call i32 @strcpy(i32 %31, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%33 = load i32, i32* %7
%34 = bitcast %struct.sockaddr_un* %6 to %struct.sockaddr*
%35 = call i64 @bind(i32 %33, %struct.sockaddr* %34, i32 8)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %27
%38 = load i32, i32* @errno
%39 = load i32, i32* @errno
%40 = call i32 @strerror(i32 %39)
%41 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 63, i32 %38, i32 %40)
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %27
%44 = call i64 (...) @fork()
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = load i32, i32* %7
%48 = call i32 @close(i32 %47)
%49 = call i32 @client(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%50 = call i32 @exit(i32 0)
unreachable
51: ; preds = %43
%52 = call i32 (...) @test_daemon()
%53 = call i32 (...) @test_waitsig()
%54 = load i32, i32* %7
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%56 = call i32 @read(i32 %54, i8* %55, i32 6)
store i32 %56, i32* %9
%57 = load i32, i32* %9
%58 = icmp sgt i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %51
%60 = load i32, i32* %9
br label %62
61: ; preds = %51
br label %62
62: ; preds = %61, %59
%63 = phi i32 [ %60, %59 ], [ 0, %61 ]
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %64
store i8 0, i8* %65
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = icmp ne i64 %67, 6
br i1 %68, label %69, label %76
69: ; preds = %62
%70 = load i32, i32* %9
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%72 = load i32, i32* @errno
%73 = load i32, i32* @errno
%74 = call i32 @strerror(i32 %73)
%75 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 80, i32 %70, i8* %71, i32 %72, i32 %74)
store i32 1, i32* %9
br label %109
76: ; preds = %62
store i32 1, i32* %9
%77 = call i64 @wait(i32* null)
%78 = icmp eq i64 %77, -1
br i1 %78, label %79, label %84
79: ; preds = %76
%80 = load i32, i32* @errno
%81 = load i32, i32* @errno
%82 = call i32 @strerror(i32 %81)
%83 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 87, i32 %80, i32 %82)
br label %109
84: ; preds = %76
%85 = call i64 (...) @fork()
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %84
%88 = call i32 @client(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%89 = call i32 @exit(i32 %88)
unreachable
90: ; preds = %84
%91 = call i64 @wait(i32* %8)
%92 = icmp slt i64 %91, 0
br i1 %92, label %93, label %98
93: ; preds = %90
%94 = load i32, i32* @errno
%95 = load i32, i32* @errno
%96 = call i32 @strerror(i32 %95)
%97 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 97, i32 %94, i32 %96)
br label %109
98: ; preds = %90
%99 = load i32, i32* %8
%100 = call i64 @WEXITSTATUS(i32 %99)
%101 = icmp ne i64 %100, 0
br i1 %101, label %102, label %107
102: ; preds = %98
%103 = load i32, i32* @errno
%104 = load i32, i32* @errno
%105 = call i32 @strerror(i32 %104)
%106 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 102, i32 %103, i32 %105)
br label %109
107: ; preds = %98
store i32 0, i32* %9
%108 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %109
109: ; preds = %107, %102, %93, %79, %69
%110 = call i32 @unlink(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%111 = load i32, i32* %9
ret i32 %111
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
@SOCK_DGRAM = global i32 0
@SOCK_NONBLOCK = global i32 0
@.str = [40 x i8] c"ERR: %s:%d: open srv (errno = %d (%s))\0A\00"
@.str.1 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fbocharov/criu/refs/heads/master/test/zdtm/live/static/socket_close_data01.c\00"
@errno = global i32 0
@.str.2 = [25 x i8] c"socket_close_data01.sock\00"
@.str.3 = [40 x i8] c"ERR: %s:%d: bind srv (errno = %d (%s))\0A\00"
@.str.4 = [8 x i8] c"(iter1)\00"
@.str.5 = [39 x i8] c"FAIL: %s:%d: %d: %s (errno = %d (%s))\0A\00"
@.str.6 = [44 x i8] c"FAIL: %s:%d: wait failed (errno = %d (%s))\0A\00"
@.str.7 = [8 x i8] c"(iter2)\00"
@.str.8 = [47 x i8] c"FAIL: %s:%d: connect failed (errno = %d (%s))\0A\00"
@.str.9 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.sockaddr_un
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = bitcast %struct.sockaddr_un* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = tail call i32 @test_init(i32 %0, i8** %1)
%10 = load i32, i32* @AF_UNIX
%11 = load i32, i32* @SOCK_DGRAM
%12 = load i32, i32* @SOCK_NONBLOCK
%13 = or i32 %12, %11
%14 = tail call i32 @socket(i32 %10, i32 %13, i32 0)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i32, i32* @errno
%18 = tail call i32 @strerror(i32 %17)
%19 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 55, i32 %17, i32 %18)
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i32, i32* @AF_UNIX
%23 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i64 0, i32 1
store i32 %22, i32* %23
%24 = tail call i32 @strcpy(i32 undef, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%25 = bitcast %struct.sockaddr_un* %3 to %struct.sockaddr*
%26 = call i64 @bind(i32 %14, %struct.sockaddr* %25, i32 8)
%27 = icmp eq i64 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %21
%29 = load i32, i32* @errno
%30 = call i32 @strerror(i32 %29)
%31 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 63, i32 %29, i32 %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %21
%34 = call i64 (...) @fork()
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = call i32 @close(i32 %14)
%38 = call i32 @client(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %33
%41 = call i32 (...) @test_daemon()
%42 = call i32 (...) @test_waitsig()
%43 = call i32 @read(i32 %14, i8* %8, i32 6)
%44 = icmp sgt i32 %43, 0
%45 = select i1 %44, i32 %43, i32 0
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %46
store i8 0, i8* %47
%48 = icmp eq i32 %43, 6
br i1 %48, label %53, label %49
49: ; preds = %40
%50 = load i32, i32* @errno
%51 = call i32 @strerror(i32 %50)
%52 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 80, i32 %43, i8* %8, i32 %50, i32 %51)
br label %83
53: ; preds = %40
%54 = call i64 @wait(i32* null)
%55 = icmp eq i64 %54, -1
br i1 %55, label %56, label %60
56: ; preds = %53
%57 = load i32, i32* @errno
%58 = call i32 @strerror(i32 %57)
%59 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 87, i32 %57, i32 %58)
br label %83
60: ; preds = %53
%61 = call i64 (...) @fork()
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %60
%64 = call i32 @client(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %60
%67 = call i64 @wait(i32* %4)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %66
%70 = load i32, i32* @errno
%71 = call i32 @strerror(i32 %70)
%72 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 97, i32 %70, i32 %71)
br label %83
73: ; preds = %66
%74 = load i32, i32* %4
%75 = call i64 @WEXITSTATUS(i32 %74)
%76 = icmp eq i64 %75, 0
br i1 %76, label %81, label %77
77: ; preds = %73
%78 = load i32, i32* @errno
%79 = call i32 @strerror(i32 %78)
%80 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 102, i32 %78, i32 %79)
br label %83
81: ; preds = %73
%82 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %83
83: ; preds = %81, %77, %69, %56, %49
%84 = phi i32 [ 1, %49 ], [ 1, %56 ], [ 1, %69 ], [ 1, %77 ], [ 0, %81 ]
%85 = call i32 @unlink(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
ret i32 %84
}