#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 /*<<< orphan*/ serv_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_LOOPBACK;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
void Recv() {
  struct sockaddr_in serv_addr;
  int sock_fd;
  char line[15] = "Hello world!";
  int size = 13;
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
  serv_addr.sin_port = htons(5000);
  sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  connect(sock_fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
  send(sock_fd, line, size, 0);
  close(sock_fd);
}


x86 assembly (clang, -O0):
<Recv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xe91(%rip),%rax
mov    %rax,-0x23(%rbp)
mov    0xe8f(%rip),%eax
mov    %eax,-0x1b(%rbp)
mov    0xe89(%rip),%ax
mov    %ax,-0x17(%rbp)
mov    0xe81(%rip),%al
mov    %al,-0x15(%rbp)
movl   $0xd,-0x28(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,-0xc(%rbp)
mov    $0x1388,%edi
call   1030 <htons@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    0x2df7(%rip),%rax
mov    (%rax),%esi
mov    0x2e06(%rip),%rax
mov    (%rax),%edx
call   1080 <socket@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0xc,%edx
call   1070 <connect@plt>
mov    -0x14(%rbp),%edi
lea    -0x23(%rbp),%rsi
mov    -0x28(%rbp),%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Recv>:
push   %rbx
sub    $0x20,%rsp
movabs $0x21646c726f,%rax
mov    %rax,0x17(%rsp)
movabs $0x6f77206f6c6c6548,%rax
20 77 6f
mov    %rax,0x10(%rsp)
mov    0x2e5e(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,0x8(%rsp)
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,0x4(%rsp)
mov    $0x1388,%edi
call   1030 <htons@plt>
mov    %eax,(%rsp)
mov    (%rbx),%edi
mov    0x2e10(%rip),%rax
mov    (%rax),%esi
mov    0x2e1f(%rip),%rax
mov    (%rax),%edx
call   1080 <socket@plt>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0xc,%edx
call   1070 <connect@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0xd,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %ebx,%edi
call   1060 <close@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@__const.Recv.line = [15 x i8] c"Hello world!\00\00\00"
@AF_INET = global i32 0
@INADDR_LOOPBACK = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
define void @Recv() {
%1 = alloca %struct.sockaddr_in
%2 = alloca i32
%3 = alloca [15 x i8]
%4 = alloca i32
%5 = bitcast [15 x i8]* %3 to i8*
store i32 13, i32* %4
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 2
store i32 %6, i32* %7
%8 = load i32, i32* @INADDR_LOOPBACK
%9 = call i32 @htonl(i32 %8)
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 1
%11 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %10, i32 0, i32 0
store i32 %9, i32* %11
%12 = call i32 @htons(i32 5000)
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 0
store i32 %12, i32* %13
%14 = load i32, i32* @AF_INET
%15 = load i32, i32* @SOCK_STREAM
%16 = load i32, i32* @IPPROTO_TCP
%17 = call i32 @socket(i32 %14, i32 %15, i32 %16)
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%20 = call i32 @connect(i32 %18, %struct.sockaddr* %19, i32 12)
%21 = load i32, i32* %2
%22 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%23 = load i32, i32* %4
%24 = call i32 @send(i32 %21, i8* %22, i32 %23, i32 0)
%25 = load i32, i32* %2
%26 = call i32 @close(i32 %25)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@__const.Recv.line = [15 x i8] c"Hello world!\00\00\00"
@AF_INET = global i32 0
@INADDR_LOOPBACK = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
define void @Recv() {
%1 = alloca %struct.sockaddr_in
%2 = alloca [15 x i8]
%3 = bitcast %struct.sockaddr_in* %1 to i8*
%4 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @AF_INET
%6 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %5, i32* %6
%7 = load i32, i32* @INADDR_LOOPBACK
%8 = tail call i32 @htonl(i32 %7)
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %8, i32* %9
%10 = tail call i32 @htons(i32 5000)
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %10, i32* %11
%12 = load i32, i32* @AF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = load i32, i32* @IPPROTO_TCP
%15 = tail call i32 @socket(i32 %12, i32 %13, i32 %14)
%16 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%17 = call i32 @connect(i32 %15, %struct.sockaddr* %16, i32 12)
%18 = call i32 @send(i32 %15, i8* %4, i32 13, i32 0)
%19 = call i32 @close(i32 %15)
ret void
}