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

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ read(int, char **, int);
int socketpair(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
               int *);
scalar_t__ strcmp(char *, 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*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  int ssk_pair[2];
  char buf[64];
  test_init(argc, argv);
  if (socketpair(AF_UNIX, SOCK_STREAM, 0, ssk_pair) == -1) {
    test_msg("FAIL: %s:%d: "
             "socketpair\n"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/sockets_spair.c",
             31, errno, strerror(errno));
    exit(1);
  }
  memset(buf, 0, sizeof(buf));
  write(ssk_pair[0], "packet", sizeof("packet"));
  read(ssk_pair[1], &buf, sizeof(buf));
  if (strcmp(buf, "packet")) {
    test_msg("FAIL: %s:%d: "
             "data corrupted\n"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/sockets_spair.c",
             39, errno, strerror(errno));
    exit(1);
  }
  test_msg("stream            : '%s'\n", buf);
  test_daemon();
  test_waitsig();
  memset(buf, 0, sizeof(buf));
  write(ssk_pair[0], "packet", sizeof("packet"));
  read(ssk_pair[1], &buf, sizeof(buf));
  if (strcmp(buf, "packet")) {
    test_msg("FAIL: %s:%d: "
             "data corrupted\n"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/sockets_spair.c",
             51, errno, strerror(errno));
    exit(1);
  }
  test_msg("stream            : '%s'\n", buf);
  test_msg("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <test_init@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
mov    0x2df6(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rcx
xor    %edx,%edx
call   10b0 <socketpair@plt>
cmp    $0xffffffff,%eax
jne    123c <main+0x8c>
mov    0x2dd1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x64(%rbp),%ecx
mov    %eax,%r8d
lea    0xde1(%rip),%rdi
lea    0xe06(%rip),%rsi
mov    $0x1f,%edx
mov    $0x0,%al
call   1070 <test_msg@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
mov    -0x18(%rbp),%edi
lea    0xe80(%rip),%rsi
mov    $0x7,%edx
call   1040 <write@plt>
mov    -0x14(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x40,%edx
call   1080 <read@plt>
lea    -0x60(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     12cf <main+0x11f>
mov    0x2d3e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x68(%rbp),%ecx
mov    %eax,%r8d
lea    0xe2b(%rip),%rdi
lea    0xd73(%rip),%rsi
mov    $0x27,%edx
mov    $0x0,%al
call   1070 <test_msg@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x60(%rbp),%rsi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1070 <test_msg@plt>
mov    $0x0,%al
call   1050 <test_daemon@plt>
mov    $0x0,%al
call   1090 <test_waitsig@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
mov    -0x18(%rbp),%edi
lea    0xdcd(%rip),%rsi
mov    $0x7,%edx
call   1040 <write@plt>
mov    -0x14(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x40,%edx
call   1080 <read@plt>
lea    -0x60(%rbp),%rdi
lea    0xda7(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1382 <main+0x1d2>
mov    0x2c8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    0x2c7f(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x6c(%rbp),%ecx
mov    %eax,%r8d
lea    0xd78(%rip),%rdi
lea    0xcc0(%rip),%rsi
mov    $0x33,%edx
mov    $0x0,%al
call   1070 <test_msg@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x60(%rbp),%rsi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1070 <test_msg@plt>
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1070 <test_msg@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
call   1030 <test_init@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
mov    0x2e0c(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rcx
xor    %edx,%edx
call   10b0 <socketpair@plt>
cmp    $0xffffffff,%eax
je     12cb <main+0x11b>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
mov    0x8(%rsp),%edi
lea    0xed4(%rip),%r14
mov    %r14,%rsi
mov    $0x7,%edx
call   1040 <write@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1080 <read@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
jne    12f0 <main+0x140>
lea    0xed2(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <test_msg@plt>
xor    %eax,%eax
call   1050 <test_daemon@plt>
xor    %eax,%eax
call   1090 <test_waitsig@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
mov    0x8(%rsp),%edi
lea    0xe64(%rip),%r14
mov    %r14,%rsi
mov    $0x7,%edx
call   1040 <write@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1080 <read@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
jne    1315 <main+0x165>
lea    0xe66(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <test_msg@plt>
lea    0xe6d(%rip),%rdi
xor    %eax,%eax
call   1070 <test_msg@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2cfe(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10d0 <strerror@plt>
lea    0xd1e(%rip),%rdi
lea    0xd43(%rip),%rsi
mov    $0x1f,%edx
jmp    1338 <main+0x188>
mov    0x2cd9(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10d0 <strerror@plt>
lea    0xdd6(%rip),%rdi
lea    0xd1e(%rip),%rsi
mov    $0x27,%edx
jmp    1338 <main+0x188>
mov    0x2cb4(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10d0 <strerror@plt>
lea    0xdb1(%rip),%rdi
lea    0xcf9(%rip),%rsi
mov    $0x33,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1070 <test_msg@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [44 x i8] c"FAIL: %s:%d: socketpair\0A (errno = %d (%s))\0A\00"
@.str.1 = [170 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/master/test/zdtm/live/static/sockets_spair.c\00"
@errno = global i32 0
@.str.2 = [7 x i8] c"packet\00"
@.str.3 = [48 x i8] c"FAIL: %s:%d: data corrupted\0A (errno = %d (%s))\0A\00"
@.str.4 = [26 x i8] c"stream : '%s'\0A\00"
@.str.5 = [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 [2 x i32]
%7 = alloca [64 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @test_init(i32 %8, i8** %9)
%11 = load i32, i32* @AF_UNIX
%12 = load i32, i32* @SOCK_STREAM
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%14 = call i32 @socketpair(i32 %11, i32 %12, i32 0, i32* %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i32, i32* @errno
%18 = load i32, i32* @errno
%19 = call i32 @strerror(i32 %18)
%20 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 31, i32 %17, i32 %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%24 = call i32 @memset(i8* %23, i32 0, i32 64)
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%26 = load i32, i32* %25
%27 = call i32 @write(i32 %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 7)
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%29 = load i32, i32* %28
%30 = bitcast [64 x i8]* %7 to i8**
%31 = call i32 @read(i32 %29, i8** %30, i32 64)
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %22
%36 = load i32, i32* @errno
%37 = load i32, i32* @errno
%38 = call i32 @strerror(i32 %37)
%39 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 39, i32 %36, i32 %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %22
%42 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%43 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %42)
%44 = call i32 (...) @test_daemon()
%45 = call i32 (...) @test_waitsig()
%46 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%47 = call i32 @memset(i8* %46, i32 0, i32 64)
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%49 = load i32, i32* %48
%50 = call i32 @write(i32 %49, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 7)
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%52 = load i32, i32* %51
%53 = bitcast [64 x i8]* %7 to i8**
%54 = call i32 @read(i32 %52, i8** %53, i32 64)
%55 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %64
58: ; preds = %41
%59 = load i32, i32* @errno
%60 = load i32, i32* @errno
%61 = call i32 @strerror(i32 %60)
%62 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 51, i32 %59, i32 %61)
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %41
%65 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%66 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %65)
%67 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [44 x i8] c"FAIL: %s:%d: socketpair\0A (errno = %d (%s))\0A\00"
@.str.1 = [170 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/master/test/zdtm/live/static/sockets_spair.c\00"
@errno = global i32 0
@.str.2 = [7 x i8] c"packet\00"
@.str.3 = [48 x i8] c"FAIL: %s:%d: data corrupted\0A (errno = %d (%s))\0A\00"
@.str.4 = [26 x i8] c"stream : '%s'\0A\00"
@.str.5 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2 x i32]
%4 = alloca [64 x i8]
%5 = bitcast [2 x i32]* %3 to i8*
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @test_init(i32 %0, i8** %1)
%8 = load i32, i32* @AF_UNIX
%9 = load i32, i32* @SOCK_STREAM
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%11 = call i32 @socketpair(i32 %8, i32 %9, i32 0, i32* %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i32, i32* @errno
%15 = call i32 @strerror(i32 %14)
%16 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 31, i32 %14, i32 %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = call i32 @memset(i8* %6, i32 0, i32 64)
%20 = load i32, i32* %10
%21 = call i32 @write(i32 %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 7)
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%23 = load i32, i32* %22
%24 = bitcast [64 x i8]* %4 to i8**
%25 = call i32 @read(i32 %23, i8** %24, i32 64)
%26 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %18
%29 = load i32, i32* @errno
%30 = call i32 @strerror(i32 %29)
%31 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 39, i32 %29, i32 %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %18
%34 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%35 = call i32 (...) @test_daemon()
%36 = call i32 (...) @test_waitsig()
%37 = call i32 @memset(i8* %6, i32 0, i32 64)
%38 = load i32, i32* %10
%39 = call i32 @write(i32 %38, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 7)
%40 = load i32, i32* %22
%41 = call i32 @read(i32 %40, i8** %24, i32 64)
%42 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %49, label %44
44: ; preds = %33
%45 = load i32, i32* @errno
%46 = call i32 @strerror(i32 %45)
%47 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 51, i32 %45, i32 %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %33
%50 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%51 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}