#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 */
scalar_t__ close(int);
int /*<<< orphan*/ err(int, char *);
void close_pipes(int pipes[2][2]) {
  for (unsigned int i = 0; i < 2; i++) {
    for (unsigned int j = 0; j < 2; j++) {
      if (close(pipes[i][j]) < 0)
        err(1, "close pipe");
    }
  }
}


x86 assembly (clang, -O0):
<close_pipes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jae    11a8 <close_pipes+0x88>
movl   $0x0,-0x10(%rbp)
cmpl   $0x2,-0x10(%rbp)
jae    1195 <close_pipes+0x75>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%ecx
mov    (%rax,%rcx,4),%edi
call   1030 <close@plt>
cmp    $0x0,%rax
jge    1182 <close_pipes+0x62>
mov    $0x1,%edi
lea    0xe83(%rip),%rsi
call   1040 <err@plt>
jmp    1187 <close_pipes+0x67>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1144 <close_pipes+0x24>
jmp    119a <close_pipes+0x7a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <close_pipes+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<close_pipes>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%edi
call   1030 <close@plt>
test   %rax,%rax
jns    1141 <close_pipes+0x21>
lea    0xec9(%rip),%rsi
mov    $0x1,%edi
call   1040 <err@plt>
mov    0x4(%rbx),%edi
call   1030 <close@plt>
test   %rax,%rax
jns    115f <close_pipes+0x3f>
lea    0xeab(%rip),%rsi
mov    $0x1,%edi
call   1040 <err@plt>
mov    0x8(%rbx),%edi
call   1030 <close@plt>
test   %rax,%rax
jns    117d <close_pipes+0x5d>
lea    0xe8d(%rip),%rsi
mov    $0x1,%edi
call   1040 <err@plt>
mov    0xc(%rbx),%edi
call   1030 <close@plt>
test   %rax,%rax
js     118c <close_pipes+0x6c>
pop    %rbx
ret
lea    0xe6d(%rip),%rsi
mov    $0x1,%edi
pop    %rbx
jmp    1040 <err@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"close pipe\00"
define void @close_pipes([2 x i32]* %0) {
%2 = alloca [2 x i32]*
%3 = alloca i32
%4 = alloca i32
store [2 x i32]* %0, [2 x i32]** %2
store i32 0, i32* %3
br label %5
5: ; preds = %30, %1
%6 = load i32, i32* %3
%7 = icmp ult i32 %6, 2
br i1 %7, label %8, label %33
8: ; preds = %5
store i32 0, i32* %4
br label %9
9: ; preds = %26, %8
%10 = load i32, i32* %4
%11 = icmp ult i32 %10, 2
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = load [2 x i32]*, [2 x i32]** %2
%14 = load i32, i32* %3
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 %15
%17 = load i32, i32* %4
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = call i64 @close(i32 %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %12
%24 = call i32 @err(i32 1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23, %12
br label %26
26: ; preds = %25
%27 = load i32, i32* %4
%28 = add i32 %27, 1
store i32 %28, i32* %4
br label %9
29: ; preds = %9
br label %30
30: ; preds = %29
%31 = load i32, i32* %3
%32 = add i32 %31, 1
store i32 %32, i32* %3
br label %5
33: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"close pipe\00"
define void @close_pipes([2 x i32]* nocapture %0) {
%2 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 0, i64 0
%3 = load i32, i32* %2
%4 = tail call i64 @close(i32 %3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %1, %6
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 0, i64 1
%10 = load i32, i32* %9
%11 = tail call i64 @close(i32 %10)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %8
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 1, i64 0
%17 = load i32, i32* %16
%18 = tail call i64 @close(i32 %17)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %15
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 1, i64 1
%24 = load i32, i32* %23
%25 = tail call i64 @close(i32 %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
ret void
}