#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*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ socket_write(int, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strcasecmp(char *, void *);
int /*<<< orphan*/ strlen(char const *);
void client_read_cb(int fd, void *buffer, int length) {
  const char message[] = "ping";
  if ((length > 0) && (buffer != NULL)) {
    if (strcasecmp("pong", buffer) == 0) {
      fprintf(stderr, "client::%s\n", message);
      socket_write(fd, message, strlen(message));
      sleep(1);
    }
  }
}


x86 assembly (clang, -O0):
<client_read_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    0xe98(%rip),%eax
mov    %eax,-0x19(%rbp)
mov    0xe93(%rip),%al
mov    %al,-0x15(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11f0 <client_read_cb+0xa0>
cmpq   $0x0,-0x10(%rbp)
je     11f0 <client_read_cb+0xa0>
mov    -0x10(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11eb <client_read_cb+0x9b>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    -0x19(%rbp),%rdx
lea    0xe53(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x19(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x19(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1050 <socket_write@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
jmp    11f0 <client_read_cb+0xa0>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<client_read_cb>:
push   %r14
push   %rbx
push   %rax
movb   $0x0,0x4(%rsp)
movl   $0x676e6970,(%rsp)
test   %rsi,%rsi
je     11b5 <client_read_cb+0x65>
test   %edx,%edx
jle    11b5 <client_read_cb+0x65>
mov    %edi,%ebx
lea    0xe93(%rip),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    11b5 <client_read_cb+0x65>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <socket_write@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.client_read_cb.message = [5 x i8] c"ping\00"
@.str = [5 x i8] c"pong\00"
@stderr = global i32 0
@.str.1 = [12 x i8] c"client::%s\0A\00"
define void @client_read_cb(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [5 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = bitcast [5 x i8]* %7 to i8*
%9 = load i32, i32* %6
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %29
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %29
14: ; preds = %11
%15 = load i8*, i8** %5
%16 = call i64 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* %4
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = call i32 @socket_write(i32 %22, i8* %23, i32 %25)
%27 = call i32 @sleep(i32 1)
br label %28
28: ; preds = %18, %14
br label %29
29: ; preds = %28, %11, %3
ret void
}

LLVM IR (-O2):
@__const.client_read_cb.message = [5 x i8] c"ping\00"
@.str = [5 x i8] c"pong\00"
@stderr = global i32 0
@.str.1 = [12 x i8] c"client::%s\0A\00"
define void @client_read_cb(i32 %0, i8* %1, i32 %2) {
%4 = alloca [5 x i8]
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%6 = icmp sgt i32 %2, 0
%7 = icmp ne i8* %1, null
%8 = and i1 %7, %6
br i1 %8, label %9, label %18
9: ; preds = %3
%10 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%15 = call i32 @strlen(i8* %5)
%16 = call i32 @socket_write(i32 %0, i8* %5, i32 %15)
%17 = call i32 @sleep(i32 1)
br label %18
18: ; preds = %9, %12, %3
ret void
}