#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 */
typedef int /*<<< orphan*/ u_short;
struct TYPE_2__ {
  void *s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  void *sin_port;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ s_addr;

/* Variables and functions */
void *AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char const *);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
void *htons(int /*<<< orphan*/);
void *inet_addr(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sleep(int);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
scalar_t__ write(int, char *, int);
int main(int argc, char const *argv[]) {
  int port, serv_no;
  char buf[128];
  if (argc == 1) {
    {
      printf("%s\n", "Usage: ./client <port>");
      exit(1);
    };
  } else {
    port = atoi(argv[1]);
    if (port < 1024 || port > 65535) {
      printf("%s\n", "Port must between 1024 to 65535");
      exit(1);
    };
  }
  struct sockaddr_in s_addr;
  char buffer[1024];
  int sfd, n;
  memset((char *)&s_addr, 0, sizeof(s_addr));
  s_addr.sin_family = AF_INET;
  s_addr.sin_port = htons((u_short)port);
  s_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
  if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    printf("%s\n", "socket() error");
    exit(1);
  };
  if (connect(sfd, (struct sockaddr *)&s_addr, sizeof(s_addr)) < 0) {
    printf("%s\n", "connect() error");
    exit(1);
  };
  printf("Type Name of the Service(s1,s2,s3,..) : ");
  scanf("%s", buf);
  write(sfd, buf, strlen(buf));
  read(sfd, buf, 128);
  close(sfd);
  serv_no = atoi(buf);
  printf("%s %d\n", buf, strlen(buf));
  if (strcmp(buf, "exit") == 0) {
    printf("%s\n", "Service Unavailable !");
    exit(1);
  };
  if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    printf("%s\n", "socket() error");
    exit(1);
  };
  memset((char *)&s_addr, 0, sizeof(s_addr));
  s_addr.sin_family = AF_INET;
  s_addr.sin_port = htons((u_short)serv_no);
  s_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
  sleep(3);
  if (connect(sfd, (struct sockaddr *)&s_addr, sizeof(s_addr)) < 0) {
    printf("%s\n", "connect() error");
    exit(1);
  };
  printf("connection successfull\n");
  read(0, buf, 128);
  if (write(sfd, buf, strlen(buf)) < 0) {
    printf("%s\n", "send() error");
    exit(1);
  }
  if ((n = read(sfd, buffer, 128)) < 0) {
    printf("%s\n", "recv() error");
    exit(1);
  };
  write(1, buffer, n);
  printf("\nExiting ...\n");
  close(sfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4f0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1232 <main+0x42>
lea    0xde6(%rip),%rdi
lea    0xde3(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x400,-0x14(%rbp)
jl     125c <main+0x6c>
cmpl   $0xffff,-0x14(%rbp)
jle    127b <main+0x8b>
lea    0xd9d(%rip),%rdi
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
jmp    1280 <main+0x90>
lea    -0xb8(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <htons@plt>
mov    %rax,-0xb0(%rbp)
lea    0xd81(%rip),%rdi
call   10a0 <inet_addr@plt>
mov    %rax,-0xb8(%rbp)
mov    0x2d1b(%rip),%rax
mov    (%rax),%rdi
mov    0x2d01(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x4c4(%rbp)
cmp    $0x0,%eax
jge    130e <main+0x11e>
lea    0xd0a(%rip),%rdi
lea    0xd48(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x4c4(%rbp),%edi
lea    -0xb8(%rbp),%rsi
mov    $0x18,%edx
call   10f0 <connect@plt>
cmp    $0x0,%rax
jge    134e <main+0x15e>
lea    0xcca(%rip),%rdi
lea    0xd17(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xa0(%rbp),%rsi
lea    0xd23(%rip),%rdi
call   10c0 <scanf@plt>
mov    -0x4c4(%rbp),%eax
mov    %eax,-0x4dc(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0x4d8(%rbp)
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x4dc(%rbp),%edi
mov    -0x4d8(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x4c4(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x80,%edx
call   1090 <read@plt>
mov    -0x4c4(%rbp),%edi
call   1080 <close@plt>
lea    -0xa0(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x18(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0x4d0(%rbp)
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x4d0(%rbp),%rsi
mov    %eax,%edx
lea    0xc8c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xc7e(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1447 <main+0x257>
lea    0xbd1(%rip),%rdi
lea    0xc66(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2b9a(%rip),%rax
mov    (%rax),%rdi
mov    0x2b80(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x4c4(%rbp)
cmp    $0x0,%eax
jge    148f <main+0x29f>
lea    0xb89(%rip),%rdi
lea    0xbc7(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0xb8(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    0x2b3f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <htons@plt>
mov    %rax,-0xb0(%rbp)
lea    0xb72(%rip),%rdi
call   10a0 <inet_addr@plt>
mov    %rax,-0xb8(%rbp)
mov    $0x3,%edi
call   1100 <sleep@plt>
mov    -0x4c4(%rbp),%edi
lea    -0xb8(%rbp),%rsi
mov    $0x18,%edx
call   10f0 <connect@plt>
cmp    $0x0,%rax
jge    151f <main+0x32f>
lea    0xaf9(%rip),%rdi
lea    0xb46(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xb8c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xa0(%rbp),%rsi
xor    %edi,%edi
mov    $0x80,%edx
call   1090 <read@plt>
mov    -0x4c4(%rbp),%eax
mov    %eax,-0x4ec(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0x4e8(%rbp)
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x4ec(%rbp),%edi
mov    -0x4e8(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    15a3 <main+0x3b3>
lea    0xa75(%rip),%rdi
lea    0xb38(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x4c4(%rbp),%edi
lea    -0x4c0(%rbp),%rsi
mov    $0x80,%edx
call   1090 <read@plt>
mov    %eax,-0x4c8(%rbp)
cmp    $0x0,%eax
jge    15e8 <main+0x3f8>
lea    0xa30(%rip),%rdi
lea    0xb00(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0x4c0(%rbp),%rsi
mov    -0x4c8(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
lea    0xade(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4c4(%rbp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x4f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x4a0,%rsp
cmp    $0x1,%edi
je     1444 <main+0x244>
mov    0x8(%rsi),%rdi
call   10e0 <atoi@plt>
mov    %eax,%ebx
lea    -0x10000(%rbx),%eax
cmp    $0xffff03ff,%eax
jbe    144d <main+0x24d>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    0x2d9c(%rip),%r15
mov    (%r15),%rax
mov    %rax,0x18(%rsp)
mov    %ebx,%edi
call   1060 <htons@plt>
mov    %rax,0x10(%rsp)
lea    0xdd0(%rip),%rdi
call   10b0 <inet_addr@plt>
mov    %rax,0x8(%rsp)
mov    (%r15),%rdi
mov    0x2d5d(%rip),%r12
mov    (%r12),%esi
xor    %edx,%edx
call   1120 <socket@plt>
test   %eax,%eax
js     1432 <main+0x232>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
mov    $0x18,%edx
call   1100 <connect@plt>
test   %rax,%rax
js     143b <main+0x23b>
lea    0xdaf(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdca(%rip),%rdi
lea    0x20(%rsp),%rbp
mov    %rbp,%rsi
call   10d0 <scanf@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x80,%edx
call   10a0 <read@plt>
mov    %ebx,%edi
call   1090 <close@plt>
mov    %rbp,%rdi
call   10e0 <atoi@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
call   1050 <strlen@plt>
lea    0xd7c(%rip),%rdi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd70(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1456 <main+0x256>
mov    (%r15),%rdi
mov    (%r12),%esi
xor    %edx,%edx
call   1120 <socket@plt>
test   %eax,%eax
js     1432 <main+0x232>
mov    %eax,%ebx
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    (%r15),%rax
mov    %rax,0x18(%rsp)
mov    %r14d,%edi
call   1060 <htons@plt>
mov    %rax,0x10(%rsp)
lea    0xcbb(%rip),%rdi
call   10b0 <inet_addr@plt>
mov    %rax,0x8(%rsp)
mov    $0x3,%edi
call   1110 <sleep@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x18,%edx
call   1100 <connect@plt>
test   %rax,%rax
js     143b <main+0x23b>
lea    0xd19(%rip),%rdi
call   1030 <puts@plt>
lea    0x20(%rsp),%rbp
xor    %edi,%edi
mov    %rbp,%rsi
mov    $0x80,%edx
call   10a0 <read@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %rax,%rax
js     145f <main+0x25f>
lea    0xa0(%rsp),%rsi
mov    %ebx,%edi
mov    $0x80,%edx
call   10a0 <read@plt>
test   %eax,%eax
js     1468 <main+0x268>
lea    0xa0(%rsp),%rsi
mov    $0x1,%edi
mov    %eax,%edx
call   1040 <write@plt>
lea    0xccb(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x4a0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc08(%rip),%rdi
jmp    146f <main+0x26f>
lea    0xc0e(%rip),%rdi
jmp    146f <main+0x26f>
lea    0xbb5(%rip),%rdi
jmp    146f <main+0x26f>
lea    0xbc3(%rip),%rdi
jmp    146f <main+0x26f>
lea    0xc3b(%rip),%rdi
jmp    146f <main+0x26f>
lea    0xc48(%rip),%rdi
jmp    146f <main+0x26f>
lea    0xc4c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [23 x i8] c"Usage: ./client <port>\00"
@.str.2 = [32 x i8] c"Port must between 1024 to 65535\00"
@AF_INET = global i8* null
@.str.3 = [10 x i8] c"127.0.0.1\00"
@SOCK_STREAM = global i32 0
@.str.4 = [15 x i8] c"socket() error\00"
@.str.5 = [16 x i8] c"connect() error\00"
@.str.6 = [41 x i8] c"Type Name of the Service(s1,s2,s3,..) : \00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [7 x i8] c"%s %d\0A\00"
@.str.9 = [5 x i8] c"exit\00"
@.str.10 = [22 x i8] c"Service Unavailable !\00"
@.str.11 = [24 x i8] c"connection successfull\0A\00"
@.str.12 = [13 x i8] c"send() error\00"
@.str.13 = [13 x i8] c"recv() error\00"
@.str.14 = [14 x i8] c"\0AExiting ...\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [128 x i8]
%9 = alloca %struct.sockaddr_in
%10 = alloca [1024 x i8]
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = icmp slt i32 %23, 1024
br i1 %24, label %28, label %25
25: ; preds = %18
%26 = load i32, i32* %6
%27 = icmp sgt i32 %26, 65535
br i1 %27, label %28, label %31
28: ; preds = %25, %18
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %25
br label %32
32: ; preds = %31
%33 = bitcast %struct.sockaddr_in* %9 to i8*
%34 = call i32 @memset(i8* %33, i32 0, i32 24)
%35 = load i8*, i8** @AF_INET
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i8* %35, i8** %36
%37 = load i32, i32* %6
%38 = call i8* @htons(i32 %37)
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i8* %38, i8** %39
%40 = call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%42 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %41, i32 0, i32 0
store i8* %40, i8** %42
%43 = load i8*, i8** @AF_INET
%44 = load i32, i32* @SOCK_STREAM
%45 = call i32 @socket(i8* %43, i32 %44, i32 0)
store i32 %45, i32* %11
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %32
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %32
%51 = load i32, i32* %11
%52 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%53 = call i64 @connect(i32 %51, %struct.sockaddr* %52, i32 24)
%54 = icmp slt i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %50
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
%60 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%61 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %60)
%62 = load i32, i32* %11
%63 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%64 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%65 = call i32 @strlen(i8* %64)
%66 = call i64 @write(i32 %62, i8* %63, i32 %65)
%67 = load i32, i32* %11
%68 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%69 = call i32 @read(i32 %67, i8* %68, i32 128)
%70 = load i32, i32* %11
%71 = call i32 @close(i32 %70)
%72 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%73 = call i32 @atoi(i8* %72)
store i32 %73, i32* %7
%74 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%75 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%76 = call i32 @strlen(i8* %75)
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %74, i32 %76)
%78 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%79 = call i64 @strcmp(i8* %78, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %58
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %58
%85 = load i8*, i8** @AF_INET
%86 = load i32, i32* @SOCK_STREAM
%87 = call i32 @socket(i8* %85, i32 %86, i32 0)
store i32 %87, i32* %11
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %84
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%91 = call i32 @exit(i32 1)
unreachable
92: ; preds = %84
%93 = bitcast %struct.sockaddr_in* %9 to i8*
%94 = call i32 @memset(i8* %93, i32 0, i32 24)
%95 = load i8*, i8** @AF_INET
%96 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i8* %95, i8** %96
%97 = load i32, i32* %7
%98 = call i8* @htons(i32 %97)
%99 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i8* %98, i8** %99
%100 = call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%101 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%102 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %101, i32 0, i32 0
store i8* %100, i8** %102
%103 = call i32 @sleep(i32 3)
%104 = load i32, i32* %11
%105 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%106 = call i64 @connect(i32 %104, %struct.sockaddr* %105, i32 24)
%107 = icmp slt i64 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %92
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%110 = call i32 @exit(i32 1)
unreachable
111: ; preds = %92
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%113 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%114 = call i32 @read(i32 0, i8* %113, i32 128)
%115 = load i32, i32* %11
%116 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%117 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%118 = call i32 @strlen(i8* %117)
%119 = call i64 @write(i32 %115, i8* %116, i32 %118)
%120 = icmp slt i64 %119, 0
br i1 %120, label %121, label %124
121: ; preds = %111
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
%123 = call i32 @exit(i32 1)
unreachable
124: ; preds = %111
%125 = load i32, i32* %11
%126 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%127 = call i32 @read(i32 %125, i8* %126, i32 128)
store i32 %127, i32* %12
%128 = icmp slt i32 %127, 0
br i1 %128, label %129, label %132
129: ; preds = %124
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0))
%131 = call i32 @exit(i32 1)
unreachable
132: ; preds = %124
%133 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%134 = load i32, i32* %12
%135 = call i64 @write(i32 1, i8* %133, i32 %134)
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i64 0, i64 0))
%137 = load i32, i32* %11
%138 = call i32 @close(i32 %137)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@.str.1 = [23 x i8] c"Usage: ./client <port>\00"
@.str.2 = [32 x i8] c"Port must between 1024 to 65535\00"
@AF_INET = global i8* null
@.str.3 = [10 x i8] c"127.0.0.1\00"
@SOCK_STREAM = global i32 0
@.str.4 = [15 x i8] c"socket() error\00"
@.str.5 = [16 x i8] c"connect() error\00"
@.str.6 = [41 x i8] c"Type Name of the Service(s1,s2,s3,..) : \00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [7 x i8] c"%s %d\0A\00"
@.str.9 = [5 x i8] c"exit\00"
@.str.10 = [22 x i8] c"Service Unavailable !\00"
@.str.12 = [13 x i8] c"send() error\00"
@.str.13 = [13 x i8] c"recv() error\00"
@str = [23 x i8] c"connection successfull\00"
@str.15 = [13 x i8] c"\0AExiting ...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = alloca %struct.sockaddr_in
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%7 = icmp eq i32 %0, 1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = add i32 %14, -65536
%16 = icmp ult i32 %15, -64512
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %11
%21 = bitcast %struct.sockaddr_in* %4 to i8*
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%23 = call i32 @memset(i8* %21, i32 0, i32 24)
%24 = load i8*, i8** @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i8* %24, i8** %25
%26 = call i8* @htons(i32 %14)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i8* %26, i8** %27
%28 = call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
store i8* %28, i8** %29
%30 = load i8*, i8** @AF_INET
%31 = load i32, i32* @SOCK_STREAM
%32 = call i32 @socket(i8* %30, i32 %31, i32 0)
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %20
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %20
%38 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%39 = call i64 @connect(i32 %32, %struct.sockaddr* %38, i32 24)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %37
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
%46 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%47 = call i32 @strlen(i8* %6)
%48 = call i64 @write(i32 %32, i8* %6, i32 %47)
%49 = call i32 @read(i32 %32, i8* %6, i32 128)
%50 = call i32 @close(i32 %32)
%51 = call i32 @atoi(i8* %6)
%52 = call i32 @strlen(i8* %6)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %6, i32 %52)
%54 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %44
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %44
%60 = load i8*, i8** @AF_INET
%61 = load i32, i32* @SOCK_STREAM
%62 = call i32 @socket(i8* %60, i32 %61, i32 0)
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %59
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %59
%68 = call i32 @memset(i8* %21, i32 0, i32 24)
%69 = load i8*, i8** @AF_INET
store i8* %69, i8** %25
%70 = call i8* @htons(i32 %51)
store i8* %70, i8** %27
%71 = call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i8* %71, i8** %29
%72 = call i32 @sleep(i32 3)
%73 = call i64 @connect(i32 %62, %struct.sockaddr* %38, i32 24)
%74 = icmp slt i64 %73, 0
br i1 %74, label %75, label %78
75: ; preds = %67
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %67
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%80 = call i32 @read(i32 0, i8* %6, i32 128)
%81 = call i32 @strlen(i8* %6)
%82 = call i64 @write(i32 %62, i8* %6, i32 %81)
%83 = icmp slt i64 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %78
%85 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %78
%88 = call i32 @read(i32 %62, i8* %22, i32 128)
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %93
90: ; preds = %87
%91 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0))
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %87
%94 = call i64 @write(i32 1, i8* %22, i32 %88)
%95 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.15, i64 0, i64 0))
%96 = call i32 @close(i32 %62)
ret i32 0
}