#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 */

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(int /*<<< orphan*/);
int do_pipe_pipe_pipe() {
  int fd[2];
  int i;
  while (1) {
    if (pipe(fd)) {
      printf("pipe: %s\n", strerror(errno));
      return -1;
    }
    printf("%d %d\n", fd[0], fd[1]);
    close(fd[0]);
    close(fd[1]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<do_pipe_pipe_pipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0x0,%rax
je     1185 <do_pipe_pipe_pipe+0x45>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbp
ret
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
jmp    1148 <do_pipe_pipe_pipe+0x8>

x86 assembly (clang, -O2):
<do_pipe_pipe_pipe>:
push   %r14
push   %rbx
push   %rax
mov    %rsp,%rdi
call   1050 <pipe@plt>
test   %rax,%rax
jne    118f <do_pipe_pipe_pipe+0x4f>
lea    0xeb2(%rip),%r14
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%edi
call   1040 <close@plt>
mov    0x4(%rsp),%edi
call   1040 <close@plt>
mov    %rbx,%rdi
call   1050 <pipe@plt>
test   %rax,%rax
je     1160 <do_pipe_pipe_pipe+0x20>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe5c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"pipe: %s\0A\00"
@errno = global i32 0
@.str.1 = [7 x i8] c"%d %d\0A\00"
define i32 @do_pipe_pipe_pipe() {
%1 = alloca [2 x i32]
%2 = alloca i32
br label %3
3: ; preds = %0, %11
%4 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%5 = call i64 @pipe(i32* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = load i32, i32* @errno
%9 = call i8* @strerror(i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %9)
ret i32 -1
11: ; preds = %3
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %15)
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%18 = load i32, i32* %17
%19 = call i32 @close(i32 %18)
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%21 = load i32, i32* %20
%22 = call i32 @close(i32 %21)
br label %3
}

LLVM IR (-O2):
@.str = [10 x i8] c"pipe: %s\0A\00"
@errno = global i32 0
@.str.1 = [7 x i8] c"%d %d\0A\00"
define i32 @do_pipe_pipe_pipe() {
%1 = alloca [2 x i32]
%2 = bitcast [2 x i32]* %1 to i8*
%3 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%4 = call i64 @pipe(i32* %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
br label %12
8: ; preds = %12, %0
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %10)
ret i32 -1
12: ; preds = %6, %12
%13 = load i32, i32* %3
%14 = load i32, i32* %7
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %14)
%16 = load i32, i32* %3
%17 = call i32 @close(i32 %16)
%18 = load i32, i32* %7
%19 = call i32 @close(i32 %18)
%20 = call i64 @pipe(i32* %3)
%21 = icmp eq i64 %20, 0
br i1 %21, label %12, label %8
}