#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*/ errno;
scalar_t__ memcmp(char *, char *, int);
int read(int, char *, int);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
long strtol(char *, char **, int);
int /*<<< orphan*/ test_msg(char *, char *, int, char *, int /*<<< orphan*/,
                            ...);
int /*<<< orphan*/ write(int, char *, int);
int get_dumpable_from_pipes(int pipe_input, int pipe_output) {
  char buf[256];
  int len;
  long value;
  char *endptr = NULL;
  write(pipe_input, "GET\n", 4);
  len = read(pipe_output, buf, sizeof(buf));
  if (len < 0) {
    test_msg("ERR: %s:%d: "
             "error in parent reading from pipe"
             " (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/dumpable02.c",
             41, errno, strerror(errno));
    return -1;
  }
  if (memcmp(buf, "DUMPABLE:", 9) != 0) {
    test_msg("ERR: %s:%d: "
             "child returned [%s]"
             " (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/dumpable02.c",
             46, buf, errno, strerror(errno));
    return -1;
  }
  value = strtol(&buf[9], &endptr, 10);
  if (!endptr || *endptr != '\n' || endptr != buf + len - 1) {
    test_msg("ERR: %s:%d: "
             "child returned [%s]"
             " (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/dumpable02.c",
             52, buf, errno, strerror(errno));
    return -1;
  }
  return (int)value;
}


x86 assembly (clang, -O0):
<get_dumpable_from_pipes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x128(%rbp)
mov    -0x8(%rbp),%edi
lea    0xe7a(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0xc(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x100,%edx
call   1050 <read@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0x0,-0x114(%rbp)
jge    1206 <get_dumpable_from_pipes+0xa6>
mov    0x2e22(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x130(%rbp)
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x130(%rbp),%rcx
mov    %eax,%r8d
lea    0xe1e(%rip),%rdi
lea    0xe58(%rip),%rsi
mov    $0x29,%edx
mov    $0x0,%al
call   1040 <test_msg@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135f <get_dumpable_from_pipes+0x1ff>
lea    -0x110(%rbp),%rdi
lea    0xed9(%rip),%rsi
mov    $0x9,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     128a <get_dumpable_from_pipes+0x12a>
lea    -0x110(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x134(%rbp)
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x140(%rbp),%rcx
mov    -0x134(%rbp),%r8d
mov    %eax,%r9d
lea    0xe8c(%rip),%rdi
lea    0xdd4(%rip),%rsi
mov    $0x2e,%edx
mov    $0x0,%al
call   1040 <test_msg@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135f <get_dumpable_from_pipes+0x1ff>
lea    -0x110(%rbp),%rdi
add    $0x9,%rdi
lea    -0x128(%rbp),%rsi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,-0x120(%rbp)
cmpq   $0x0,-0x128(%rbp)
je     12f3 <get_dumpable_from_pipes+0x193>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    12f3 <get_dumpable_from_pipes+0x193>
mov    -0x128(%rbp),%rax
lea    -0x110(%rbp),%rcx
movslq -0x114(%rbp),%rdx
add    %rdx,%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rax
je     1355 <get_dumpable_from_pipes+0x1f5>
lea    -0x110(%rbp),%rax
mov    %rax,-0x150(%rbp)
mov    0x2cd8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x144(%rbp)
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x150(%rbp),%rcx
mov    -0x144(%rbp),%r8d
mov    %eax,%r9d
lea    0xdc1(%rip),%rdi
lea    0xd09(%rip),%rsi
mov    $0x34,%edx
mov    $0x0,%al
call   1040 <test_msg@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135f <get_dumpable_from_pipes+0x1ff>
mov    -0x120(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dumpable_from_pipes>:
push   %rbx
sub    $0x110,%rsp
mov    %esi,%ebx
movq   $0x0,0x8(%rsp)
lea    0xe86(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x100,%edx
call   1050 <read@plt>
test   %eax,%eax
js     11e3 <get_dumpable_from_pipes+0x83>
mov    %eax,%ebx
lea    0xf4b(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0x9,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
je     1218 <get_dumpable_from_pipes+0xb8>
mov    0x2e23(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1080 <strerror@plt>
lea    0xf2a(%rip),%rdi
lea    0xe72(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    $0x2e,%edx
jmp    1271 <get_dumpable_from_pipes+0x111>
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
movslq %eax,%rbx
mov    %ebx,%edi
call   1080 <strerror@plt>
lea    0xe08(%rip),%rdi
lea    0xe42(%rip),%rsi
mov    $0x29,%edx
mov    %rbx,%rcx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <test_msg@plt>
jmp    127e <get_dumpable_from_pipes+0x11e>
lea    0x19(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
je     1249 <get_dumpable_from_pipes+0xe9>
cmpb   $0xa,(%rcx)
jne    1249 <get_dumpable_from_pipes+0xe9>
mov    %ebx,%edx
add    %rsp,%rdx
add    $0xf,%rdx
cmp    %rdx,%rcx
je     1283 <get_dumpable_from_pipes+0x123>
mov    0x2d90(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1080 <strerror@plt>
lea    0xe97(%rip),%rdi
lea    0xddf(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    $0x34,%edx
mov    %ebx,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1040 <test_msg@plt>
mov    $0xffffffff,%eax
add    $0x110,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"GET\0A\00"
@.str.1 = [65 x i8] c"ERR: %s:%d: error in parent reading from pipe (errno = %d (%s))\0A\00"
@.str.2 = [167 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/dumpable02.c\00"
@errno = global i32 0
@.str.3 = [10 x i8] c"DUMPABLE:\00"
@.str.4 = [51 x i8] c"ERR: %s:%d: child returned [%s] (errno = %d (%s))\0A\00"
define i32 @get_dumpable_from_pipes(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [256 x i8]
%7 = alloca i32
%8 = alloca i64
%9 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* null, i8** %9
%10 = load i32, i32* %4
%11 = call i32 @write(i32 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%12 = load i32, i32* %5
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%14 = call i32 @read(i32 %12, i8* %13, i32 256)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %2
%18 = load i32, i32* @errno
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i8*
%21 = load i32, i32* @errno
%22 = call i32 @strerror(i32 %21)
%23 = call i32 (i8*, i8*, i32, i8*, i32, ...) @test_msg(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0), i32 41, i8* %20, i32 %22)
store i32 -1, i32* %3
br label %61
24: ; preds = %2
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%26 = call i64 @memcmp(i8* %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 9)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %24
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%30 = load i32, i32* @errno
%31 = load i32, i32* @errno
%32 = call i32 @strerror(i32 %31)
%33 = call i32 (i8*, i8*, i32, i8*, i32, ...) @test_msg(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0), i32 46, i8* %29, i32 %30, i32 %32)
store i32 -1, i32* %3
br label %61
34: ; preds = %24
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 9
%36 = call i64 @strtol(i8* %35, i8** %9, i32 10)
store i64 %36, i64* %8
%37 = load i8*, i8** %9
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %52
39: ; preds = %34
%40 = load i8*, i8** %9
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 10
br i1 %43, label %52, label %44
44: ; preds = %39
%45 = load i8*, i8** %9
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = getelementptr inbounds i8, i8* %49, i64 -1
%51 = icmp ne i8* %45, %50
br i1 %51, label %52, label %58
52: ; preds = %44, %39, %34
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%54 = load i32, i32* @errno
%55 = load i32, i32* @errno
%56 = call i32 @strerror(i32 %55)
%57 = call i32 (i8*, i8*, i32, i8*, i32, ...) @test_msg(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0), i32 52, i8* %53, i32 %54, i32 %56)
store i32 -1, i32* %3
br label %61
58: ; preds = %44
%59 = load i64, i64* %8
%60 = trunc i64 %59 to i32
store i32 %60, i32* %3
br label %61
61: ; preds = %58, %52, %28, %17
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [5 x i8] c"GET\0A\00"
@.str.1 = [65 x i8] c"ERR: %s:%d: error in parent reading from pipe (errno = %d (%s))\0A\00"
@.str.2 = [167 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/dumpable02.c\00"
@errno = global i32 0
@.str.3 = [10 x i8] c"DUMPABLE:\00"
@.str.4 = [51 x i8] c"ERR: %s:%d: child returned [%s] (errno = %d (%s))\0A\00"
define i32 @get_dumpable_from_pipes(i32 %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = alloca i8*
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%7 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%8 = call i32 @read(i32 %1, i8* %5, i32 256)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @errno
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i8*
%14 = tail call i32 @strerror(i32 %11)
%15 = tail call i32 (i8*, i8*, i32, i8*, i32, ...) @test_msg(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0), i32 41, i8* %13, i32 %14)
br label %42
16: ; preds = %2
%17 = call i64 @memcmp(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 9)
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = load i32, i32* @errno
%21 = call i32 @strerror(i32 %20)
%22 = call i32 (i8*, i8*, i32, i8*, i32, ...) @test_msg(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0), i32 46, i8* %5, i32 %20, i32 %21)
br label %42
23: ; preds = %16
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 9
%25 = call i64 @strtol(i8* %24, i8** %4, i32 10)
%26 = load i8*, i8** %4
%27 = icmp eq i8* %26, null
br i1 %27, label %36, label %28
28: ; preds = %23
%29 = load i8, i8* %26
%30 = icmp eq i8 %29, 10
%31 = zext i32 %8 to i64
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %31
%33 = getelementptr inbounds i8, i8* %32, i64 -1
%34 = icmp eq i8* %26, %33
%35 = select i1 %30, i1 %34, i1 false
br i1 %35, label %40, label %36
36: ; preds = %28, %23
%37 = load i32, i32* @errno
%38 = call i32 @strerror(i32 %37)
%39 = call i32 (i8*, i8*, i32, i8*, i32, ...) @test_msg(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0), i32 52, i8* %5, i32 %37, i32 %38)
br label %42
40: ; preds = %28
%41 = trunc i64 %25 to i32
br label %42
42: ; preds = %40, %36, %19, %10
%43 = phi i32 [ -1, %10 ], [ -1, %19 ], [ -1, %36 ], [ %41, %40 ]
ret i32 %43
}