#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*/ perror(char *);
int send(int, char *, int, int /*<<< orphan*/);
scalar_t__ strcasecmp(char const *, char const *);
int handleCommands(const char *command, int sockfd, int id) {
  if ((strcasecmp(command, (const char *)"/ping") == 0) && (id == 1)) {
    if (send(sockfd, "/ping", 6, 0) == -1) {
      return -1;
    }
  }
  if ((strcasecmp(command, (const char *)"/ping") == 0) && (id == 0)) {
    if (send(sockfd, "pong!", 6, 0) == -1) {
      perror("send");
      return -1;
    }
  }
  if (strcasecmp(command, (const char *)"/quit") == 0) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<handleCommands>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1196 <handleCommands+0x66>
cmpl   $0x1,-0x18(%rbp)
jne    1196 <handleCommands+0x66>
mov    -0x14(%rbp),%edi
lea    0xe90(%rip),%rsi
mov    $0x6,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    $0xffffffff,%eax
jne    1191 <handleCommands+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    1223 <handleCommands+0xf3>
jmp    1196 <handleCommands+0x66>
mov    -0x10(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11f6 <handleCommands+0xc6>
cmpl   $0x0,-0x18(%rbp)
jne    11f6 <handleCommands+0xc6>
mov    -0x14(%rbp),%edi
lea    0xe42(%rip),%rsi
mov    $0x6,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    $0xffffffff,%eax
jne    11f1 <handleCommands+0xc1>
lea    0xe2c(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1223 <handleCommands+0xf3>
jmp    11f6 <handleCommands+0xc6>
mov    -0x10(%rbp),%rdi
lea    0xe10(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    121c <handleCommands+0xec>
movl   $0x1,-0x4(%rbp)
jmp    1223 <handleCommands+0xf3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handleCommands>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xebd(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x1,%ebp
jne    116d <handleCommands+0x3d>
test   %rax,%rax
jne    116d <handleCommands+0x3d>
lea    0xea7(%rip),%rsi
mov    %r14d,%edi
mov    $0x6,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    $0xffffffff,%eax
je     11bf <handleCommands+0x8f>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %ebp,%ebp
jne    11a0 <handleCommands+0x70>
test   %rax,%rax
jne    11a0 <handleCommands+0x70>
lea    0xe7a(%rip),%rsi
mov    %r14d,%edi
mov    $0x6,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    $0xffffffff,%eax
je     11c6 <handleCommands+0x96>
lea    0xe6a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0xffffffff,%eax
jmp    11ba <handleCommands+0x8a>
lea    0xe3f(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%eax
jmp    11ba <handleCommands+0x8a>

LLVM IR (-O0):
@.str = [6 x i8] c"/ping\00"
@.str.1 = [6 x i8] c"pong!\00"
@.str.2 = [5 x i8] c"send\00"
@.str.3 = [6 x i8] c"/quit\00"
define i32 @handleCommands(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i8*, i8** %5
%9 = call i64 @strcasecmp(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %3
%12 = load i32, i32* %7
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i32, i32* %6
%16 = call i32 @send(i32 %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 6, i32 0)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 -1, i32* %4
br label %40
19: ; preds = %14
br label %20
20: ; preds = %19, %11, %3
%21 = load i8*, i8** %5
%22 = call i64 @strcasecmp(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = load i32, i32* %7
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = load i32, i32* %6
%29 = call i32 @send(i32 %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 0)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %4
br label %40
33: ; preds = %27
br label %34
34: ; preds = %33, %24, %20
%35 = load i8*, i8** %5
%36 = call i64 @strcasecmp(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
store i32 1, i32* %4
br label %40
39: ; preds = %34
store i32 0, i32* %4
br label %40
40: ; preds = %39, %38, %31, %18
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
@.str = [6 x i8] c"/ping\00"
@.str.1 = [6 x i8] c"pong!\00"
@.str.2 = [5 x i8] c"send\00"
@.str.3 = [6 x i8] c"/quit\00"
define i32 @handleCommands(i8* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
%6 = icmp eq i32 %2, 1
%7 = and i1 %6, %5
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = tail call i32 @send(i32 %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 6, i32 0)
%10 = icmp eq i32 %9, -1
br i1 %10, label %25, label %11
11: ; preds = %8, %3
%12 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = icmp eq i32 %2, 0
%15 = and i1 %14, %13
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = tail call i32 @send(i32 %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 0)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %25
21: ; preds = %16, %11
%22 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %21, %8, %19
%26 = phi i32 [ -1, %19 ], [ -1, %8 ], [ %24, %21 ]
ret i32 %26
}