#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 char uint8_t;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ F_SETFL;
int /*<<< orphan*/ O_NONBLOCK;
int __chk_error(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fcntl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, char *, int);
void test_pipe(void) {
  fd_set rfds, wfds;
  int fds[2], fd_max, ret;
  uint8_t ch;
  int wcount, rcount;
  __chk_error("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/"
              "OXT-112/Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c",
              360, (pipe(fds)));
  __chk_error("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/"
              "OXT-112/Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c",
              361, (fcntl(fds[0], F_SETFL, O_NONBLOCK)));
  __chk_error("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/"
              "OXT-112/Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c",
              362, (fcntl(fds[1], F_SETFL, O_NONBLOCK)));
  wcount = 0;
  rcount = 0;
  for (;;) {
    FD_ZERO(&rfds);
    fd_max = fds[0];
    FD_SET(fds[0], &rfds);
    FD_ZERO(&wfds);
    FD_SET(fds[1], &wfds);
    if (fds[1] > fd_max)
      fd_max = fds[1];
    ret = __chk_error(
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/OXT-112/"
        "Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c",
        375, (select(fd_max + 1, &rfds, &wfds, NULL, NULL)));
    if (ret > 0) {
      if (FD_ISSET(fds[0], &rfds)) {
        __chk_error(
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/OXT-112/"
            "Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c",
            378, (read(fds[0], &ch, 1)));
        rcount++;
        if (rcount >= 512)
          break;
      }
      if (FD_ISSET(fds[1], &wfds)) {
        ch = 'a';
        __chk_error(
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/OXT-112/"
            "Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c",
            385, (write(fds[0], &ch, 1)));
        wcount++;
      }
    }
  }
  __chk_error("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/"
              "OXT-112/Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c",
              390, (close(fds[0])));
  __chk_error("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/"
              "OXT-112/Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c",
              391, (close(fds[1])));
}


x86 assembly (clang, -O0):
<test_pipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x10(%rbp),%rdi
call   1080 <pipe@plt>
mov    %eax,%edx
lea    0xe46(%rip),%rdi
mov    $0x168,%esi
call   1060 <__chk_error@plt>
mov    -0x10(%rbp),%edi
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
mov    0x2e11(%rip),%rax
mov    (%rax),%edx
call   1030 <fcntl@plt>
mov    %eax,%edx
lea    0xe19(%rip),%rdi
mov    $0x169,%esi
call   1060 <__chk_error@plt>
mov    -0xc(%rbp),%edi
mov    0x2ddd(%rip),%rax
mov    (%rax),%esi
mov    0x2de4(%rip),%rax
mov    (%rax),%edx
call   1030 <fcntl@plt>
mov    %eax,%edx
lea    0xdec(%rip),%rdi
mov    $0x16a,%esi
call   1060 <__chk_error@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x4(%rbp),%rdi
call   10a0 <FD_ZERO@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
lea    -0x4(%rbp),%rsi
call   10c0 <FD_SET@plt>
lea    -0x8(%rbp),%rdi
call   10a0 <FD_ZERO@plt>
mov    -0xc(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   10c0 <FD_SET@plt>
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    126e <test_pipe+0xce>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   10b0 <select@plt>
mov    %eax,%edx
lea    0xd6e(%rip),%rdi
mov    $0x177,%esi
call   1060 <__chk_error@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    134f <test_pipe+0x1af>
mov    -0x10(%rbp),%edi
lea    -0x4(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1303 <test_pipe+0x163>
mov    -0x10(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
mov    %eax,%edx
lea    0xd27(%rip),%rdi
mov    $0x17a,%esi
call   1060 <__chk_error@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x200,-0x24(%rbp)
jl     12fe <test_pipe+0x15e>
jmp    1354 <test_pipe+0x1b4>
jmp    1303 <test_pipe+0x163>
mov    -0xc(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     134a <test_pipe+0x1aa>
movb   $0x61,-0x19(%rbp)
mov    -0x10(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %eax,%edx
lea    0xcc9(%rip),%rdi
mov    $0x181,%esi
call   1060 <__chk_error@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    134f <test_pipe+0x1af>
jmp    122c <test_pipe+0x8c>
mov    -0x10(%rbp),%edi
call   1070 <close@plt>
mov    %eax,%edx
lea    0xc9b(%rip),%rdi
mov    $0x186,%esi
call   1060 <__chk_error@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    %eax,%edx
lea    0xc80(%rip),%rdi
mov    $0x187,%esi
call   1060 <__chk_error@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_pipe>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
call   1080 <pipe@plt>
lea    0xe41(%rip),%r14
mov    %r14,%rdi
mov    $0x168,%esi
mov    %eax,%edx
call   1060 <__chk_error@plt>
mov    0x8(%rsp),%edi
mov    0x2dff(%rip),%rbx
mov    (%rbx),%esi
mov    0x2e06(%rip),%rbp
mov    0x0(%rbp),%edx
call   1030 <fcntl@plt>
mov    %r14,%rdi
mov    $0x169,%esi
mov    %eax,%edx
call   1060 <__chk_error@plt>
mov    0xc(%rsp),%edi
mov    (%rbx),%esi
mov    0x0(%rbp),%edx
call   1030 <fcntl@plt>
mov    %r14,%rdi
mov    $0x16a,%esi
mov    %eax,%edx
call   1060 <__chk_error@plt>
xor    %r13d,%r13d
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%rbx
lea    0x7(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   10a0 <FD_ZERO@plt>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
mov    %r15,%rsi
call   10c0 <FD_SET@plt>
mov    %rbx,%rdi
call   10a0 <FD_ZERO@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   10c0 <FD_SET@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
cmovg  %eax,%ebp
add    $0x1,%ebp
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10b0 <select@plt>
mov    %r14,%rdi
mov    $0x177,%esi
mov    %eax,%edx
call   1060 <__chk_error@plt>
test   %eax,%eax
jle    1230 <test_pipe+0x90>
mov    0x8(%rsp),%edi
mov    %r15,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     12c9 <test_pipe+0x129>
mov    0x8(%rsp),%edi
mov    %r12,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
mov    %r14,%rdi
mov    $0x17a,%esi
mov    %eax,%edx
call   1060 <__chk_error@plt>
cmp    $0x1fe,%r13d
jg     1308 <test_pipe+0x168>
add    $0x1,%r13d
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1230 <test_pipe+0x90>
movb   $0x61,0x7(%rsp)
mov    0x8(%rsp),%edi
mov    %r12,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %r14,%rdi
mov    $0x181,%esi
mov    %eax,%edx
call   1060 <__chk_error@plt>
jmp    1230 <test_pipe+0x90>
mov    0x8(%rsp),%edi
call   1070 <close@plt>
lea    0xce8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x186,%esi
mov    %eax,%edx
call   1060 <__chk_error@plt>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
mov    %rbx,%rdi
mov    $0x187,%esi
mov    %eax,%edx
call   1060 <__chk_error@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [183 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/OXT-112/Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
define void @test_pipe() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%10 = call i32 @pipe(i32* %9)
%11 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 360, i32 %10)
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%13 = load i32, i32* %12
%14 = load i32, i32* @F_SETFL
%15 = load i32, i32* @O_NONBLOCK
%16 = call i32 @fcntl(i32 %13, i32 %14, i32 %15)
%17 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 361, i32 %16)
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%19 = load i32, i32* %18
%20 = load i32, i32* @F_SETFL
%21 = load i32, i32* @O_NONBLOCK
%22 = call i32 @fcntl(i32 %19, i32 %20, i32 %21)
%23 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 362, i32 %22)
store i32 0, i32* %7
store i32 0, i32* %8
br label %24
24: ; preds = %78, %0
%25 = call i32 @FD_ZERO(i32* %1)
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%27 = load i32, i32* %26
store i32 %27, i32* %4
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%29 = load i32, i32* %28
%30 = call i32 @FD_SET(i32 %29, i32* %1)
%31 = call i32 @FD_ZERO(i32* %2)
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%33 = load i32, i32* %32
%34 = call i32 @FD_SET(i32 %33, i32* %2)
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%36 = load i32, i32* %35
%37 = load i32, i32* %4
%38 = icmp sgt i32 %36, %37
br i1 %38, label %39, label %42
39: ; preds = %24
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%41 = load i32, i32* %40
store i32 %41, i32* %4
br label %42
42: ; preds = %39, %24
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
%45 = call i32 @select(i32 %44, i32* %1, i32* %2, i32* null, i32* null)
%46 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 375, i32 %45)
store i32 %46, i32* %5
%47 = load i32, i32* %5
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %78
49: ; preds = %42
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%51 = load i32, i32* %50
%52 = call i64 @FD_ISSET(i32 %51, i32* %1)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %65
54: ; preds = %49
%55 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%56 = load i32, i32* %55
%57 = call i32 @read(i32 %56, i8* %6, i32 1)
%58 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 378, i32 %57)
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
store i32 %60, i32* %8
%61 = load i32, i32* %8
%62 = icmp sge i32 %61, 512
br i1 %62, label %63, label %64
63: ; preds = %54
br label %79
64: ; preds = %54
br label %65
65: ; preds = %64, %49
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%67 = load i32, i32* %66
%68 = call i64 @FD_ISSET(i32 %67, i32* %2)
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %77
70: ; preds = %65
store i8 97, i8* %6
%71 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%72 = load i32, i32* %71
%73 = call i32 @write(i32 %72, i8* %6, i32 1)
%74 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 385, i32 %73)
%75 = load i32, i32* %7
%76 = add nsw i32 %75, 1
store i32 %76, i32* %7
br label %77
77: ; preds = %70, %65
br label %78
78: ; preds = %77, %42
br label %24
79: ; preds = %63
%80 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%81 = load i32, i32* %80
%82 = call i32 @close(i32 %81)
%83 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 390, i32 %82)
%84 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%85 = load i32, i32* %84
%86 = call i32 @close(i32 %85)
%87 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 391, i32 %86)
ret void
}

LLVM IR (-O2):
@.str = [183 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/OXT-112/Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
define void @test_pipe() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [2 x i32]
%4 = alloca i8
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast [2 x i32]* %3 to i8*
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%9 = call i32 @pipe(i32* %8)
%10 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 360, i32 %9)
%11 = load i32, i32* %8
%12 = load i32, i32* @F_SETFL
%13 = load i32, i32* @O_NONBLOCK
%14 = call i32 @fcntl(i32 %11, i32 %12, i32 %13)
%15 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 361, i32 %14)
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%17 = load i32, i32* %16
%18 = load i32, i32* @F_SETFL
%19 = load i32, i32* @O_NONBLOCK
%20 = call i32 @fcntl(i32 %17, i32 %18, i32 %19)
%21 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 362, i32 %20)
br label %22
22: ; preds = %57, %0
%23 = phi i32 [ 0, %0 ], [ %49, %57 ]
br label %24
24: ; preds = %22, %24
%25 = call i32 @FD_ZERO(i32* %1)
%26 = load i32, i32* %8
%27 = call i32 @FD_SET(i32 %26, i32* %1)
%28 = call i32 @FD_ZERO(i32* %2)
%29 = load i32, i32* %16
%30 = call i32 @FD_SET(i32 %29, i32* %2)
%31 = load i32, i32* %16
%32 = icmp sgt i32 %31, %26
%33 = select i1 %32, i32 %31, i32 %26
%34 = add nsw i32 %33, 1
%35 = call i32 @select(i32 %34, i32* %1, i32* %2, i32* null, i32* null)
%36 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 375, i32 %35)
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %24
38: ; preds = %24
%39 = load i32, i32* %8
%40 = call i64 @FD_ISSET(i32 %39, i32* %1)
%41 = icmp eq i64 %40, 0
br i1 %41, label %48, label %42
42: ; preds = %38
%43 = load i32, i32* %8
%44 = call i32 @read(i32 %43, i8* %4, i32 1)
%45 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 378, i32 %44)
%46 = add nsw i32 %23, 1
%47 = icmp sgt i32 %23, 510
br i1 %47, label %58, label %48
48: ; preds = %42, %38
%49 = phi i32 [ %46, %42 ], [ %23, %38 ]
%50 = load i32, i32* %16
%51 = call i64 @FD_ISSET(i32 %50, i32* %2)
%52 = icmp eq i64 %51, 0
br i1 %52, label %57, label %53
53: ; preds = %48
store i8 97, i8* %4
%54 = load i32, i32* %8
%55 = call i32 @write(i32 %54, i8* %4, i32 1)
%56 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 385, i32 %55)
br label %57
57: ; preds = %53, %48
br label %22
58: ; preds = %42
%59 = load i32, i32* %8
%60 = call i32 @close(i32 %59)
%61 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 390, i32 %60)
%62 = load i32, i32* %16
%63 = call i32 @close(i32 %62)
%64 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 391, i32 %63)
ret void
}