#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ sin;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_LOOPBACK;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
int /*<<< orphan*/ recv(int, char *, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ server_send(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int strlen(char *);
int execute_recv() {
  fprintf(stderr, "in RECV");
  char *message = "Message to be received.";
  size_t messagelen = strlen(message) + 1;
  server_send(message);
  int sfd = socket(AF_INET, SOCK_STREAM, 0);
  struct sockaddr_in sin;
  memset((void *)&sin, 0, sizeof(sin));
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
  sin.sin_port = htons(25588);
  socklen_t sin_len = sizeof(struct sockaddr);
  connect(sfd, (struct sockaddr *)&sin, sin_len);
  char line[messagelen];
  recv(sfd, line, messagelen, 0);
  return 0;
}


x86 assembly (clang, -O0):
<execute_recv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1080 <fprintf@plt>
lea    0xe54(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   10a0 <server_send@plt>
mov    0x2e0e(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    (%rax),%edi
mov    0x2de1(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    %edx,-0x4c(%rbp)
call   10b0 <socket@plt>
mov    -0x4c(%rbp),%esi
mov    %eax,-0x14(%rbp)
lea    -0x20(%rbp),%rdi
mov    %rdi,-0x40(%rbp)
mov    $0xc,%edx
call   1070 <memset@plt>
mov    -0x48(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x63f4,%edi
call   1050 <htons@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,-0x20(%rbp)
movl   $0x4,-0x24(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x24(%rbp),%edx
call   1090 <connect@plt>
mov    -0x10(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rdx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_recv>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
call   1080 <fprintf@plt>
lea    0xe4b(%rip),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
movslq %eax,%rbx
lea    0x1(%rbx),%r14
mov    %r15,%rdi
call   10a0 <server_send@plt>
mov    0x2e0d(%rip),%r13
mov    0x0(%r13),%edi
mov    0x2de2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
mov    %eax,%r12d
lea    -0x38(%rbp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x0(%r13),%eax
mov    %eax,-0x30(%rbp)
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,-0x34(%rbp)
mov    $0x63f4,%edi
call   1050 <htons@plt>
mov    %eax,-0x38(%rbp)
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   1090 <connect@plt>
mov    %rsp,%r15
mov    %rsp,%rsi
add    $0x10,%rbx
and    $0xfffffffffffffff0,%rbx
sub    %rbx,%rsi
mov    %rsi,%rsp
mov    %r12d,%edi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [8 x i8] c"in RECV\00"
@.str.1 = [24 x i8] c"Message to be received.\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@INADDR_LOOPBACK = global i32 0
define i32 @execute_recv() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8** %1
%10 = load i8*, i8** %1
%11 = call i32 @strlen(i8* %10)
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
store i64 %13, i64* %2
%14 = load i8*, i8** %1
%15 = call i32 @server_send(i8* %14)
%16 = load i32, i32* @AF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = call i32 @socket(i32 %16, i32 %17, i32 0)
store i32 %18, i32* %3
%19 = bitcast %struct.sockaddr_in* %4 to i8*
%20 = call i32 @memset(i8* %19, i32 0, i32 12)
%21 = load i32, i32* @AF_INET
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 2
store i32 %21, i32* %22
%23 = load i32, i32* @INADDR_LOOPBACK
%24 = call i32 @htonl(i32 %23)
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 1
%26 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %25, i32 0, i32 0
store i32 %24, i32* %26
%27 = call i32 @htons(i32 25588)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
store i32 %27, i32* %28
store i32 4, i32* %5
%29 = load i32, i32* %3
%30 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%31 = load i32, i32* %5
%32 = call i32 @connect(i32 %29, %struct.sockaddr* %30, i32 %31)
%33 = load i64, i64* %2
%34 = call i8* @llvm.stacksave()
store i8* %34, i8** %6
%35 = alloca i8, i64 %33
store i64 %33, i64* %7
%36 = load i32, i32* %3
%37 = load i64, i64* %2
%38 = call i32 @recv(i32 %36, i8* %35, i64 %37, i32 0)
%39 = load i8*, i8** %6
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [8 x i8] c"in RECV\00"
@.str.1 = [24 x i8] c"Message to be received.\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@INADDR_LOOPBACK = global i32 0
define i32 @execute_recv() {
%1 = alloca %struct.sockaddr_in
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%5 = add nsw i32 %4, 1
%6 = sext i32 %5 to i64
%7 = tail call i32 @server_send(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @AF_INET
%9 = load i32, i32* @SOCK_STREAM
%10 = tail call i32 @socket(i32 %8, i32 %9, i32 0)
%11 = bitcast %struct.sockaddr_in* %1 to i8*
%12 = call i32 @memset(i8* %11, i32 0, i32 12)
%13 = load i32, i32* @AF_INET
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %13, i32* %14
%15 = load i32, i32* @INADDR_LOOPBACK
%16 = call i32 @htonl(i32 %15)
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %16, i32* %17
%18 = call i32 @htons(i32 25588)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %18, i32* %19
%20 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%21 = call i32 @connect(i32 %10, %struct.sockaddr* %20, i32 4)
%22 = call i8* @llvm.stacksave()
%23 = alloca i8, i64 %6
%24 = call i32 @recv(i32 %10, i8* %23, i64 %6, i32 0)
ret i32 0
}