#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 size_t ssize_t;
typedef int /*<<< orphan*/ evutil_socket_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ create_connectfd();
int /*<<< orphan*/ evutil_closesocket(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
size_t recv(int /*<<< orphan*/, char *, size_t, int /*<<< orphan*/);
size_t send(int /*<<< orphan*/, char *, size_t, int /*<<< orphan*/);
size_t strlen(char *);
void client(void) {
  char buf[1024];
  ssize_t n;
  evutil_socket_t connectfd = create_connectfd();
  n = send(connectfd, "HelloWorld", strlen("HelloWorld"), 0);
  assert(n == strlen("HelloWorld"));
  printf("[client] send: %s\n", "HelloWorld");
  n = recv(connectfd, buf, strlen("HelloWorld"), 0);
  assert(n == strlen("HelloWorld"));
  buf[n] = '\0';
  printf("[client] recv: %s\n", buf);
  evutil_closesocket(connectfd);
}


x86 assembly (clang, -O0):
<client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    $0x0,%al
call   1090 <create_connectfd@plt>
mov    %eax,-0x40c(%rbp)
mov    -0x40c(%rbp),%eax
mov    %eax,-0x434(%rbp)
lea    0xe65(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x434(%rbp),%edi
mov    %rax,%rdx
lea    0xe50(%rip),%rsi
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %rax,-0x408(%rbp)
mov    -0x408(%rbp),%rax
mov    %rax,-0x430(%rbp)
lea    0xe2d(%rip),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x430(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xe12(%rip),%rdi
lea    0xe00(%rip),%rsi
call   1060 <printf@plt>
mov    -0x40c(%rbp),%eax
mov    %eax,-0x424(%rbp)
lea    -0x400(%rbp),%rax
mov    %rax,-0x420(%rbp)
lea    0xdda(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x424(%rbp),%edi
mov    -0x420(%rbp),%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %rax,-0x408(%rbp)
mov    -0x408(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    0xda2(%rip),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x418(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x408(%rbp),%rax
movb   $0x0,-0x400(%rbp,%rax,1)
lea    -0x400(%rbp),%rsi
lea    0xd84(%rip),%rdi
call   1060 <printf@plt>
mov    -0x40c(%rbp),%edi
call   1080 <evutil_closesocket@plt>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<client>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
xor    %eax,%eax
call   1080 <create_connectfd@plt>
mov    %eax,%ebp
lea    0xe85(%rip),%r14
mov    $0xa,%edx
mov    %eax,%edi
mov    %r14,%rsi
xor    %ecx,%ecx
call   1040 <send@plt>
xor    %edi,%edi
cmp    $0xa,%rax
sete   %dil
call   1060 <assert@plt>
lea    0xe69(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    %rsp,%r14
mov    $0xa,%edx
mov    %ebp,%edi
mov    %r14,%rsi
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %rax,%rbx
xor    %edi,%edi
cmp    $0xa,%rax
sete   %dil
call   1060 <assert@plt>
movb   $0x0,(%rsp,%rbx,1)
lea    0xe43(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    %ebp,%edi
call   1070 <evutil_closesocket@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"HelloWorld\00"
@.str.1 = [19 x i8] c"[client] send: %s\0A\00"
@.str.2 = [19 x i8] c"[client] recv: %s\0A\00"
define void @client() {
%1 = alloca [1024 x i8]
%2 = alloca i64
%3 = alloca i32
%4 = call i32 (...) @create_connectfd()
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = call i64 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = call i64 @send(i32 %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %6, i32 0)
store i64 %7, i64* %2
%8 = load i64, i64* %2
%9 = call i64 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %8, %9
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* %3
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%16 = call i64 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%17 = call i64 @recv(i32 %14, i8* %15, i64 %16, i32 0)
store i64 %17, i64* %2
%18 = load i64, i64* %2
%19 = call i64 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %18, %19
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i64, i64* %2
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %23
store i8 0, i8* %24
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i32, i32* %3
%28 = call i32 @evutil_closesocket(i32 %27)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"HelloWorld\00"
@.str.1 = [19 x i8] c"[client] send: %s\0A\00"
@.str.2 = [19 x i8] c"[client] recv: %s\0A\00"
define void @client() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @create_connectfd()
%4 = tail call i64 @send(i32 %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 10, i32 0)
%5 = icmp eq i64 %4, 10
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%9 = call i64 @recv(i32 %3, i8* %2, i64 10, i32 0)
%10 = icmp eq i64 %9, 10
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %9
store i8 0, i8* %13
%14 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%15 = call i32 @evutil_closesocket(i32 %3)
ret void
}