#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 ipcCloseAllFD(int prfd, int pwfd, int crfd, int cwfd) {
  if (prfd >= 0)
    close(prfd);
  if (prfd != pwfd)
    if (pwfd >= 0)
      close(pwfd);
  if (crfd >= 0)
    close(crfd);
  if (crfd != cwfd)
    if (cwfd >= 0)
      close(cwfd);
  return -1;
}


x86 assembly (clang, -O0):
<ipcCloseAllFD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1136 <ipcCloseAllFD+0x26>
mov    -0x4(%rbp),%edi
call   1030 <close@plt>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     1159 <ipcCloseAllFD+0x49>
cmpl   $0x0,-0x8(%rbp)
jl     1154 <ipcCloseAllFD+0x44>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
jmp    1159 <ipcCloseAllFD+0x49>
cmpl   $0x0,-0xc(%rbp)
jl     116b <ipcCloseAllFD+0x5b>
mov    -0xc(%rbp),%edi
call   1030 <close@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     118e <ipcCloseAllFD+0x7e>
cmpl   $0x0,-0x10(%rbp)
jl     1189 <ipcCloseAllFD+0x79>
mov    -0x10(%rbp),%edi
call   1030 <close@plt>
jmp    118e <ipcCloseAllFD+0x7e>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipcCloseAllFD>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%ebp
test   %edi,%edi
js     112c <ipcCloseAllFD+0x1c>
mov    %ebp,%edi
call   1030 <close@plt>
cmp    %ebx,%ebp
je     113b <ipcCloseAllFD+0x2b>
test   %ebx,%ebx
js     113b <ipcCloseAllFD+0x2b>
mov    %ebx,%edi
call   1030 <close@plt>
test   %r15d,%r15d
js     1148 <ipcCloseAllFD+0x38>
mov    %r15d,%edi
call   1030 <close@plt>
cmp    %r14d,%r15d
je     115a <ipcCloseAllFD+0x4a>
test   %r14d,%r14d
js     115a <ipcCloseAllFD+0x4a>
mov    %r14d,%edi
call   1030 <close@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ipcCloseAllFD(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = load i32, i32* %5
%13 = call i32 @close(i32 %12)
br label %14
14: ; preds = %11, %4
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i32, i32* %6
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* %6
%23 = call i32 @close(i32 %22)
br label %24
24: ; preds = %21, %18
br label %25
25: ; preds = %24, %14
%26 = load i32, i32* %7
%27 = icmp sge i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %7
%30 = call i32 @close(i32 %29)
br label %31
31: ; preds = %28, %25
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = icmp ne i32 %32, %33
br i1 %34, label %35, label %42
35: ; preds = %31
%36 = load i32, i32* %8
%37 = icmp sge i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i32, i32* %8
%40 = call i32 @close(i32 %39)
br label %41
41: ; preds = %38, %35
br label %42
42: ; preds = %41, %31
ret i32 -1
}

LLVM IR (-O2):
define i32 @ipcCloseAllFD(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %0, -1
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @close(i32 %0)
br label %8
8: ; preds = %6, %4
%9 = icmp ne i32 %0, %1
%10 = icmp sgt i32 %1, -1
%11 = and i1 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 @close(i32 %1)
br label %14
14: ; preds = %12, %8
%15 = icmp sgt i32 %2, -1
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = tail call i32 @close(i32 %2)
br label %18
18: ; preds = %16, %14
%19 = icmp ne i32 %2, %3
%20 = icmp sgt i32 %3, -1
%21 = and i1 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = tail call i32 @close(i32 %3)
br label %24
24: ; preds = %22, %18
ret i32 -1
}