#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 */
typedef int uint32_t;

/* Variables and functions */
int EPOLLIN;
int /*<<< orphan*/ clear_client(int, int);
int handle_login(char *, size_t, int);
int handle_userlist(char *, size_t, int);
size_t receive_msg(char **, int);
void client_service(int cli_fd, uint32_t events, int epoll_fd) {
  char *msg = 0;
  size_t len = 0;
  int if_clear_client = 1;
  if (events & EPOLLIN) {
    len = receive_msg(&msg, cli_fd);
    if (len > 0) {
      if (msg[0] == '2') {
        if_clear_client = handle_login(msg, len, cli_fd);
      } else if (msg[0] == '6') {
        if_clear_client = handle_userlist(msg, len, cli_fd);
      }
    }
  }
  if (if_clear_client) {
    clear_client(cli_fd, epoll_fd);
  }
}


x86 assembly (clang, -O0):
<client_service>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e76(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11f2 <client_service+0xb2>
mov    -0x4(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   1040 <receive_msg@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jbe    11ed <client_service+0xad>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x32,%eax
jne    11c0 <client_service+0x80>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1050 <handle_login@plt>
mov    %eax,-0x24(%rbp)
jmp    11e8 <client_service+0xa8>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x36,%eax
jne    11e3 <client_service+0xa3>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1060 <handle_userlist@plt>
mov    %eax,-0x24(%rbp)
jmp    11e8 <client_service+0xa8>
jmp    11ed <client_service+0xad>
jmp    11f2 <client_service+0xb2>
cmpl   $0x0,-0x24(%rbp)
je     1207 <client_service+0xc7>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <clear_client@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<client_service>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %edi,%ebp
movq   $0x0,(%rsp)
mov    0x2e92(%rip),%rax
test   %esi,(%rax)
je     1197 <client_service+0x57>
mov    %rsp,%rdi
mov    %ebp,%esi
call   1040 <receive_msg@plt>
test   %rax,%rax
je     1197 <client_service+0x57>
mov    (%rsp),%rdi
mov    (%rdi),%cl
cmp    $0x36,%cl
je     1189 <client_service+0x49>
cmp    $0x32,%cl
jne    1197 <client_service+0x57>
mov    %rax,%rsi
mov    %ebp,%edx
call   1050 <handle_login@plt>
test   %eax,%eax
jne    1197 <client_service+0x57>
jmp    11a0 <client_service+0x60>
mov    %rax,%rsi
mov    %ebp,%edx
call   1060 <handle_userlist@plt>
test   %eax,%eax
je     11a0 <client_service+0x60>
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <clear_client@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@EPOLLIN = global i32 0
define void @client_service(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i8* null, i8** %7
store i64 0, i64* %8
store i32 1, i32* %9
%10 = load i32, i32* %5
%11 = load i32, i32* @EPOLLIN
%12 = and i32 %10, %11
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %44
14: ; preds = %3
%15 = load i32, i32* %4
%16 = call i64 @receive_msg(i8** %7, i32 %15)
store i64 %16, i64* %8
%17 = load i64, i64* %8
%18 = icmp ugt i64 %17, 0
br i1 %18, label %19, label %43
19: ; preds = %14
%20 = load i8*, i8** %7
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 50
br i1 %24, label %25, label %30
25: ; preds = %19
%26 = load i8*, i8** %7
%27 = load i64, i64* %8
%28 = load i32, i32* %4
%29 = call i32 @handle_login(i8* %26, i64 %27, i32 %28)
store i32 %29, i32* %9
br label %42
30: ; preds = %19
%31 = load i8*, i8** %7
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 54
br i1 %35, label %36, label %41
36: ; preds = %30
%37 = load i8*, i8** %7
%38 = load i64, i64* %8
%39 = load i32, i32* %4
%40 = call i32 @handle_userlist(i8* %37, i64 %38, i32 %39)
store i32 %40, i32* %9
br label %41
41: ; preds = %36, %30
br label %42
42: ; preds = %41, %25
br label %43
43: ; preds = %42, %14
br label %44
44: ; preds = %43, %3
%45 = load i32, i32* %9
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = load i32, i32* %4
%49 = load i32, i32* %6
%50 = call i32 @clear_client(i32 %48, i32 %49)
br label %51
51: ; preds = %47, %44
ret void
}

LLVM IR (-O2):
@EPOLLIN = global i32 0
define void @client_service(i32 %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%6 = load i32, i32* @EPOLLIN
%7 = and i32 %6, %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %22, label %9
9: ; preds = %3
%10 = call i64 @receive_msg(i8** %4, i32 %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %9
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
switch i8 %14, label %22 [
i8 50, label %15
i8 54, label %17
]
15: ; preds = %12
%16 = call i32 @handle_login(i8* %13, i64 %10, i32 %0)
br label %19
17: ; preds = %12
%18 = call i32 @handle_userlist(i8* %13, i64 %10, i32 %0)
br label %19
19: ; preds = %17, %15
%20 = phi i32 [ %16, %15 ], [ %18, %17 ]
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %12, %3, %9, %19
%23 = call i32 @clear_client(i32 %0, i32 %2)
br label %24
24: ; preds = %22, %19
ret void
}