#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*/ exit(int);
int /*<<< orphan*/ perror(char *);
long pipe(int *);
int main(int argc, char **argv) {
  int fds[2];
  {
    int i;
    for (i = 3; i < 64; i++)
      close(i);
  };
  ({
    long res = pipe(fds);
    if (res < 0) {
      perror("pipe(fds)");
      exit(1);
    };
    res;
  });
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x1c(%rbp)
cmpl   $0x40,-0x1c(%rbp)
jge    117d <main+0x3d>
mov    -0x1c(%rbp),%edi
call   1030 <close@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115d <main+0x1d>
lea    -0x18(%rbp),%rdi
call   1040 <pipe@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    11ab <main+0x6b>
lea    0xe64(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x3,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1030 <close@plt>
add    $0x1,%ebx
cmp    $0x40,%ebx
jne    1150 <main+0x10>
lea    0x8(%rsp),%rdi
call   1040 <pipe@plt>
test   %rax,%rax
js     1176 <main+0x36>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe83(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"pipe(fds)\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 i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3, i32* %7
br label %10
10: ; preds = %16, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 64
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i32, i32* %7
%15 = call i32 @close(i32 %14)
br label %16
16: ; preds = %13
%17 = load i32, i32* %7
%18 = add nsw i32 %17, 1
store i32 %18, i32* %7
br label %10
19: ; preds = %10
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%21 = call i64 @pipe(i32* %20)
store i64 %21, i64* %8
%22 = load i64, i64* %8
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %19
%28 = load i64, i64* %8
store i64 %28, i64* %9
%29 = load i64, i64* %9
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"pipe(fds)\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2 x i32]
%4 = bitcast [2 x i32]* %3 to i8*
br label %5
5: ; preds = %2, %5
%6 = phi i32 [ 3, %2 ], [ %8, %5 ]
%7 = tail call i32 @close(i32 %6)
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, 64
br i1 %9, label %10, label %5
10: ; preds = %5
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%12 = call i64 @pipe(i32* %11)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %10
ret i32 0
}