#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 find_client_fd(char *);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ rio_writen(int, char *, scalar_t__);
int /*<<< orphan*/ strcmp(char *, char *);
scalar_t__ strlen(char *);
bool want_to_chat(char *client, char *otherclient) {
  int otherclient_fd = find_client_fd(otherclient);
  char buf[8192];
  rio_writen(otherclient_fd, "askcnct", strlen("askcnct") + 1);
  rio_writen(otherclient_fd, client, strlen(client) + 1);
  read(otherclient_fd, buf, 8192);
  if (!strcmp(buf, "n") || !strcmp(buf, "N"))
    return false;
  else
    return true;
}


x86 assembly (clang, -O0):
<want_to_chat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <find_client_fd@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2030(%rbp)
lea    0xe81(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x2030(%rbp),%edi
mov    %rax,%rdx
add    $0x1,%rdx
lea    0xe68(%rip),%rsi
call   1070 <rio_writen@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x202c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x2028(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x202c(%rbp),%edi
mov    -0x2028(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1070 <rio_writen@plt>
mov    -0x1c(%rbp),%edi
lea    -0x2020(%rbp),%rsi
mov    $0x2000,%edx
call   1050 <read@plt>
lea    -0x2020(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     121f <want_to_chat+0xcf>
lea    -0x2020(%rbp),%rdi
lea    0xdf9(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    122b <want_to_chat+0xdb>
movl   $0x0,-0x4(%rbp)
jmp    1232 <want_to_chat+0xe2>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<want_to_chat>:
push   %rbp
push   %rbx
sub    $0x2008,%rsp
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <find_client_fd@plt>
mov    %eax,%ebp
lea    0xea3(%rip),%rsi
mov    $0x8,%edx
mov    %eax,%edi
call   1060 <rio_writen@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <rio_writen@plt>
mov    %rsp,%rsi
mov    %ebp,%edi
mov    $0x2000,%edx
call   1050 <read@plt>
movzwl (%rsp),%ecx
and    $0xffffffdf,%ecx
xor    %eax,%eax
cmp    $0x4e,%cx
setne  %al
add    $0x2008,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"askcnct\00"
@.str.1 = [2 x i8] c"n\00"
@.str.2 = [2 x i8] c"N\00"
define i32 @want_to_chat(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [8192 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = call i32 @find_client_fd(i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = call i64 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = add nsw i64 %11, 1
%13 = call i32 @rio_writen(i32 %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %12)
%14 = load i32, i32* %6
%15 = load i8*, i8** %4
%16 = load i8*, i8** %4
%17 = call i64 @strlen(i8* %16)
%18 = add nsw i64 %17, 1
%19 = call i32 @rio_writen(i32 %14, i8* %15, i64 %18)
%20 = load i32, i32* %6
%21 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%22 = call i32 @read(i32 %20, i8* %21, i32 8192)
%23 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %2
%27 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %26, %2
store i32 0, i32* %3
br label %32
31: ; preds = %26
store i32 1, i32* %3
br label %32
32: ; preds = %31, %30
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [8 x i8] c"askcnct\00"
define i32 @want_to_chat(i8* %0, i8* %1) {
%3 = alloca [8192 x i8]
%4 = tail call i32 @find_client_fd(i8* %1)
%5 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @rio_writen(i32 %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 8)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = add nsw i64 %7, 1
%9 = tail call i32 @rio_writen(i32 %4, i8* %0, i64 %8)
%10 = call i32 @read(i32 %4, i8* %5, i32 8192)
%11 = bitcast [8192 x i8]* %3 to i16*
%12 = load i16, i16* %11
%13 = and i16 %12, -33
%14 = icmp ne i16 %13, 78
%15 = zext i1 %14 to i32
ret i32 %15
}