#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 */
struct shl_pty {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ EPOLL_CTL_DEL;
int /*<<< orphan*/ epoll_ctl(int, int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/ *);
int /*<<< orphan*/ shl_pty_get_fd(struct shl_pty *);
int /*<<< orphan*/ shl_pty_is_open(struct shl_pty *);
void shl_pty_bridge_remove(int bridge, struct shl_pty *pty) {
  if (bridge < 0 || !shl_pty_is_open(pty))
    return;
  epoll_ctl(bridge, EPOLL_CTL_DEL, shl_pty_get_fd(pty), NULL);
}


x86 assembly (clang, -O0):
<shl_pty_bridge_remove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     115b <shl_pty_bridge_remove+0x2b>
mov    -0x10(%rbp),%rdi
call   1040 <shl_pty_is_open@plt>
cmp    $0x0,%eax
jne    1160 <shl_pty_bridge_remove+0x30>
jmp    118c <shl_pty_bridge_remove+0x5c>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <shl_pty_get_fd@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    %eax,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <epoll_ctl@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shl_pty_bridge_remove>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
js     116b <shl_pty_bridge_remove+0x3b>
mov    %rsi,%r14
mov    %edi,%ebx
mov    %rsi,%rdi
call   1040 <shl_pty_is_open@plt>
test   %eax,%eax
je     116b <shl_pty_bridge_remove+0x3b>
mov    0x2ea8(%rip),%rax
mov    (%rax),%ebp
mov    %r14,%rdi
call   1050 <shl_pty_get_fd@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
xor    %ecx,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <epoll_ctl@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.shl_pty = type { i32 }
@EPOLL_CTL_DEL = global i32 0
define void @shl_pty_bridge_remove(i32 %0, %struct.shl_pty* %1) {
%3 = alloca i32
%4 = alloca %struct.shl_pty*
store i32 %0, i32* %3
store %struct.shl_pty* %1, %struct.shl_pty** %4
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = load %struct.shl_pty*, %struct.shl_pty** %4
%9 = call i32 @shl_pty_is_open(%struct.shl_pty* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %7, %2
br label %18
12: ; preds = %7
%13 = load i32, i32* %3
%14 = load i32, i32* @EPOLL_CTL_DEL
%15 = load %struct.shl_pty*, %struct.shl_pty** %4
%16 = call i32 @shl_pty_get_fd(%struct.shl_pty* %15)
%17 = call i32 @epoll_ctl(i32 %13, i32 %14, i32 %16, i32* null)
br label %18
18: ; preds = %12, %11
ret void
}

LLVM IR (-O2):
%struct.shl_pty = type { i32 }
@EPOLL_CTL_DEL = global i32 0
define void @shl_pty_bridge_remove(i32 %0, %struct.shl_pty* %1) {
%3 = icmp slt i32 %0, 0
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = tail call i32 @shl_pty_is_open(%struct.shl_pty* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = load i32, i32* @EPOLL_CTL_DEL
%9 = tail call i32 @shl_pty_get_fd(%struct.shl_pty* %1)
%10 = tail call i32 @epoll_ctl(i32 %0, i32 %8, i32 %9, i32* null)
br label %11
11: ; preds = %2, %4, %7
ret void
}