#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*/ AF_UNIX;
int /*<<< orphan*/ PF_UNIX;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ socketpair(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int *);
int main(int argc, char **argv) {
  int fds[2];
  {
    int i;
    for (i = 3; i < 64; i++)
      close(i);
  };
  socketpair(AF_UNIX, SOCK_STREAM, PF_UNIX, fds);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x1c(%rbp)
cmpl   $0x40,-0x1c(%rbp)
jge    115d <main+0x3d>
mov    -0x1c(%rbp),%edi
call   1030 <close@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113d <main+0x1d>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
mov    0x2e82(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rcx
call   1040 <socketpair@plt>
xor    %eax,%eax
add    $0x20,%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    1130 <main+0x10>
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
mov    0x2ea0(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
call   1040 <socketpair@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@PF_UNIX = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i32]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3, i32* %7
br label %8
8: ; preds = %14, %2
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 64
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = load i32, i32* %7
%13 = call i32 @close(i32 %12)
br label %14
14: ; preds = %11
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 1
store i32 %16, i32* %7
br label %8
17: ; preds = %8
%18 = load i32, i32* @AF_UNIX
%19 = load i32, i32* @SOCK_STREAM
%20 = load i32, i32* @PF_UNIX
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%22 = call i32 @socketpair(i32 %18, i32 %19, i32 %20, i32* %21)
ret i32 0
}

LLVM IR (-O2):
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@PF_UNIX = global i32 0
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 = load i32, i32* @AF_UNIX
%12 = load i32, i32* @SOCK_STREAM
%13 = load i32, i32* @PF_UNIX
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%15 = call i32 @socketpair(i32 %11, i32 %12, i32 %13, i32* %14)
ret i32 0
}