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

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ EBADF;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
scalar_t__ lrand48();
int read(int, char *, int);
int socketpair(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
               int *);
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 write(int, char *, int);
int main(int argc, char *argv[]) {
  int ssk_pair[2], ret;
  char aux, data;
  test_init(argc, argv);
  data = (char)lrand48();
  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/sockets02.c",
             31, errno, strerror(errno));
    exit(1);
  }
  if (write(ssk_pair[1], &data, sizeof(data)) != sizeof(data)) {
    test_msg("FAIL: %s:%d: "
             "write\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/sockets02.c",
             36, errno, strerror(errno));
    exit(1);
  }
  close(ssk_pair[1]);
  test_daemon();
  test_waitsig();
  ret = read(ssk_pair[0], &aux, sizeof(aux));
  if (ret != sizeof(data) && aux != data) {
    test_msg("FAIL: %s:%d: "
             "Data loss (write %d, read %d)"
             " (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/sockets02.c",
             47, data, aux, errno, strerror(errno));
    return 1;
  }
  errno = 0;
  ret = read(ssk_pair[0], &aux, sizeof(aux));
  if (ret != 0 || errno != 0) {
    test_msg("FAIL: %s:%d: "
             "Opened end in wrong state (%d/%d)"
             " (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/sockets02.c",
             54, ret, errno, errno, strerror(errno));
    return 0;
  }
  errno = 0;
  ret = read(ssk_pair[1], &aux, sizeof(aux));
  if (ret != -1 || errno != EBADF) {
    test_msg("FAIL: %s:%d: "
             "Closed end in wrong state (%d/%d)"
             " (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/sockets02.c",
             61, ret, errno, errno, strerror(errno));
    return 0;
  }
  test_msg("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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    $0x0,%al
call   10b0 <lrand48@plt>
mov    %al,-0x1e(%rbp)
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    0x2dec(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rcx
xor    %edx,%edx
call   10a0 <socketpair@plt>
cmp    $0xffffffff,%eax
jne    1246 <main+0x96>
mov    0x2dc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x24(%rbp),%ecx
mov    %eax,%r8d
lea    0xdd7(%rip),%rdi
lea    0xdfc(%rip),%rsi
mov    $0x1f,%edx
mov    $0x0,%al
call   1070 <test_msg@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cltq
cmp    $0x1,%rax
je     12a7 <main+0xf7>
mov    0x2d66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x28(%rbp),%ecx
mov    %eax,%r8d
lea    0xe48(%rip),%rdi
lea    0xd9b(%rip),%rsi
mov    $0x24,%edx
mov    $0x0,%al
call   1070 <test_msg@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    $0x0,%al
call   1050 <test_daemon@plt>
mov    $0x0,%al
call   1090 <test_waitsig@plt>
mov    -0x18(%rbp),%edi
lea    -0x1d(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0x1,%rax
je     134b <main+0x19b>
movsbl -0x1d(%rbp),%eax
movsbl -0x1e(%rbp),%ecx
cmp    %ecx,%eax
je     134b <main+0x19b>
movsbl -0x1e(%rbp),%eax
mov    %eax,-0x34(%rbp)
movsbl -0x1d(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2ccc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x34(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
lea    0xdd0(%rip),%rdi
lea    0xcfc(%rip),%rsi
mov    $0x2f,%edx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1070 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    149e <main+0x2ee>
mov    0x2c7e(%rip),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%edi
lea    -0x1d(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1386 <main+0x1d6>
mov    0x2c53(%rip),%rax
cmpl   $0x0,(%rax)
je     13e6 <main+0x236>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    0x2c3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2c31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x40(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
mov    -0x38(%rbp),%r9d
lea    0xd73(%rip),%rdi
lea    0xc61(%rip),%rsi
mov    $0x36,%edx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1070 <test_msg@plt>
movl   $0x0,-0x4(%rbp)
jmp    149e <main+0x2ee>
mov    0x2be3(%rip),%rax
movl   $0x0,(%rax)
mov    -0x14(%rbp),%edi
lea    -0x1d(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1429 <main+0x279>
mov    0x2bb8(%rip),%rax
mov    (%rax),%eax
mov    0x2ba7(%rip),%rcx
cmp    (%rcx),%eax
je     1489 <main+0x2d9>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2b9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2b8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2b82(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x4c(%rbp),%ecx
mov    -0x48(%rbp),%r8d
mov    -0x44(%rbp),%r9d
lea    0xd12(%rip),%rdi
lea    0xbbe(%rip),%rsi
mov    $0x3d,%edx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1070 <test_msg@plt>
movl   $0x0,-0x4(%rbp)
jmp    149e <main+0x2ee>
lea    0xd2b(%rip),%rdi
mov    $0x0,%al
call   1070 <test_msg@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
call   1030 <test_init@plt>
xor    %eax,%eax
call   10b0 <lrand48@plt>
mov    %rax,%rbx
mov    %bl,0xf(%rsp)
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
mov    0x2dfb(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rcx
xor    %edx,%edx
call   10a0 <socketpair@plt>
cmp    $0xffffffff,%eax
je     1361 <main+0x1b1>
mov    0x14(%rsp),%edi
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0x1,%eax
jne    1386 <main+0x1d6>
mov    0x14(%rsp),%edi
call   1060 <close@plt>
xor    %eax,%eax
call   1050 <test_daemon@plt>
xor    %eax,%eax
call   1090 <test_waitsig@plt>
mov    0x10(%rsp),%edi
lea    0xe(%rsp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
cmp    $0x1,%eax
je     124d <main+0x9d>
movsbl 0xe(%rsp),%ebp
cmp    %bl,%bpl
jne    12e1 <main+0x131>
mov    0x2d7c(%rip),%r15
movl   $0x0,(%r15)
mov    0x10(%rsp),%edi
lea    0xe(%rsp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
mov    %eax,%ebx
mov    (%r15),%ebp
or     %ebp,%eax
je     129e <main+0xee>
mov    %ebp,%edi
call   10d0 <strerror@plt>
mov    %eax,(%rsp)
lea    0xeaf(%rip),%rdi
lea    0xd9d(%rip),%rsi
xor    %r15d,%r15d
mov    $0x36,%edx
mov    %ebx,%ecx
jmp    1346 <main+0x196>
movl   $0x0,(%r15)
mov    0x14(%rsp),%edi
lea    0xe(%rsp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
mov    %eax,%r14d
mov    (%r15),%ebp
cmp    $0xffffffff,%eax
jne    1323 <main+0x173>
mov    0x2cfe(%rip),%rax
cmp    (%rax),%ebp
jne    1323 <main+0x173>
lea    0xee6(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1070 <test_msg@plt>
jmp    1353 <main+0x1a3>
movsbl %bl,%r14d
mov    0x2ce4(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10d0 <strerror@plt>
mov    %eax,(%rsp)
lea    0xdfa(%rip),%rdi
lea    0xd26(%rip),%rsi
mov    $0x2f,%edx
mov    %r14d,%ecx
mov    %ebp,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
call   1070 <test_msg@plt>
mov    $0x1,%r15d
jmp    1353 <main+0x1a3>
mov    %ebp,%edi
call   10d0 <strerror@plt>
mov    %eax,(%rsp)
lea    0xe45(%rip),%rdi
lea    0xcf1(%rip),%rsi
xor    %r15d,%r15d
mov    $0x3d,%edx
mov    %r14d,%ecx
mov    %ebp,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1070 <test_msg@plt>
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c68(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10d0 <strerror@plt>
lea    0xc88(%rip),%rdi
lea    0xcad(%rip),%rsi
mov    $0x1f,%edx
jmp    13a9 <main+0x1f9>
mov    0x2c43(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10d0 <strerror@plt>
lea    0xd35(%rip),%rdi
lea    0xc88(%rip),%rsi
mov    $0x24,%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 = [166 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/sockets02.c\00"
@errno = global i32 0
@.str.2 = [39 x i8] c"FAIL: %s:%d: write\0A (errno = %d (%s))\0A\00"
@.str.3 = [62 x i8] c"FAIL: %s:%d: Data loss (write %d, read %d) (errno = %d (%s))\0A\00"
@.str.4 = [66 x i8] c"FAIL: %s:%d: Opened end in wrong state (%d/%d) (errno = %d (%s))\0A\00"
@EBADF = global i32 0
@.str.5 = [66 x i8] c"FAIL: %s:%d: Closed end in wrong state (%d/%d) (errno = %d (%s))\0A\00"
@.str.6 = [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 i32
%8 = alloca i8
%9 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @test_init(i32 %10, i8** %11)
%13 = call i64 (...) @lrand48()
%14 = trunc i64 %13 to i8
store i8 %14, i8* %9
%15 = load i32, i32* @AF_UNIX
%16 = load i32, i32* @SOCK_STREAM
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%18 = call i32 @socketpair(i32 %15, i32 %16, i32 0, i32* %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %26
20: ; preds = %2
%21 = load i32, i32* @errno
%22 = load i32, i32* @errno
%23 = call i32 @strerror(i32 %22)
%24 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 31, i32 %21, i32 %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%28 = load i32, i32* %27
%29 = call i32 @write(i32 %28, i8* %9, i32 1)
%30 = sext i32 %29 to i64
%31 = icmp ne i64 %30, 1
br i1 %31, label %32, label %38
32: ; preds = %26
%33 = load i32, i32* @errno
%34 = load i32, i32* @errno
%35 = call i32 @strerror(i32 %34)
%36 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 36, i32 %33, i32 %35)
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %26
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%40 = load i32, i32* %39
%41 = call i32 @close(i32 %40)
%42 = call i32 (...) @test_daemon()
%43 = call i32 (...) @test_waitsig()
%44 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%45 = load i32, i32* %44
%46 = call i32 @read(i32 %45, i8* %8, i32 1)
store i32 %46, i32* %7
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = icmp ne i64 %48, 1
br i1 %49, label %50, label %65
50: ; preds = %38
%51 = load i8, i8* %8
%52 = sext i8 %51 to i32
%53 = load i8, i8* %9
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %52, %54
br i1 %55, label %56, label %65
56: ; preds = %50
%57 = load i8, i8* %9
%58 = sext i8 %57 to i32
%59 = load i8, i8* %8
%60 = sext i8 %59 to i32
%61 = load i32, i32* @errno
%62 = load i32, i32* @errno
%63 = call i32 @strerror(i32 %62)
%64 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 47, i32 %58, i32 %60, i32 %61, i32 %63)
store i32 1, i32* %3
br label %100
65: ; preds = %50, %38
store i32 0, i32* @errno
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%67 = load i32, i32* %66
%68 = call i32 @read(i32 %67, i8* %8, i32 1)
store i32 %68, i32* %7
%69 = load i32, i32* %7
%70 = icmp ne i32 %69, 0
br i1 %70, label %74, label %71
71: ; preds = %65
%72 = load i32, i32* @errno
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %81
74: ; preds = %71, %65
%75 = load i32, i32* %7
%76 = load i32, i32* @errno
%77 = load i32, i32* @errno
%78 = load i32, i32* @errno
%79 = call i32 @strerror(i32 %78)
%80 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 54, i32 %75, i32 %76, i32 %77, i32 %79)
store i32 0, i32* %3
br label %100
81: ; preds = %71
store i32 0, i32* @errno
%82 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%83 = load i32, i32* %82
%84 = call i32 @read(i32 %83, i8* %8, i32 1)
store i32 %84, i32* %7
%85 = load i32, i32* %7
%86 = icmp ne i32 %85, -1
br i1 %86, label %91, label %87
87: ; preds = %81
%88 = load i32, i32* @errno
%89 = load i32, i32* @EBADF
%90 = icmp ne i32 %88, %89
br i1 %90, label %91, label %98
91: ; preds = %87, %81
%92 = load i32, i32* %7
%93 = load i32, i32* @errno
%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 ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 61, i32 %92, i32 %93, i32 %94, i32 %96)
store i32 0, i32* %3
br label %100
98: ; preds = %87
%99 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %3
br label %100
100: ; preds = %98, %91, %74, %56
%101 = load i32, i32* %3
ret i32 %101
}

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 = [166 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/sockets02.c\00"
@errno = global i32 0
@.str.2 = [39 x i8] c"FAIL: %s:%d: write\0A (errno = %d (%s))\0A\00"
@.str.3 = [62 x i8] c"FAIL: %s:%d: Data loss (write %d, read %d) (errno = %d (%s))\0A\00"
@.str.4 = [66 x i8] c"FAIL: %s:%d: Opened end in wrong state (%d/%d) (errno = %d (%s))\0A\00"
@EBADF = global i32 0
@.str.5 = [66 x i8] c"FAIL: %s:%d: Closed end in wrong state (%d/%d) (errno = %d (%s))\0A\00"
@.str.6 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2 x i32]
%4 = alloca i8
%5 = alloca i8
%6 = bitcast [2 x i32]* %3 to i8*
%7 = tail call i32 @test_init(i32 %0, i8** %1)
%8 = tail call i64 (...) @lrand48()
%9 = trunc i64 %8 to i8
store i8 %9, i8* %5
%10 = load i32, i32* @AF_UNIX
%11 = load i32, i32* @SOCK_STREAM
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%13 = call i32 @socketpair(i32 %10, i32 %11, i32 0, i32* %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* @errno
%17 = call i32 @strerror(i32 %16)
%18 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 31, i32 %16, i32 %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%22 = load i32, i32* %21
%23 = call i32 @write(i32 %22, i8* %5, i32 1)
%24 = icmp eq i32 %23, 1
br i1 %24, label %30, label %25
25: ; preds = %20
%26 = load i32, i32* @errno
%27 = call i32 @strerror(i32 %26)
%28 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 36, i32 %26, i32 %27)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %20
%31 = load i32, i32* %21
%32 = call i32 @close(i32 %31)
%33 = call i32 (...) @test_daemon()
%34 = call i32 (...) @test_waitsig()
%35 = load i32, i32* %12
%36 = call i32 @read(i32 %35, i8* %4, i32 1)
%37 = icmp eq i32 %36, 1
br i1 %37, label %47, label %38
38: ; preds = %30
%39 = load i8, i8* %4
%40 = icmp eq i8 %39, %9
br i1 %40, label %47, label %41
41: ; preds = %38
%42 = sext i8 %9 to i32
%43 = sext i8 %39 to i32
%44 = load i32, i32* @errno
%45 = call i32 @strerror(i32 %44)
%46 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 47, i32 %42, i32 %43, i32 %44, i32 %45)
br label %70
47: ; preds = %38, %30
store i32 0, i32* @errno
%48 = load i32, i32* %12
%49 = call i32 @read(i32 %48, i8* %4, i32 1)
%50 = icmp ne i32 %49, 0
%51 = load i32, i32* @errno
%52 = icmp ne i32 %51, 0
%53 = select i1 %50, i1 true, i1 %52
br i1 %53, label %54, label %57
54: ; preds = %47
%55 = call i32 @strerror(i32 %51)
%56 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 54, i32 %49, i32 %51, i32 %51, i32 %55)
br label %70
57: ; preds = %47
store i32 0, i32* @errno
%58 = load i32, i32* %21
%59 = call i32 @read(i32 %58, i8* %4, i32 1)
%60 = icmp eq i32 %59, -1
%61 = load i32, i32* @errno
%62 = load i32, i32* @EBADF
%63 = icmp eq i32 %61, %62
%64 = select i1 %60, i1 %63, i1 false
br i1 %64, label %68, label %65
65: ; preds = %57
%66 = call i32 @strerror(i32 %61)
%67 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 61, i32 %59, i32 %61, i32 %61, i32 %66)
br label %70
68: ; preds = %57
%69 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %70
70: ; preds = %68, %65, %54, %41
%71 = phi i32 [ 1, %41 ], [ 0, %54 ], [ 0, %65 ], [ 0, %68 ]
ret i32 %71
}