#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*/ EPOLL_CTL_DEL;
int /*<<< orphan*/ close(int);
scalar_t__ epoll_ctl(int, int /*<<< orphan*/, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
void remove_client(int epoll_fd, int client_fd, int why) {
  if (why == 1) {
    printf("*** Removing client because connection appears to be dead\n");
  } else if (why == 0) {
    printf("*** Removing client after voluntary request\n");
  } else {
    printf("*** Removing client for unknown reasons\n");
  }
  if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, client_fd, NULL) < 0) {
    perror("epoll_ctl(2) failed when attempting to remove client\n");
    return;
  }
  close(client_fd);
}


x86 assembly (clang, -O0):
<remove_client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    116c <remove_client+0x2c>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
jmp    1198 <remove_client+0x58>
cmpl   $0x0,-0xc(%rbp)
jne    1187 <remove_client+0x47>
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
jmp    1193 <remove_client+0x53>
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
jmp    1198 <remove_client+0x58>
mov    -0x4(%rbp),%edi
mov    0x2e56(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <epoll_ctl@plt>
cmp    $0x0,%rax
jge    11cb <remove_client+0x8b>
lea    0xed0(%rip),%rdi
call   1060 <perror@plt>
jmp    11d3 <remove_client+0x93>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_client>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
test   %edx,%edx
lea    0xf0e(%rip),%rax
lea    0xedf(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x1,%edx
lea    0xf25(%rip),%rdi
cmovne %rcx,%rdi
call   1030 <puts@plt>
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %ebx,%edx
xor    %ecx,%ecx
call   1050 <epoll_ctl@plt>
test   %rax,%rax
js     1194 <remove_client+0x54>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <close@plt>
lea    0xe65(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <perror@plt>

LLVM IR (-O0):
@.str = [59 x i8] c"*** Removing client because connection appears to be dead\0A\00"
@.str.1 = [45 x i8] c"*** Removing client after voluntary request\0A\00"
@.str.2 = [41 x i8] c"*** Removing client for unknown reasons\0A\00"
@EPOLL_CTL_DEL = global i32 0
@.str.3 = [54 x i8] c"epoll_ctl(2) failed when attempting to remove client\0A\00"
define void @remove_client(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
br label %19
11: ; preds = %3
%12 = load i32, i32* %6
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %18
16: ; preds = %11
%17 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
br label %19
19: ; preds = %18, %9
%20 = load i32, i32* %4
%21 = load i32, i32* @EPOLL_CTL_DEL
%22 = load i32, i32* %5
%23 = call i64 @epoll_ctl(i32 %20, i32 %21, i32 %22, i32* null)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
br label %30
27: ; preds = %19
%28 = load i32, i32* %5
%29 = call i32 @close(i32 %28)
br label %30
30: ; preds = %27, %25
ret void
}

LLVM IR (-O2):
@EPOLL_CTL_DEL = global i32 0
@.str.3 = [54 x i8] c"epoll_ctl(2) failed when attempting to remove client\0A\00"
@str = [40 x i8] c"*** Removing client for unknown reasons\00"
@str.4 = [44 x i8] c"*** Removing client after voluntary request\00"
@str.5 = [58 x i8] c"*** Removing client because connection appears to be dead\00"
define void @remove_client(i32 %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
%5 = select i1 %4, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0)
%6 = icmp eq i32 %2, 1
%7 = select i1 %6, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @str.5, i64 0, i64 0), i8* %5
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
%9 = load i32, i32* @EPOLL_CTL_DEL
%10 = tail call i64 @epoll_ctl(i32 %0, i32 %9, i32 %1, i32* null)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = tail call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
br label %16
14: ; preds = %3
%15 = tail call i32 @close(i32 %1)
br label %16
16: ; preds = %14, %12
ret void
}