#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;
};
struct in_addr {
  int /*<<< orphan*/ s_addr;
};
struct hostent {
  scalar_t__ h_addr;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char *);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ isNumber(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ shutdown(int, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int strlen(char *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  struct hostent *host;
  struct sockaddr_in servaddr;
  int port, sd, nread;
  char input[256], result[256];
  if (argc != 3) {
    printf("Error:%s serverAddress serverPort\n", argv[0]);
    exit(1);
  }
  host = gethostbyname(argv[1]);
  if (host == NULL) {
    printf("%s not found in /etc/hosts\n", argv[1]);
    exit(2);
  }
  if (!isNumber(argv[2])) {
    printf("%s\n", "Usage: client serverAddress serverPort");
    printf("%s is not a number\n", argv[2]);
    exit(3);
  }
  port = atoi(argv[2]);
  if (port < 1024 || port > 65535) {
    printf("Port must be in [1024, 65535]\n");
    exit(4);
  }
  memset((char *)&servaddr, 0, sizeof(struct sockaddr_in));
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = ((struct in_addr *)(host->h_addr))->s_addr;
  servaddr.sin_port = htons(port);
  printf("\n%s", "Insert Input: ");
  while (fgets(input, 256, stdin) != NULL) {
    if (input[strlen(input) - 1] == '\n')
      input[strlen(input) - 1] = '\0';
    sd = socket(AF_INET, SOCK_STREAM, 0);
    if (sd < 0) {
      perror("Opening Socket");
      exit(1);
    }
    printf("Socket created: sd=%d\n", sd);
    if (connect(sd, (struct sockaddr *)&servaddr, sizeof(struct sockaddr)) <
        0) {
      perror("connect");
      exit(1);
    }
    write(sd, input, strlen(input) + 1);
    shutdown(sd, 1);
    if ((nread = read(sd, result, 256)) < 0) {
      printf("ERROR receiving response\n");
      continue;
    }
    close(sd);
    printf("Result: %s\n", result);
    printf("\n%s", "Insert Input: ");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1242 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <gethostbyname@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    127e <main+0x7e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x2,%edi
call   1100 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10d0 <isNumber@plt>
cmp    $0x0,%eax
jne    12c9 <main+0xc9>
lea    0xe61(%rip),%rdi
lea    0xd9d(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x3,%edi
call   1100 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x400,-0x2c(%rbp)
jl     12f3 <main+0xf3>
cmpl   $0xffff,-0x2c(%rbp)
jle    130b <main+0x10b>
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x4,%edi
call   1100 <exit@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2cc6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x2c(%rbp),%edi
call   1060 <htons@plt>
mov    %eax,-0x28(%rbp)
lea    0xd54(%rip),%rdi
lea    0xd51(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x140(%rbp),%rdi
mov    0x2c7f(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   10b0 <fgets@plt>
cmp    $0x0,%rax
je     14e1 <main+0x2e1>
lea    -0x140(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x140(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    13b2 <main+0x1b2>
lea    -0x140(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x140(%rbp,%rax,1)
mov    0x2c2f(%rip),%rax
mov    (%rax),%edi
mov    0x2c0e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jge    13ee <main+0x1ee>
lea    0xccd(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x30(%rbp),%esi
lea    0xcc3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x4,%edx
call   1110 <connect@plt>
cmp    $0x0,%rax
jge    1430 <main+0x230>
lea    0xcb1(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x24c(%rbp)
lea    -0x140(%rbp),%rax
mov    %rax,-0x248(%rbp)
lea    -0x140(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x24c(%rbp),%edi
mov    -0x248(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1030 <write@plt>
mov    -0x30(%rbp),%edi
mov    $0x1,%esi
call   1040 <shutdown@plt>
mov    -0x30(%rbp),%edi
lea    -0x240(%rbp),%rsi
mov    $0x100,%edx
call   10a0 <read@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    14aa <main+0x2aa>
lea    0xc3c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1353 <main+0x153>
mov    -0x30(%rbp),%edi
call   1090 <close@plt>
lea    -0x240(%rbp),%rsi
lea    0xc34(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xbcb(%rip),%rdi
lea    0xbc8(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1353 <main+0x153>
xor    %eax,%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rsi,%rbp
cmp    $0x3,%edi
jne    142f <main+0x21f>
mov    0x8(%rbp),%rdi
call   10d0 <gethostbyname@plt>
test   %rax,%rax
je     144b <main+0x23b>
mov    %rax,%rbx
mov    0x10(%rbp),%rdi
call   10e0 <isNumber@plt>
test   %eax,%eax
je     1467 <main+0x257>
mov    0x10(%rbp),%rdi
call   1100 <atoi@plt>
mov    %eax,%ebp
lea    -0x10000(%rbp),%eax
cmp    $0xffff03ff,%eax
jbe    148f <main+0x27f>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2d63(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    (%rbx),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    %ebp,%edi
call   1070 <htons@plt>
mov    %eax,(%rsp)
lea    0xdd5(%rip),%rdi
lea    0xdd2(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2d26(%rip),%rax
mov    (%rax),%edx
lea    0x110(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   10c0 <fgets@plt>
test   %rax,%rax
je     13fc <main+0x1ec>
mov    0x2cef(%rip),%rbp
lea    0xdb4(%rip),%r14
mov    %rsp,%r15
lea    0x10(%rsp),%r12
jmp    132b <main+0x11b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xdc0(%rip),%rdi
call   1030 <puts@plt>
mov    0x2ccd(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   10c0 <fgets@plt>
test   %rax,%rax
je     13fc <main+0x1ec>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    134b <main+0x13b>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    0x2c96(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%esi
xor    %edx,%edx
call   1130 <socket@plt>
test   %eax,%eax
js     1410 <main+0x200>
mov    %eax,%r13d
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   1120 <connect@plt>
test   %rax,%rax
js     1419 <main+0x209>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edx
mov    %r13d,%edi
mov    %rbx,%rsi
call   1040 <write@plt>
mov    %r13d,%edi
mov    $0x1,%esi
call   1050 <shutdown@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    $0x100,%edx
call   10b0 <read@plt>
test   %eax,%eax
js     1300 <main+0xf0>
mov    %r13d,%edi
call   10a0 <close@plt>
lea    0xce3(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc91(%rip),%rdi
lea    0xc8e(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    130c <main+0xfc>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc76(%rip),%rdi
jmp    1420 <main+0x210>
lea    0xc93(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x0(%rbp),%rsi
lea    0xbc6(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x8(%rbp),%rsi
lea    0xbcd(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x2,%edi
call   1110 <exit@plt>
lea    0xbd1(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rbp),%rsi
lea    0xbe8(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x3,%edi
call   1110 <exit@plt>
lea    0xc4a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x4,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.hostent = type { i64 }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.in_addr = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [35 x i8] c"Error:%s serverAddress serverPort\0A\00"
@.str.1 = [28 x i8] c"%s not found in /etc/hosts\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [39 x i8] c"Usage: client serverAddress serverPort\00"
@.str.4 = [20 x i8] c"%s is not a number\0A\00"
@.str.5 = [31 x i8] c"Port must be in [1024, 65535]\0A\00"
@AF_INET = global i32 0
@.str.6 = [4 x i8] c"\0A%s\00"
@.str.7 = [15 x i8] c"Insert Input: \00"
@stdin = global i32 0
@SOCK_STREAM = global i32 0
@.str.8 = [15 x i8] c"Opening Socket\00"
@.str.9 = [23 x i8] c"Socket created: sd=%d\0A\00"
@.str.10 = [8 x i8] c"connect\00"
@.str.11 = [26 x i8] c"ERROR receiving response\0A\00"
@.str.12 = [12 x i8] c"Result: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.hostent*
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [256 x i8]
%12 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call %struct.hostent* @gethostbyname(i8* %24)
store %struct.hostent* %25, %struct.hostent** %6
%26 = load %struct.hostent*, %struct.hostent** %6
%27 = icmp eq %struct.hostent* %26, null
br i1 %27, label %28, label %34
28: ; preds = %21
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = call i32 @exit(i32 2)
unreachable
34: ; preds = %21
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @isNumber(i8* %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %47, label %40
40: ; preds = %34
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %44)
%46 = call i32 @exit(i32 3)
unreachable
47: ; preds = %34
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 @atoi(i8* %50)
store i32 %51, i32* %8
%52 = load i32, i32* %8
%53 = icmp slt i32 %52, 1024
br i1 %53, label %57, label %54
54: ; preds = %47
%55 = load i32, i32* %8
%56 = icmp sgt i32 %55, 65535
br i1 %56, label %57, label %60
57: ; preds = %54, %47
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%59 = call i32 @exit(i32 4)
unreachable
60: ; preds = %54
%61 = bitcast %struct.sockaddr_in* %7 to i8*
%62 = call i32 @memset(i8* %61, i32 0, i32 12)
%63 = load i32, i32* @AF_INET
%64 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i32 %63, i32* %64
%65 = load %struct.hostent*, %struct.hostent** %6
%66 = getelementptr inbounds %struct.hostent, %struct.hostent* %65, i32 0, i32 0
%67 = load i64, i64* %66
%68 = inttoptr i64 %67 to %struct.in_addr*
%69 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %68, i32 0, i32 0
%70 = load i32, i32* %69
%71 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%72 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %71, i32 0, i32 0
store i32 %70, i32* %72
%73 = load i32, i32* %8
%74 = call i32 @htons(i32 %73)
%75 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i32 %74, i32* %75
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %77
77: ; preds = %131, %129, %60
%78 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%79 = load i32, i32* @stdin
%80 = call i32* @fgets(i8* %78, i32 256, i32 %79)
%81 = icmp ne i32* %80, null
br i1 %81, label %82, label %137
82: ; preds = %77
%83 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%84 = call i32 @strlen(i8* %83)
%85 = sub nsw i32 %84, 1
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 %86
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp eq i32 %89, 10
br i1 %90, label %91, label %97
91: ; preds = %82
%92 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%93 = call i32 @strlen(i8* %92)
%94 = sub nsw i32 %93, 1
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 %95
store i8 0, i8* %96
br label %97
97: ; preds = %91, %82
%98 = load i32, i32* @AF_INET
%99 = load i32, i32* @SOCK_STREAM
%100 = call i32 @socket(i32 %98, i32 %99, i32 0)
store i32 %100, i32* %9
%101 = load i32, i32* %9
%102 = icmp slt i32 %101, 0
br i1 %102, label %103, label %106
103: ; preds = %97
%104 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%105 = call i32 @exit(i32 1)
unreachable
106: ; preds = %97
%107 = load i32, i32* %9
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %107)
%109 = load i32, i32* %9
%110 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%111 = call i64 @connect(i32 %109, %struct.sockaddr* %110, i32 4)
%112 = icmp slt i64 %111, 0
br i1 %112, label %113, label %116
113: ; preds = %106
%114 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%115 = call i32 @exit(i32 1)
unreachable
116: ; preds = %106
%117 = load i32, i32* %9
%118 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%119 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%120 = call i32 @strlen(i8* %119)
%121 = add nsw i32 %120, 1
%122 = call i32 @write(i32 %117, i8* %118, i32 %121)
%123 = load i32, i32* %9
%124 = call i32 @shutdown(i32 %123, i32 1)
%125 = load i32, i32* %9
%126 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%127 = call i32 @read(i32 %125, i8* %126, i32 256)
store i32 %127, i32* %10
%128 = icmp slt i32 %127, 0
br i1 %128, label %129, label %131
129: ; preds = %116
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
br label %77
131: ; preds = %116
%132 = load i32, i32* %9
%133 = call i32 @close(i32 %132)
%134 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i8* %134)
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %77
137: ; preds = %77
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i64 }
%struct.in_addr = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [35 x i8] c"Error:%s serverAddress serverPort\0A\00"
@.str.1 = [28 x i8] c"%s not found in /etc/hosts\0A\00"
@.str.3 = [39 x i8] c"Usage: client serverAddress serverPort\00"
@.str.4 = [20 x i8] c"%s is not a number\0A\00"
@AF_INET = global i32 0
@.str.6 = [4 x i8] c"\0A%s\00"
@.str.7 = [15 x i8] c"Insert Input: \00"
@stdin = global i32 0
@SOCK_STREAM = global i32 0
@.str.8 = [15 x i8] c"Opening Socket\00"
@.str.9 = [23 x i8] c"Socket created: sd=%d\0A\00"
@.str.10 = [8 x i8] c"connect\00"
@.str.12 = [12 x i8] c"Result: %s\0A\00"
@str = [25 x i8] c"ERROR receiving response\00"
@str.13 = [30 x i8] c"Port must be in [1024, 65535]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = bitcast %struct.sockaddr_in* %3 to i8*
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 3
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call %struct.hostent* @gethostbyname(i8* %16)
%18 = icmp eq %struct.hostent* %17, null
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i8*, i8** %15
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = tail call i32 @exit(i32 2)
unreachable
23: ; preds = %14
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32 @isNumber(i8* %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%30 = load i8*, i8** %24
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %30)
%32 = tail call i32 @exit(i32 3)
unreachable
33: ; preds = %23
%34 = load i8*, i8** %24
%35 = tail call i32 @atoi(i8* %34)
%36 = add i32 %35, -65536
%37 = icmp ult i32 %36, -64512
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.13, i64 0, i64 0))
%40 = tail call i32 @exit(i32 4)
unreachable
41: ; preds = %33
%42 = call i32 @memset(i8* %6, i32 0, i32 12)
%43 = load i32, i32* @AF_INET
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %43, i32* %44
%45 = getelementptr inbounds %struct.hostent, %struct.hostent* %17, i64 0, i32 0
%46 = load i64, i64* %45
%47 = inttoptr i64 %46 to %struct.in_addr*
%48 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %47, i64 0, i32 0
%49 = load i32, i32* %48
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %49, i32* %50
%51 = call i32 @htons(i32 %35)
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %51, i32* %52
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%54 = load i32, i32* @stdin
%55 = call i32* @fgets(i8* %7, i32 256, i32 %54)
%56 = icmp eq i32* %55, null
br i1 %56, label %103, label %57
57: ; preds = %41
%58 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
br label %59
59: ; preds = %57, %95
%60 = call i32 @strlen(i8* %7)
%61 = add nsw i32 %60, -1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = icmp eq i8 %64, 10
br i1 %65, label %66, label %71
66: ; preds = %59
%67 = call i32 @strlen(i8* %7)
%68 = add nsw i32 %67, -1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %69
store i8 0, i8* %70
br label %71
71: ; preds = %66, %59
%72 = load i32, i32* @AF_INET
%73 = load i32, i32* @SOCK_STREAM
%74 = call i32 @socket(i32 %72, i32 %73, i32 0)
%75 = icmp slt i32 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %71
%77 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %71
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %74)
%81 = call i64 @connect(i32 %74, %struct.sockaddr* %58, i32 4)
%82 = icmp slt i64 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %79
%84 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %79
%87 = call i32 @strlen(i8* %7)
%88 = add nsw i32 %87, 1
%89 = call i32 @write(i32 %74, i8* %7, i32 %88)
%90 = call i32 @shutdown(i32 %74, i32 1)
%91 = call i32 @read(i32 %74, i8* %8, i32 256)
%92 = icmp slt i32 %91, 0
br i1 %92, label %93, label %99
93: ; preds = %86
%94 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %95
95: ; preds = %93, %99
%96 = load i32, i32* @stdin
%97 = call i32* @fgets(i8* %7, i32 256, i32 %96)
%98 = icmp eq i32* %97, null
br i1 %98, label %103, label %59
99: ; preds = %86
%100 = call i32 @close(i32 %74)
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i8* %8)
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %95
103: ; preds = %95, %41
ret i32 0
}