#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 {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int dummy;
};
typedef int /*<<< orphan*/ server_address;
typedef int /*<<< orphan*/ buff;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int client(char *args) {
  printf("Argument Dump(Debug purposes):%s\n", args);
  char *address = args;
  int es_socket, addrlen;
  int port = 2718;
  printf("Establishing Socket\n");
  es_socket = socket(AF_INET, SOCK_STREAM, 0);
  struct hostent *server;
  printf("Resolving Hostname\n");
  server = gethostbyname(address);
  struct sockaddr_in server_address;
  printf("Setting Zeros\n");
  bzero((char *)&server_address, sizeof(server_address));
  server_address.sin_family = AF_INET;
  printf("Binding Address To Machine\n");
  server_address.sin_port = htons(port);
  server_address.sin_addr.s_addr = inet_addr(address);
  printf("Connecting to server\n");
  if ((connect(es_socket, (struct sockaddr *)&server_address,
               sizeof(server_address))) < 0) {
    printf("Failed to connect!\n");
    exit(EXIT_FAILURE);
  }
  printf("Connected!\n");
  int linelen = 0;
  int i = 0;
  while (1) {
    char *buff = malloc(1024);
    recv(es_socket, buff, sizeof(buff), 0);
    printf("%s", buff);
    char *recvbuff = malloc(1024);
    fgets(recvbuff, 1024, stdin);
    send(es_socket, recvbuff, 1024, 0);
    char *buffer = malloc(1024);
    recv(es_socket, buffer, 1024, 0);
    printf("%s\n", buffer);
  }
  close(es_socket);
}


x86 assembly (clang, -O0):
<client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0xa9e,-0x1c(%rbp)
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    0x2dc5(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,-0x14(%rbp)
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1090 <gethostbyname@plt>
mov    %rax,-0x28(%rbp)
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x38(%rbp),%rdi
mov    $0xc,%esi
call   10b0 <bzero@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1040 <htons@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <inet_addr@plt>
mov    %eax,-0x38(%rbp)
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <connect@plt>
cmp    $0x0,%rax
jge    12c4 <client+0x104>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x48(%rbp),%rsi
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
mov    0x2cb4(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1070 <fgets@plt>
mov    -0x14(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x58(%rbp),%rsi
lea    0xca7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12e0 <client+0x120>

x86 assembly (clang, -O2):
<client>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
lea    0xe1c(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe30(%rip),%rdi
call   1040 <puts@plt>
mov    0x2de7(%rip),%rbx
mov    (%rbx),%edi
mov    0x2dc6(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,%ebp
lea    0xe1d(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   10a0 <gethostbyname@plt>
lea    0xe1c(%rip),%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%r15
mov    %r15,%rdi
mov    $0xc,%esi
call   10c0 <bzero@plt>
mov    (%rbx),%eax
mov    %eax,0x10(%rsp)
lea    0xe06(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa9e,%edi
call   1050 <htons@plt>
mov    %eax,0xc(%rsp)
mov    %r14,%rdi
call   1090 <inet_addr@plt>
mov    %eax,0x8(%rsp)
lea    0xdfb(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   10e0 <connect@plt>
test   %rax,%rax
js     1344 <client+0x174>
lea    0xdec(%rip),%rdi
call   1040 <puts@plt>
lea    0xd78(%rip),%r14
mov    0x2d2f(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x400,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %rax,%rsi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x400,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
mov    (%r15),%edx
mov    %rax,%rdi
mov    $0x400,%esi
call   1080 <fgets@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    $0x400,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %rax,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
jmp    12c0 <client+0xf0>
lea    0xd4a(%rip),%rdi
call   1040 <puts@plt>
mov    0x2c71(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.hostent = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [34 x i8] c"Argument Dump(Debug purposes):%s\0A\00"
@.str.1 = [21 x i8] c"Establishing Socket\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [20 x i8] c"Resolving Hostname\0A\00"
@.str.3 = [15 x i8] c"Setting Zeros\0A\00"
@.str.4 = [28 x i8] c"Binding Address To Machine\0A\00"
@.str.5 = [22 x i8] c"Connecting to server\0A\00"
@.str.6 = [20 x i8] c"Failed to connect!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.7 = [12 x i8] c"Connected!\0A\00"
@.str.8 = [3 x i8] c"%s\00"
@stdin = global i32 0
@.str.9 = [4 x i8] c"%s\0A\00"
define i32 @client(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.hostent*
%8 = alloca %struct.sockaddr_in
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %2
%14 = load i8*, i8** %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %2
store i8* %16, i8** %3
store i32 2718, i32* %6
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @AF_INET
%19 = load i32, i32* @SOCK_STREAM
%20 = call i32 @socket(i32 %18, i32 %19, i32 0)
store i32 %20, i32* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%22 = load i8*, i8** %3
%23 = call %struct.hostent* @gethostbyname(i8* %22)
store %struct.hostent* %23, %struct.hostent** %7
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%25 = bitcast %struct.sockaddr_in* %8 to i8*
%26 = call i32 @bzero(i8* %25, i32 12)
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %27, i32* %28
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%30 = load i32, i32* %6
%31 = call i32 @htons(i32 %30)
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
store i32 %31, i32* %32
%33 = load i8*, i8** %3
%34 = call i32 @inet_addr(i8* %33)
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%36 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %35, i32 0, i32 0
store i32 %34, i32* %36
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%38 = load i32, i32* %4
%39 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%40 = call i64 @connect(i32 %38, %struct.sockaddr* %39, i32 12)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %1
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %1
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %9
store i32 0, i32* %10
br label %48
48: ; preds = %46, %48
%49 = call i8* @malloc(i32 1024)
store i8* %49, i8** %11
%50 = load i32, i32* %4
%51 = load i8*, i8** %11
%52 = call i32 @recv(i32 %50, i8* %51, i32 8, i32 0)
%53 = load i8*, i8** %11
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %53)
%55 = call i8* @malloc(i32 1024)
store i8* %55, i8** %12
%56 = load i8*, i8** %12
%57 = load i32, i32* @stdin
%58 = call i32 @fgets(i8* %56, i32 1024, i32 %57)
%59 = load i32, i32* %4
%60 = load i8*, i8** %12
%61 = call i32 @send(i32 %59, i8* %60, i32 1024, i32 0)
%62 = call i8* @malloc(i32 1024)
store i8* %62, i8** %13
%63 = load i32, i32* %4
%64 = load i8*, i8** %13
%65 = call i32 @recv(i32 %63, i8* %64, i32 1024, i32 0)
%66 = load i8*, i8** %13
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %66)
br label %48
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [34 x i8] c"Argument Dump(Debug purposes):%s\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@EXIT_FAILURE = global i32 0
@.str.8 = [3 x i8] c"%s\00"
@stdin = global i32 0
@str = [20 x i8] c"Establishing Socket\00"
@str.10 = [19 x i8] c"Resolving Hostname\00"
@str.11 = [14 x i8] c"Setting Zeros\00"
@str.12 = [27 x i8] c"Binding Address To Machine\00"
@str.13 = [21 x i8] c"Connecting to server\00"
@str.14 = [11 x i8] c"Connected!\00"
@str.15 = [19 x i8] c"Failed to connect!\00"
define i32 @client(i8* %0) {
%2 = alloca %struct.sockaddr_in
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%5 = load i32, i32* @AF_INET
%6 = load i32, i32* @SOCK_STREAM
%7 = tail call i32 @socket(i32 %5, i32 %6, i32 0)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0))
%9 = tail call %struct.hostent* @gethostbyname(i8* %0)
%10 = bitcast %struct.sockaddr_in* %2 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.11, i64 0, i64 0))
%12 = call i32 @bzero(i8* %10, i32 12)
%13 = load i32, i32* @AF_INET
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i32 %13, i32* %14
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.12, i64 0, i64 0))
%16 = tail call i32 @htons(i32 2718)
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
store i32 %16, i32* %17
%18 = tail call i32 @inet_addr(i8* %0)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0, i32 0
store i32 %18, i32* %19
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.13, i64 0, i64 0))
%21 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%22 = call i64 @connect(i32 %7, %struct.sockaddr* %21, i32 12)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %1
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.15, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %1
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.14, i64 0, i64 0))
br label %30
30: ; preds = %30, %28
%31 = call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%32 = call i32 @recv(i32 %7, i8* %31, i32 8, i32 0)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %31)
%34 = call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%35 = load i32, i32* @stdin
%36 = call i32 @fgets(i8* %34, i32 1024, i32 %35)
%37 = call i32 @send(i32 %7, i8* %34, i32 1024, i32 0)
%38 = call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%39 = call i32 @recv(i32 %7, i8* %38, i32 1024, i32 0)
%40 = call i32 @puts(i8* dereferenceable(1) %38)
br label %30
}